Source:
public void testEstimatedAndSplitForSmallTable() throws Exception { TableName tableName = newTestTableName(); try (Admin admin = connection.getAdmin()) { LOG.info("Creating table in testEstimatedAndSplitForSmallTable()"); admin.createTable( new HTableDescriptor(tableName).addFamily(new HColumnDescriptor(COLUMN_FAMILY))); try (Table table = connection.getTable(tableName)) { table.put(Arrays.asList( new Put(Bytes.toBytes("row1")).addColumn(COLUMN_FAMILY, QUALIFIER1, Bytes.toBytes("1")), new Put(Bytes.toBytes("row2")).addColumn(COLUMN_FAMILY, QUALIFIER1, Bytes.toBytes("2")))); } LOG.info("getSampleKeys() in testEstimatedAndSplitForSmallTable()"); List<SampleRowKeysResponse> sampleRowKeys = getSampleKeys(tableName); try { LOG.info("Creating BoundedSource in testEstimatedAndSplitForSmallTable()"); BoundedSource<Result> source = CloudBigtableIO.read(new CloudBigtableScanConfiguration( projectId, zoneId, clusterId, tableName.getQualifierAsString(), new Scan())); long estimatedSizeBytes = source.getEstimatedSizeBytes(null); SampleRowKeysResponse lastSample = sampleRowKeys.get(sampleRowKeys.size() - 1); Assert.assertEquals(lastSample.getOffsetBytes(), estimatedSizeBytes); LOG.info("Creating Bundles in testEstimatedAndSplitForSmallTable()"); List<? extends BoundedSource<Result>> bundles = source.splitIntoBundles(estimatedSizeBytes / 2 + 1, null); LOG.info("Creatd Bundles in testEstimatedAndSplitForSmallTable()"); Assert.assertEquals(sampleRowKeys.size() * 2 - 1, bundles.size()); } finally { LOG.info("Deleting table in testEstimatedAndSplitForSmallTable()"); admin.deleteTable(tableName); LOG.info("Deleted table in testEstimatedAndSplitForSmallTable()"); } } }

Target:
public void testEstimatedAndSplitForSmallTable() throws Exception { TableName tableName = newTestTableName(); try (Admin admin = connection.getAdmin()) { LOG.info("Creating table in testEstimatedAndSplitForSmallTable()"); admin.createTable( new HTableDescriptor(tableName).addFamily(new HColumnDescriptor(COLUMN_FAMILY))); try (Table table = connection.getTable(tableName)) { table.put(Arrays.asList( new Put(Bytes.toBytes("row1")).addColumn(COLUMN_FAMILY, QUALIFIER1, Bytes.toBytes("1")), new Put(Bytes.toBytes("row2")).addColumn(COLUMN_FAMILY, QUALIFIER1, Bytes.toBytes("2")))); } LOG.info("getSampleKeys() in testEstimatedAndSplitForSmallTable()"); try { CloudBigtableScanConfiguration config = new CloudBigtableScanConfiguration(projectId, zoneId, clusterId, tableName.getQualifierAsString(), new Scan()); CloudBigtableIO.Source source = new CloudBigtableIO.Source(config); List<SampleRowKeysResponse> sampleRowKeys = source.getSampleRowKeys(); LOG.info("Creating BoundedSource in testEstimatedAndSplitForSmallTable()"); long estimatedSizeBytes = source.getEstimatedSizeBytes(null); SampleRowKeysResponse lastSample = sampleRowKeys.get(sampleRowKeys.size() - 1); Assert.assertEquals(lastSample.getOffsetBytes(), estimatedSizeBytes); LOG.info("Creating Bundles in testEstimatedAndSplitForSmallTable()"); List<? extends BoundedSource<Result>> bundles = source.splitIntoBundles(estimatedSizeBytes / 2 + 1, null); LOG.info("Created Bundles in testEstimatedAndSplitForSmallTable()"); Assert.assertEquals(sampleRowKeys.size() * 2 - 1, bundles.size()); Assert.assertSame(sampleRowKeys, source.getSampleRowKeys()); } finally { LOG.info("Deleting table in testEstimatedAndSplitForSmallTable()"); admin.deleteTable(tableName); LOG.info("Deleted table in testEstimatedAndSplitForSmallTable()"); } } }