use of com.google.cloud.bigtable.hbase.BigtableExtendedScan in project java-bigtable-hbase by googleapis.
the class ScanAdapter method getRangeSet.
private RangeSet<RowKeyWrapper> getRangeSet(Scan scan) {
if (scan instanceof BigtableExtendedScan) {
RowSet rowSet = ((BigtableExtendedScan) scan).getRowSet();
return rowRangeAdapter.rowSetToRangeSet(rowSet);
} else {
RangeSet<RowKeyWrapper> rangeSet = TreeRangeSet.create();
final ByteString startRow = ByteString.copyFrom(scan.getStartRow());
final ByteString stopRow = ByteString.copyFrom(scan.getStopRow());
if (scan.isGetScan()) {
rangeSet.add(Range.singleton(new RowKeyWrapper(startRow)));
} else {
final BoundType startBound = (!OPEN_CLOSED_AVAILABLE || scan.includeStartRow()) ? BoundType.CLOSED : BoundType.OPEN;
final BoundType endBound = (!OPEN_CLOSED_AVAILABLE || !scan.includeStopRow()) ? BoundType.OPEN : BoundType.CLOSED;
rangeSet.add(rowRangeAdapter.boundedRange(startBound, startRow, endBound, stopRow));
}
return rangeSet;
}
}
use of com.google.cloud.bigtable.hbase.BigtableExtendedScan in project java-bigtable-hbase by googleapis.
the class TestScanAdapter method testExtendedScan.
@Test
public void testExtendedScan() {
byte[] row1 = Bytes.toBytes("row1");
byte[] row2 = Bytes.toBytes("row2");
byte[] startRow = Bytes.toBytes(START_KEY);
byte[] stopRow = Bytes.toBytes(STOP_KEY);
byte[] prefix = Bytes.toBytes("prefix");
byte[] prefixEnd = calculatePrefixEnd(prefix);
BigtableExtendedScan scan = new BigtableExtendedScan();
scan.addRowKey(row1);
scan.addRowKey(row2);
scan.addRange(startRow, stopRow);
scan.addRangeWithPrefix(prefix);
scanAdapter.adapt(scan, throwingReadHooks, query);
RowSet expected = RowSet.newBuilder().addRowKeys(ByteStringer.wrap(row1)).addRowKeys(ByteStringer.wrap(row2)).addRowRanges(toRange(prefix, prefixEnd)).addRowRanges(toRange(startRow, stopRow)).build();
Assert.assertEquals(expected, query.toProto(requestContext).getRows());
}
Aggregations