use of com.google.cloud.bigtable.data.v2.models.RowCell in project java-docs-samples by GoogleCloudPlatform.
the class CassandraMigrationCodelab method get.
public void get() {
try {
String rowKey = "phone#4c410523#20190501";
Row row = dataClient.readRow(tableId, rowKey);
for (RowCell cell : row.getCells()) {
System.out.printf("Family: %s Qualifier: %s Value: %s Timestamp: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
}
} catch (Exception e) {
System.out.println("Error during lookup: \n" + e.toString());
}
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project java-docs-samples by GoogleCloudPlatform.
the class CassandraMigrationCodelab method scan.
public void scan() {
try {
Query query = Query.create(tableId).range("tablet#a0b81f74#201905", "tablet#a0b81f74#201906");
ServerStream<Row> rowStream = dataClient.readRows(query);
for (Row row : rowStream) {
System.out.println("Row Key: " + row.getKey().toStringUtf8());
for (RowCell cell : row.getCells()) {
System.out.printf("Family: %s Qualifier: %s Value: %s Timestamp: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
}
}
} catch (Exception e) {
System.out.println("Error during scan: \n" + e.toString());
}
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project testcontainers-java by testcontainers.
the class BigtableEmulatorContainerTest method testSimple.
// }
@Test
public // testWithEmulatorContainer {
void testSimple() throws IOException, InterruptedException, ExecutionException {
ManagedChannel channel = ManagedChannelBuilder.forTarget(emulator.getEmulatorEndpoint()).usePlaintext().build();
TransportChannelProvider channelProvider = FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel));
NoCredentialsProvider credentialsProvider = NoCredentialsProvider.create();
try {
createTable(channelProvider, credentialsProvider, "test-table");
BigtableDataClient client = BigtableDataClient.create(BigtableDataSettings.newBuilderForEmulator(emulator.getHost(), emulator.getEmulatorPort()).setProjectId(PROJECT_ID).setInstanceId(INSTANCE_ID).build());
client.mutateRow(RowMutation.create("test-table", "1").setCell("name", "firstName", "Ray"));
Row row = client.readRow("test-table", "1");
List<RowCell> cells = row.getCells("name", "firstName");
assertThat(cells).isNotNull().hasSize(1);
assertThat(cells.get(0).getValue().toStringUtf8()).isEqualTo("Ray");
} finally {
channel.shutdown();
}
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project java-bigtable-hbase by googleapis.
the class TestRowResultAdapter method testWithSingleCellRow.
@Test
public void testWithSingleCellRow() {
RowAdapter.RowBuilder<Result> rowBuilder = underTest.createRowBuilder();
rowBuilder.startRow(ROW_KEY);
rowBuilder.startCell(COL_FAMILY, QUAL_ONE, 10000L, Collections.<String>emptyList(), VALUE.size());
rowBuilder.cellValue(VALUE);
rowBuilder.finishCell();
rowBuilder.startCell(COL_FAMILY, QUAL_TWO, 20000L, LABELS, -1);
rowBuilder.cellValue(VALUE);
rowBuilder.finishCell();
Result expected = Result.create(ImmutableList.<Cell>of(new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_ONE.toByteArray(), 10L, VALUE.toByteArray()), new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_TWO.toByteArray(), 20L, VALUE.toByteArray(), LABELS)));
assertResult(expected, rowBuilder.finishRow());
assertEquals(ROW_KEY, underTest.getKey(expected));
}
use of com.google.cloud.bigtable.data.v2.models.RowCell in project java-bigtable-hbase by googleapis.
the class TestRowResultAdapter method testOnlyValueIsDifferent.
@Test
public void testOnlyValueIsDifferent() {
ByteString valuePart1 = ByteString.copyFromUtf8("part-1");
RowAdapter.RowBuilder<Result> rowBuilder = underTest.createRowBuilder();
rowBuilder.startRow(ROW_KEY);
rowBuilder.startCell(COL_FAMILY, QUAL_ONE, 30000L, LABELS, VALUE.size());
rowBuilder.cellValue(VALUE);
rowBuilder.finishCell();
// started cell with same qualifier but different value
rowBuilder.startCell(COL_FAMILY, QUAL_ONE, 30000L, LABELS, valuePart1.size());
rowBuilder.cellValue(valuePart1);
rowBuilder.finishCell();
Result actual = rowBuilder.finishRow();
assertEquals(2, actual.size());
Result expected = Result.create(ImmutableList.<Cell>of(new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_ONE.toByteArray(), 30L, VALUE.toByteArray(), LABELS), new RowCell(ROW_KEY.toByteArray(), COL_FAMILY.getBytes(), QUAL_ONE.toByteArray(), 30L, valuePart1.toByteArray(), LABELS)));
assertResult(expected, actual);
}
Aggregations