use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class Reads method readRow.
public static void readRow(String projectId, String instanceId, String tableId) {
// the "close" method on the client to safely clean up any remaining background resources.
try (BigtableDataClient dataClient = BigtableDataClient.create(projectId, instanceId)) {
String rowkey = "phone#4c410523#20190501";
Row row = dataClient.readRow(tableId, rowkey);
printRow(row);
} catch (IOException e) {
System.out.println("Unable to initialize service client, as a network error occurred: \n" + e.toString());
}
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class Reads method printRow.
// [END bigtable_reads_filter]
// [END_EXCLUDE]
private static void printRow(Row row) {
System.out.printf("Reading data for %s%n", row.getKey().toStringUtf8());
String colFamily = "";
for (RowCell cell : row.getCells()) {
if (!cell.getFamily().equals(colFamily)) {
colFamily = cell.getFamily();
System.out.printf("Column Family %s%n", colFamily);
}
System.out.printf("\t%s: %s @%s%n", cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
}
System.out.println();
}
use of com.google.cloud.bigtable.data.v2.models.Row 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.Row 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.Row in project java-bigtable by googleapis.
the class BigtableDataClientTests method existsAsyncTest.
@Test
public void existsAsyncTest() throws Exception {
Mockito.when(mockStub.readRowCallable()).thenReturn(mockReadRowCallable);
Query expectedQuery = Query.create("fake-table").rowKey("fake-row-key").filter(FILTERS.chain().filter(FILTERS.limit().cellsPerRow(1)).filter(FILTERS.value().strip()));
Row row = Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
Mockito.when(mockReadRowCallable.futureCall(expectedQuery)).thenReturn(ApiFutures.immediateFuture(row)).thenReturn(ApiFutures.<Row>immediateFuture(null));
ApiFuture<Boolean> result = bigtableDataClient.existsAsync("fake-table", ByteString.copyFromUtf8("fake-row-key"));
assertThat(result.get()).isTrue();
ApiFuture<Boolean> anotherResult = bigtableDataClient.existsAsync("fake-table", "fake-row-key");
assertThat(anotherResult.get()).isFalse();
Mockito.verify(mockReadRowCallable, Mockito.times(2)).futureCall(expectedQuery);
}
Aggregations