@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()); }
@Override public void adapt(Scan scan, ReadHooks readHooks, Query query) { throwIfUnsupportedScan(scan); toByteStringRange(scan, query); query.filter(buildFilter(scan, readHooks)); if (LIMIT_AVAILABLE && scan.getLimit() > 0) { query.limit(scan.getLimit()); } }
ScanAdapter implements ReadOperationAdapter<Scan> { @Override public void adapt(Scan scan, ReadHooks readHooks, Query query) { throwIfUnsupportedScan(scan); toByteStringRange(scan, query); query.filter(buildFilter(scan, readHooks)); if (LIMIT_AVAILABLE && scan.getLimit() > 0) { query.limit(scan.getLimit()); } } }
ScanAdapter implements ReadOperationAdapter<Scan> { @Override public void adapt(Scan scan, ReadHooks readHooks, Query query) { throwIfUnsupportedScan(scan); toByteStringRange(scan, query); query.filter(buildFilter(scan, readHooks)); if (LIMIT_AVAILABLE && scan.getLimit() > 0) { query.limit(scan.getLimit()); } } ScanAdapter(FilterAdapter filterAdapter, RowRangeAdapter rowRangeAdapter); }
ScanAdapter implements ReadOperationAdapter<Scan> { @Override public void adapt(Scan scan, ReadHooks readHooks, Query query) { throwIfUnsupportedScan(scan); toByteStringRange(scan, query); query.filter(buildFilter(scan, readHooks)); if (LIMIT_AVAILABLE && scan.getLimit() > 0) { query.limit(scan.getLimit()); } } ScanAdapter(FilterAdapter filterAdapter, RowRangeAdapter rowRangeAdapter); void throwIfUnsupportedScan(Scan scan); Filters.Filter buildFilter(Scan scan, ReadHooks hooks); @Override void adapt(Scan scan, ReadHooks readHooks, Query query); }
ScanAdapter implements ReadOperationAdapter<Scan> { @Override public void adapt(Scan scan, ReadHooks readHooks, Query query) { throwIfUnsupportedScan(scan); toByteStringRange(scan, query); query.filter(buildFilter(scan, readHooks)); if (LIMIT_AVAILABLE && scan.getLimit() > 0) { query.limit(scan.getLimit()); } } ScanAdapter(FilterAdapter filterAdapter, RowRangeAdapter rowRangeAdapter); void throwIfUnsupportedScan(Scan scan); Filters.Filter buildFilter(Scan scan, ReadHooks hooks); @Override void adapt(Scan scan, ReadHooks readHooks, Query query);  }