ThemisCpUtil { public static Scan constructLockAndWriteScan(Scan userScan, long startTs) throws IOException { boolean excludeDataColumn = false; Scan internalScan = new Scan(userScan); internalScan.setFilter(null); internalScan.setFamilyMap(new TreeMap<byte[], NavigableSet<byte[]>>(Bytes.BYTES_COMPARATOR)); for (Entry<byte[], NavigableSet<byte[]>> entry : userScan.getFamilyMap().entrySet()) { if (entry.getValue() != null && entry.getValue().size() > 0) { for (byte[] qualifier : entry.getValue()) { Column dataColumn = new Column(entry.getKey(), qualifier); addLockAndWriteColumnToScan(dataColumn, internalScan); } } else { internalScan.addFamily(ColumnUtil.LOCK_FAMILY_NAME); internalScan.addFamily(entry.getKey()); if (!ColumnUtil.isCommitToSameFamily()) { internalScan.addFamily(ColumnUtil.PUT_FAMILY_NAME_BYTES); internalScan.addFamily(ColumnUtil.DELETE_FAMILY_NAME_BYTES); } excludeDataColumn = true; } } if (excludeDataColumn) { internalScan.setFilter(new ExcludeDataColumnFilter()); } internalScan.setTimeRange(0, startTs); moveRowkeyFiltersForWriteScan(userScan, internalScan); return internalScan; }  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 testCreateScanWithLockAndWriteColumns() throws IOException { byte[] startRow = Bytes.toBytes("aaa"); byte[] stopRow = Bytes.toBytes("bbb"); Scan scan = new Scan(startRow, stopRow); scan.addColumn(FAMILY, QUALIFIER); scan.addColumn(ANOTHER_FAMILY, ANOTHER_QUALIFIER); Scan createdScan = ThemisCpUtil.constructLockAndWriteScan(scan, PREWRITE_TS); Assert.assertArrayEquals(startRow, createdScan.getStartRow()); Assert.assertArrayEquals(stopRow, createdScan.getStopRow()); Assert.assertEquals(3, createdScan.getFamilies().length); checkReadWithLockAndWriteColumns(createdScan.getFamilyMap(), COLUMN); checkReadWithLockAndWriteColumns(createdScan.getFamilyMap(), new ColumnCoordinate(ANOTHER_FAMILY, ANOTHER_QUALIFIER)); scan = new Scan(startRow, stopRow); scan.addFamily(ANOTHER_FAMILY); scan.addColumn(FAMILY, QUALIFIER); createdScan = ThemisCpUtil.constructLockAndWriteScan(scan, PREWRITE_TS); Assert.assertArrayEquals(startRow, createdScan.getStartRow()); Assert.assertArrayEquals(stopRow, createdScan.getStopRow()); if (ColumnUtil.isCommitToSameFamily()) { Assert.assertEquals(3, createdScan.getFamilies().length); checkReadWithWriteColumns(createdScan.getFamilyMap(), new ColumnCoordinate(FAMILY, QUALIFIER)); } else { Assert.assertEquals(4, createdScan.getFamilies().length); } Assert.assertTrue(createdScan.getFamilyMap().containsKey(ANOTHER_FAMILY) && createdScan.getFamilyMap().get(ANOTHER_FAMILY) == null); Assert.assertTrue(createdScan.getFamilyMap().containsKey(ColumnUtil.LOCK_FAMILY_NAME) && createdScan.getFamilyMap().get(ColumnUtil.LOCK_FAMILY_NAME) == null); Assert.assertTrue(createdScan.getFilter() instanceof ExcludeDataColumnFilter); }