use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestRowRangeAdapter method testSingleOpenClosedRangeRowSet.
@Test
public void testSingleOpenClosedRangeRowSet() {
ByteString key1 = ByteString.copyFromUtf8("myKey");
ByteString key2 = ByteString.copyFromUtf8("otherKey");
RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyOpen(key1).setEndKeyClosed(key2)).build();
RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.openClosed(new RowKeyWrapper(key1), new RowKeyWrapper(key2))).build();
assertEquals(expected, out);
adapter.rangeSetToByteStringRange(out, query);
assertEquals(in, query.toProto(requestContext).getRows());
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class FilterListAdapter method collectChildHints.
private List<RangeSet<RowKeyWrapper>> collectChildHints(FilterList filter) {
List<Filter> subFilters = filter.getFilters();
List<RangeSet<RowKeyWrapper>> hints = new ArrayList<>(subFilters.size());
RangeSet<RowKeyWrapper> last = null;
for (Filter subFilter : subFilters) {
SingleFilterAdapter<?> subAdapter = subFilterAdapter.getAdapterForFilterOrThrow(subFilter);
RangeSet<RowKeyWrapper> subRangeSet = subAdapter.getIndexScanHint(subFilter);
// consecutive universes.
if (last != subRangeSet) {
hints.add(subRangeSet);
last = subRangeSet;
}
}
return hints;
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestFilterListAdapter method testInterleavedIndexHintDisjointUnion.
@Test
public void testInterleavedIndexHintDisjointUnion() {
FilterAdapter adapter = FilterAdapter.buildAdapter();
PrefixFilter p1 = new PrefixFilter("a".getBytes());
PrefixFilter p2 = new PrefixFilter("c".getBytes());
FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, p1, p2);
RangeSet<RowKeyWrapper> actual = adapter.getIndexScanHint(filterList);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("a")), new RowKeyWrapper(ByteString.copyFromUtf8("b")))).add(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("c")), new RowKeyWrapper(ByteString.copyFromUtf8("d")))).build();
Assert.assertEquals(expected, actual);
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestMultiRowRangeAdapter method testUnboundedStopSingle.
@Test
public void testUnboundedStopSingle() throws IOException {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Collections.singletonList(new RowRange("cc".getBytes(), true, HConstants.EMPTY_END_ROW, true)));
Filters.Filter adaptedFilter = adapter.adapt(context, filter);
Assert.assertEquals(unaffectedRowFilter, adaptedFilter);
RangeSet<RowKeyWrapper> indexScanHint = adapter.getIndexScanHint(filter);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.atLeast(new RowKeyWrapper(ByteString.copyFromUtf8("cc"))));
Assert.assertEquals(expected, indexScanHint);
}
use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.
the class TestMultiRowRangeAdapter method testClosedOpenSingle.
@Test
public void testClosedOpenSingle() throws IOException {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Collections.singletonList(new RowRange("cc", true, "ee", false)));
Filters.Filter adaptedFilter = adapter.adapt(context, filter);
Assert.assertEquals(unaffectedRowFilter, adaptedFilter);
RangeSet<RowKeyWrapper> indexScanHint = adapter.getIndexScanHint(filter);
RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("cc")), new RowKeyWrapper(ByteString.copyFromUtf8("ee"))));
Assert.assertEquals(expected, indexScanHint);
}
Aggregations