Search in sources :

Example 26 with RowKeyWrapper

use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.

the class TestMultiRowRangeAdapter method testOverlap.

@Test
public void testOverlap() throws IOException {
    MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(new RowRange("bb", true, "cc", true), new RowRange("ca", true, "yy", true)));
    Filters.Filter adaptedFilter = adapter.adapt(context, filter);
    Assert.assertEquals(unaffectedRowFilter, adaptedFilter);
    RangeSet<RowKeyWrapper> indexScanHint = adapter.getIndexScanHint(filter);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.closed(new RowKeyWrapper(ByteString.copyFromUtf8("bb")), new RowKeyWrapper(ByteString.copyFromUtf8("yy"))));
    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 27 with RowKeyWrapper

use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.

the class TestFilterListAdapter method testInterleavedIndexHintUnion.

@Test
public void testInterleavedIndexHintUnion() {
    FilterAdapter adapter = FilterAdapter.buildAdapter();
    PrefixFilter p1 = new PrefixFilter("a".getBytes());
    PrefixFilter p2 = new PrefixFilter("abc".getBytes());
    FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, p1, p2);
    RangeSet<RowKeyWrapper> actual = adapter.getIndexScanHint(filterList);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.of(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("a")), new RowKeyWrapper(ByteString.copyFromUtf8("b"))));
    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 28 with RowKeyWrapper

use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.

the class TestPrefixFilterAdapter method testIndexIsNarrowed.

@Test
public void testIndexIsNarrowed() {
    PrefixFilterAdapter adapter = new PrefixFilterAdapter();
    String prefix = "Foobar";
    PrefixFilter filter = new PrefixFilter(Bytes.toBytes(prefix));
    RangeSet<RowKeyWrapper> hint = adapter.getIndexScanHint(filter);
    ImmutableRangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.closedOpen(new RowKeyWrapper(ByteString.copyFromUtf8("Foobar")), new RowKeyWrapper(ByteString.copyFromUtf8("Foobas")))).build();
    Assert.assertEquals(expected, hint);
}
Also used : PrefixFilter(org.apache.hadoop.hbase.filter.PrefixFilter) ByteString(com.google.protobuf.ByteString) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 29 with RowKeyWrapper

use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.

the class TestRowRangeAdapter method testLesserOrEqThan.

@Test
public void testLesserOrEqThan() {
    ByteString key = ByteString.copyFromUtf8("hi");
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setEndKeyClosed(key)).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.atMost(new RowKeyWrapper(key))).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 30 with RowKeyWrapper

use of com.google.cloud.bigtable.hbase.util.RowKeyWrapper in project java-bigtable-hbase by googleapis.

the class TestRowRangeAdapter method testGreaterOrEqThan.

@Test
public void testGreaterOrEqThan() {
    ByteString key = ByteString.copyFromUtf8("hi");
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(key)).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.atLeast(new RowKeyWrapper(key))).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)

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