Search in sources :

Example 16 with Builder

use of com.google.bigtable.v2.ReadRowsRequest.Builder in project java-bigtable-hbase by googleapis.

the class TestRowRangeAdapter method testSingleKeyRowSet.

@Test
public void testSingleKeyRowSet() {
    ByteString key = ByteString.copyFromUtf8("myKey");
    RowSet in = RowSet.newBuilder().addRowKeys(key).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.closed(new RowKeyWrapper(key), 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 17 with Builder

use of com.google.bigtable.v2.ReadRowsRequest.Builder in project java-bigtable-hbase by googleapis.

the class TestRowRangeAdapter method testSingleOpenRangeRowSet.

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

use of com.google.bigtable.v2.ReadRowsRequest.Builder in project java-bigtable-hbase by googleapis.

the class TestRowRangeAdapter method testAllRowSet2.

@Test
public void testAllRowSet2() {
    RowSet in = RowSet.newBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.EMPTY).setEndKeyOpen(ByteString.EMPTY)).build();
    RangeSet<RowKeyWrapper> out = adapter.rowSetToRangeSet(in);
    RangeSet<RowKeyWrapper> expected = ImmutableRangeSet.<RowKeyWrapper>builder().add(Range.<RowKeyWrapper>all()).build();
    assertEquals(expected, out);
// NOTE: this isn't symmetrical, ['','') is converted to its canonical form of unset bounds
}
Also used : RowSet(com.google.bigtable.v2.RowSet) RowKeyWrapper(com.google.cloud.bigtable.hbase.util.RowKeyWrapper) Test(org.junit.Test)

Example 19 with Builder

use of com.google.bigtable.v2.ReadRowsRequest.Builder in project java-bigtable by googleapis.

the class QueryTest method rowRangeTest.

@Test
public void rowRangeTest() {
    Query query = Query.create(TABLE_ID).range("simple-begin", "simple-end").range(ByteString.copyFromUtf8("byte-begin"), ByteString.copyFromUtf8("byte-end")).range(ByteStringRange.create("range-begin", "range-end"));
    Builder expectedProto = expectedProtoBuilder();
    expectedProto.getRowsBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("simple-begin")).setEndKeyOpen(ByteString.copyFromUtf8("simple-end"))).addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("byte-begin")).setEndKeyOpen(ByteString.copyFromUtf8("byte-end"))).addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("range-begin")).setEndKeyOpen(ByteString.copyFromUtf8("range-end")));
    ReadRowsRequest actualProto = query.toProto(requestContext);
    assertThat(actualProto).isEqualTo(expectedProto.build());
}
Also used : Builder(com.google.bigtable.v2.ReadRowsRequest.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Example 20 with Builder

use of com.google.bigtable.v2.ReadRowsRequest.Builder in project java-bigtable by googleapis.

the class QueryTest method filterTest.

@Test
public void filterTest() {
    Query query = Query.create(TABLE_ID).filter(FILTERS.key().regex(".*"));
    Builder expectedProto = expectedProtoBuilder().setFilter(RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(".*")));
    ReadRowsRequest actualProto = query.toProto(requestContext);
    assertThat(actualProto).isEqualTo(expectedProto.build());
}
Also used : Builder(com.google.bigtable.v2.ReadRowsRequest.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 RowSet (com.google.bigtable.v2.RowSet)14 RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)12 ByteString (com.google.protobuf.ByteString)12 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)6 Builder (com.google.bigtable.v2.ReadRowsRequest.Builder)4 Column (com.google.bigtable.v2.Column)3 Family (com.google.bigtable.v2.Family)3 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)2 Builder (com.google.bigtable.v2.MutateRowsRequest.Builder)2 DeleteFromRow (com.google.bigtable.v2.Mutation.DeleteFromRow)2 Row (com.google.bigtable.v2.Row)2 RowFilter (com.google.bigtable.v2.RowFilter)2 Builder (com.google.bigtable.v2.RowFilter.Chain.Builder)2 MutateRowsException (com.google.cloud.bigtable.data.v2.models.MutateRowsException)2 FailedMutation (com.google.cloud.bigtable.data.v2.models.MutateRowsException.FailedMutation)2 ExecutionException (java.util.concurrent.ExecutionException)2 ByteArrayByteIterator (site.ycsb.ByteArrayByteIterator)2 InternalApi (com.google.api.core.InternalApi)1 InstantiatingGrpcChannelProvider (com.google.api.gax.grpc.InstantiatingGrpcChannelProvider)1