Search in sources :

Example 11 with RowKeyWrapper

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

the class TestRowRangeAdapter method testMultipleDisjoint.

@Test
public void testMultipleDisjoint() {
    RowSet in = RowSet.newBuilder().addRowKeys(ByteString.copyFromUtf8("point1")).addRowKeys(ByteString.copyFromUtf8("point2")).addRowRanges(RowRange.newBuilder().setEndKeyClosed(ByteString.copyFromUtf8("b"))).addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("c")).setEndKeyClosed(ByteString.copyFromUtf8("d"))).addRowRanges(RowRange.newBuilder().setStartKeyOpen(ByteString.copyFromUtf8("y"))).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.singleton(new RowKeyWrapper(ByteString.copyFromUtf8("point1")))).add(Range.singleton(new RowKeyWrapper(ByteString.copyFromUtf8("point2")))).add(Range.atMost(new RowKeyWrapper(ByteString.copyFromUtf8("b")))).add(Range.closed(new RowKeyWrapper(ByteString.copyFromUtf8("c")), new RowKeyWrapper(ByteString.copyFromUtf8("d")))).add(Range.greaterThan(new RowKeyWrapper(ByteString.copyFromUtf8("y")))).build();
    assertEquals(expected, out);
    adapter.rangeSetToByteStringRange(out, query);
    assertEquals(in, query.toProto(requestContext).getRows());
}
Also used : RowSet(com.google.bigtable.v2.RowSet) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 12 with RowKeyWrapper

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

the class TestRowRangeAdapter method testSingleClosedOpenRangeRowSet.

@Test
public void testSingleClosedOpenRangeRowSet() {
    ByteString key1 = ByteString.copyFromUtf8("myKey");
    ByteString key2 = ByteString.copyFromUtf8("otherKey");
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(key1).setEndKeyOpen(key2)).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.closedOpen(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 13 with RowKeyWrapper

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

the class TestRowRangeAdapter method testLesserThan.

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

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

the class TestRowRangeAdapter method testSingleClosedRangeRowSet.

@Test
public void testSingleClosedRangeRowSet() {
    ByteString key1 = ByteString.copyFromUtf8("myKey");
    ByteString key2 = ByteString.copyFromUtf8("otherKey");
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(key1).setEndKeyClosed(key2)).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.closed(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 15 with RowKeyWrapper

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

the class TestRowRangeAdapter method testAllRowSet.

@Test
public void testAllRowSet() {
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder()).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.<RowKeyWrapper>all()).build();
    assertEquals(expected, out);
    adapter.rangeSetToByteStringRange(out, query);
    assertEquals(in, query.toProto(requestContext).getRows());
}
Also used : 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