use of com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapter in project java-bigtable-hbase by googleapis.
the class TestScanAdapter method testNarrowedScan.
@Test
public void testNarrowedScan() throws IOException {
FilterAdapter filterAdapter = Mockito.mock(FilterAdapter.class);
ScanAdapter scanAdapter = new ScanAdapter(filterAdapter, new RowRangeAdapter());
Filter fakeFilter = new FilterBase() {
@Override
public ReturnCode filterKeyValue(Cell v) throws IOException {
return ReturnCode.INCLUDE;
}
};
RangeSet<RowKeyWrapper> rangeSet = ImmutableRangeSet.of(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("b")), new RowKeyWrapper(ByteString.copyFromUtf8("d"))));
Mockito.when(filterAdapter.getIndexScanHint(any(Filter.class))).thenReturn(rangeSet);
Mockito.when(filterAdapter.adaptFilter(any(FilterAdapterContext.class), eq(fakeFilter))).thenReturn(Optional.of(Filters.FILTERS.pass()));
Scan scan = new Scan().withStartRow("a".getBytes()).withStopRow("z".getBytes()).setFilter(fakeFilter);
scanAdapter.adapt(scan, throwingReadHooks, query);
Assert.assertEquals(RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("b")).setEndKeyOpen(ByteString.copyFromUtf8("d"))).build(), query.toProto(requestContext).getRows());
}
Aggregations