ThemisCpUtil { protected static List<KeyValue> getPutKvs(List<KeyValue> writeKvs) { if (ColumnUtil.isCommitToSameFamily()) { List<KeyValue> result = new ArrayList<KeyValue>(); Column lastDataColumn = null; KeyValue lastKv = null; for (int i = 0; i < writeKvs.size(); ++i) { KeyValue kv = writeKvs.get(i); Column column = new Column(kv.getFamily(), kv.getQualifier()); Column dataColumn = ColumnUtil.getDataColumn(column); if (lastDataColumn != null && lastDataColumn.equals(dataColumn)) { if (lastKv.getTimestamp() < kv.getTimestamp()) { lastKv = kv; } } else { if (lastKv != null && ColumnUtil.isPutColumn(lastKv.getFamily(), lastKv.getQualifier())) { result.add(lastKv); } lastDataColumn = dataColumn; lastKv = kv; } } if (lastKv != null && ColumnUtil.isPutColumn(lastKv.getFamily(), lastKv.getQualifier())) { result.add(lastKv); } return result; } else { return getPutKvsForCommitDifferentFamily(writeKvs); } }  static String getDisallowedFilterClassNameString(); static void processFilters(Filter filter, FilterCallable callable); static void moveRowkeyFiltersForWriteGet(Get sourceGet, Get destGet); static void moveRowkeyFiltersForWriteScan(Scan sourceScan, Scan destScan); static void addLockAndWriteColumnToGet(Get userGet, Get internalGet, long startTs); static Result removeNotRequiredLockColumns(Map<byte[], NavigableSet<byte[]>> familyMap,
      Result result); static Get constructLockAndWriteGet(Get userGet, long startTs); static void prepareGet(Get get, Collection<HColumnDescriptor> families); static void prepareScan(Scan scan, Collection<HColumnDescriptor> families); static Scan constructLockAndWriteScan(Scan userScan, long startTs); static void addLockAndWriteColumnToScan(Column column, Scan scan); static Get constructDataGetByPutKvs(List<KeyValue> putKvs, Filter filter); static void addWriteColumnToGet(Column column, Get get); static boolean isLockResult(Result result); static Pair<List<KeyValue>, List<KeyValue>> seperateLockAndWriteKvs(List<KeyValue> kvs); static Set<Class<? extends Filter>> ALLOWED_ROWKEY_FILTER_CLASSES; static Set<Class<? extends Filter>> DISALLOWD_FILTERS; }
@Test public void testGetPutKvs() { List<KeyValue> writeKvs = new ArrayList<KeyValue>(); writeKvs.add(getPutKv(COLUMN, PREWRITE_TS)); writeKvs.add(getDeleteKv(COLUMN, PREWRITE_TS + 1)); writeKvs.add(getPutKv(COLUMN_WITH_ANOTHER_FAMILY, PREWRITE_TS + 1)); writeKvs.add(getDeleteKv(COLUMN_WITH_ANOTHER_FAMILY, PREWRITE_TS)); writeKvs.add(getDeleteKv(new ColumnCoordinate(ROW, ANOTHER_FAMILY, ANOTHER_QUALIFIER), PREWRITE_TS)); writeKvs.add(getPutKv(COLUMN_WITH_ANOTHER_QUALIFIER, PREWRITE_TS)); Collections.sort(writeKvs, KeyValue.COMPARATOR); List<KeyValue> putKvs = ThemisCpUtil.getPutKvs(writeKvs); Assert.assertEquals(2, putKvs.size()); Collections.sort(putKvs, new KVComparator()); Assert.assertTrue(getPutKv(COLUMN_WITH_ANOTHER_FAMILY, PREWRITE_TS + 1).equals(putKvs.get(0))); Assert.assertTrue(getPutKv(COLUMN_WITH_ANOTHER_QUALIFIER, PREWRITE_TS).equals(putKvs.get(1))); writeKvs.clear(); writeKvs.add(getPutKv(COLUMN_WITH_ANOTHER_FAMILY, PREWRITE_TS)); writeKvs.add(getPutKv(COLUMN, PREWRITE_TS)); Collections.sort(writeKvs, new KVComparator()); putKvs = ThemisCpUtil.getPutKvs(writeKvs); Assert.assertTrue(getPutKv(COLUMN_WITH_ANOTHER_FAMILY, PREWRITE_TS).equals(putKvs.get(0))); Assert.assertTrue(getPutKv(COLUMN, PREWRITE_TS).equals(putKvs.get(1))); }