Search in sources :

Example 6 with Builder

use of com.google.bigtable.v2.MutateRowsRequest.Builder 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 7 with Builder

use of com.google.bigtable.v2.MutateRowsRequest.Builder 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 8 with Builder

use of com.google.bigtable.v2.MutateRowsRequest.Builder 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)

Example 9 with Builder

use of com.google.bigtable.v2.MutateRowsRequest.Builder 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 10 with Builder

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

the class DefaultRowAdapter method createRowFromProto.

/**
 * Helper to convert a proto Row to a model Row.
 *
 * <p>For internal use only.
 */
@InternalApi
public Row createRowFromProto(com.google.bigtable.v2.Row row) {
    RowBuilder<Row> builder = createRowBuilder();
    builder.startRow(row.getKey());
    for (Family family : row.getFamiliesList()) {
        for (Column column : family.getColumnsList()) {
            for (Cell cell : column.getCellsList()) {
                builder.startCell(family.getName(), column.getQualifier(), cell.getTimestampMicros(), cell.getLabelsList(), cell.getValue().size());
                builder.cellValue(cell.getValue());
                builder.finishCell();
            }
        }
    }
    return builder.finishRow();
}
Also used : Column(com.google.bigtable.v2.Column) Family(com.google.bigtable.v2.Family) Cell(com.google.bigtable.v2.Cell) InternalApi(com.google.api.core.InternalApi)

Aggregations

Test (org.junit.Test)16 RowSet (com.google.bigtable.v2.RowSet)14 ByteString (com.google.protobuf.ByteString)13 RowKeyWrapper (com.google.cloud.bigtable.hbase.util.RowKeyWrapper)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