Search in sources :

Example 16 with RowKeyWrapper

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());
}
Also used : ByteString(com.google.protobuf.ByteString) RowSet(com.google.bigtable.v2.RowSet) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 17 with RowKeyWrapper

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;
}
Also used : InterleaveFilter(com.google.cloud.bigtable.data.v2.models.Filters.InterleaveFilter) ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter) Filter(org.apache.hadoop.hbase.filter.Filter) ArrayList(java.util.ArrayList) RangeSet(com.google.common.collect.RangeSet) TreeRangeSet(com.google.common.collect.TreeRangeSet) ImmutableRangeSet(com.google.common.collect.ImmutableRangeSet) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper)

Example 18 with RowKeyWrapper

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);
}
Also used : PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 19 with RowKeyWrapper

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);
}
Also used : Filters(com.google.cloud.bigtable.data.v2.models.Filters) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) MultiRowRangeFilter(org.apache.hadoop.hbase.filter.MultiRowRangeFilter) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 20 with RowKeyWrapper

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);
}
Also used : Filters(com.google.cloud.bigtable.data.v2.models.Filters) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) MultiRowRangeFilter(org.apache.hadoop.hbase.filter.MultiRowRangeFilter) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Aggregations

RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)34 Test (org.junit.Test)28 RowSet (com.google.bigtable.v2.RowSet)14 ByteString (com.google.protobuf.ByteString)12 Filters (com.google.cloud.bigtable.data.v2.models.Filters)9 MultiRowRangeFilter (org.apache.hadoop.hbase.filter.MultiRowRangeFilter)9 RowRange (org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange)9 PrefixFilter (org.apache.hadoop.hbase.filter.PrefixFilter)5 FilterList (org.apache.hadoop.hbase.filter.FilterList)4 BigtableExtendedScan (com.google.cloud.bigtable.hbase.BigtableExtendedScan)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 BoundType (com.google.common.collect.BoundType)2 Filter (org.apache.hadoop.hbase.filter.Filter)2 ChainFilter (com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter)1 InterleaveFilter (com.google.cloud.bigtable.data.v2.models.Filters.InterleaveFilter)1 ByteStringRange (com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange)1 FilterAdapter (com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapter)1 FilterAdapterContext (com.google.cloud.bigtable.hbase.adapters.filters.FilterAdapterContext)1 ImmutableRangeSet (com.google.common.collect.ImmutableRangeSet)1 RangeSet (com.google.common.collect.RangeSet)1