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());
}
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());
}
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());
}
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());
}
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();
}
Aggregations