ThemisCpUtil { public static void addLockAndWriteColumnToGet(Get userGet, Get internalGet, long startTs) throws IOException { boolean excludeDataColumn = false; for (Entry<byte[], NavigableSet<byte[]>> entry : userGet.getFamilyMap().entrySet()) { if (entry.getValue() != null && entry.getValue().size() > 0) { for (byte[] qualifier : entry.getValue()) { Column dataColumn = new Column(entry.getKey(), qualifier); if (!(internalGet.getFamilyMap().containsKey(ColumnUtil.LOCK_FAMILY_NAME) && internalGet .getFamilyMap().get(ColumnUtil.LOCK_FAMILY_NAME) == null)) { Column lockColumn = ColumnUtil.getLockColumn(dataColumn); internalGet.addColumn(lockColumn.getFamily(), lockColumn.getQualifier()); } addWriteColumnToGet(dataColumn, internalGet); } } else { internalGet.addFamily(ColumnUtil.LOCK_FAMILY_NAME); if (ColumnUtil.isCommitToSameFamily()) { internalGet.addFamily(entry.getKey()); } else { internalGet.addFamily(ColumnUtil.PUT_FAMILY_NAME_BYTES); internalGet.addFamily(ColumnUtil.DELETE_FAMILY_NAME_BYTES); } excludeDataColumn = true; } } if (excludeDataColumn) { internalGet.setFilter(new ExcludeDataColumnFilter()); } internalGet.setTimeRange(0, startTs); }  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 testAddLockAndWriteColumnToGet() throws IOException { byte[][] families = new byte[][] {FAMILY, FAMILY, ANOTHER_FAMILY}; byte[][] qualifiers = new byte[][] {QUALIFIER, ANOTHER_QUALIFIER, QUALIFIER}; Get userGet = new Get(ROW); for (int i = 0; i < families.length; ++i) { userGet.addColumn(families[i], qualifiers[i]); } Get internalGet = new Get(userGet.getRow()); ThemisCpUtil.addLockAndWriteColumnToGet(userGet, internalGet, PREWRITE_TS); Assert.assertEquals(3, internalGet.getFamilyMap().size()); if (ColumnUtil.isCommitToSameFamily()) { Assert.assertEquals(4, internalGet.getFamilyMap().get(FAMILY).size()); Assert.assertEquals(2, internalGet.getFamilyMap().get(ANOTHER_FAMILY).size()); } else { Assert.assertEquals(3, internalGet.getFamilyMap().get(ColumnUtil.PUT_FAMILY_NAME_BYTES).size()); Assert.assertEquals(3, internalGet.getFamilyMap().get(ColumnUtil.DELETE_FAMILY_NAME_BYTES).size()); } Assert.assertEquals(3, internalGet.getFamilyMap().get(ColumnUtil.LOCK_FAMILY_NAME).size()); for (int i = 0; i < families.length; ++i) { checkReadWithLockAndWriteColumns(internalGet.getFamilyMap(), new ColumnCoordinate(families[i], qualifiers[i])); } Assert.assertEquals(PREWRITE_TS, internalGet.getTimeRange().getMax()); Assert.assertEquals(1, internalGet.getMaxVersions()); userGet = new Get(ROW); userGet.addFamily(FAMILY); internalGet = new Get(userGet.getRow()); ThemisCpUtil.addLockAndWriteColumnToGet(userGet, internalGet, PREWRITE_TS); if (ColumnUtil.isCommitToSameFamily()) { checkAddLockAndDataFamily(internalGet, ColumnUtil.LOCK_FAMILY_NAME, FAMILY); } else { checkAddLockAndDataFamily(internalGet, ColumnUtil.LOCK_FAMILY_NAME, ColumnUtil.PUT_FAMILY_NAME_BYTES, ColumnUtil.DELETE_FAMILY_NAME_BYTES); } Assert.assertTrue(internalGet.getFilter() instanceof ExcludeDataColumnFilter); userGet = new Get(ROW); userGet.addFamily(ANOTHER_FAMILY); userGet.addColumn(FAMILY, ANOTHER_QUALIFIER); internalGet = new Get(userGet.getRow()); ThemisCpUtil.addLockAndWriteColumnToGet(userGet, internalGet, PREWRITE_TS); if (ColumnUtil.isCommitToSameFamily()) { checkAddLockAndDataFamily(internalGet, ColumnUtil.LOCK_FAMILY_NAME, ANOTHER_FAMILY); checkReadWithWriteColumns(internalGet.getFamilyMap(), new ColumnCoordinate(FAMILY, ANOTHER_QUALIFIER)); } else { checkAddLockAndDataFamily(internalGet, ColumnUtil.LOCK_FAMILY_NAME, ColumnUtil.PUT_FAMILY_NAME_BYTES, ColumnUtil.DELETE_FAMILY_NAME_BYTES); } Assert.assertTrue(internalGet.getFilter() instanceof ExcludeDataColumnFilter); }