use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper 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());
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestFilterListAdapter method testChainedIndexHintDisjointIntersection.
@Test
public void testChainedIndexHintDisjointIntersection() {
FilterAdapter adapter = FilterAdapter.buildAdapter();
PrefixFilter p1 = new PrefixFilter("a".getBytes());
PrefixFilter p2 = new PrefixFilter("b".getBytes());
FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, p1, p2);
RangeSet<RowKeyWrapper> actual = adapter.getIndexScanHint(filterList);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of();
Assert.assertEquals(expected, actual);
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestFilterListAdapter method testChainedIndexHintIntersection.
@Test
public void testChainedIndexHintIntersection() {
FilterAdapter adapter = FilterAdapter.buildAdapter();
PrefixFilter p1 = new PrefixFilter("a".getBytes());
PrefixFilter p2 = new PrefixFilter("abc".getBytes());
FilterList filterList = new FilterList(Operator.MUST_PASS_ALL, p1, p2);
RangeSet<RowKeyWrapper> actual = adapter.getIndexScanHint(filterList);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("abc")), new RowKeyWrapper(ByteString.copyFromUtf8("abd"))));
Assert.assertEquals(expected, actual);
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestMultiRowRangeAdapter method testOpenClosedSingle.
@Test
public void testOpenClosedSingle() throws IOException {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Collections.singletonList(new RowRange("cc", false, "ee", true)));
Filters.Filter adaptedFilter = adapter.adapt(context, filter);
Assert.assertEquals(unaffectedRowFilter, adaptedFilter);
RangeSet<RowKeyWrapper> indexScanHint = adapter.getIndexScanHint(filter);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.openClosed(new RowKeyWrapper(ByteString.copyFromUtf8("cc")), new RowKeyWrapper(ByteString.copyFromUtf8("ee"))));
Assert.assertEquals(expected, indexScanHint);
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestRowRangeAdapter method testGreaterThan.
@Test
public void testGreaterThan() {
ByteString key = ByteString.copyFromUtf8("hi");
RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyOpen(key)).build();
RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.greaterThan(new RowKeyWrapper(key))).build();
assertEquals(expected, out);
adapter.rangeSetToByteStringRange(out, query);
assertEquals(in, query.toProto(requestContext).getRows());
}
Aggregations