use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class BigtableDataClientTest method proxyReadRowsAsyncTest.
@Test
public void proxyReadRowsAsyncTest() {
Mockito.when(mockStub.readRowsCallable()).thenReturn(mockReadRowsCallable);
Query query = Query.create("fake-table");
@SuppressWarnings("unchecked") ResponseObserver<Row> mockObserver = Mockito.mock(ResponseObserver.class);
bigtableDataClient.readRowsAsync(query, mockObserver);
Mockito.verify(mockReadRowsCallable).call(query, mockObserver);
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class BigtableDataClientTest method proxyReadRowsSyncTest.
@Test
public void proxyReadRowsSyncTest() {
Mockito.when(mockStub.readRowsCallable()).thenReturn(mockReadRowsCallable);
Query query = Query.create("fake-table");
bigtableDataClient.readRows(query);
Mockito.verify(mockReadRowsCallable).call(query);
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class ReadRowsRetryTest method getResults.
private List<String> getResults(Query query) {
ServerStream<Row> actualRows = client.readRows(query);
List<String> actualValues = Lists.newArrayList();
for (Row row : actualRows) {
actualValues.add(row.getKey().toStringUtf8());
}
return actualValues;
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class HelloWorld method readTable.
/**
* Demonstrates how to read an entire table.
*/
public List<Row> readTable() {
// [START bigtable_hw_scan_all]
try {
System.out.println("\nReading the entire table");
Query query = Query.create(tableId);
ServerStream<Row> rowStream = dataClient.readRows(query);
List<Row> tableRows = new ArrayList<>();
for (Row r : rowStream) {
System.out.println("Row Key: " + r.getKey().toStringUtf8());
tableRows.add(r);
for (RowCell cell : r.getCells()) {
System.out.printf("Family: %s Qualifier: %s Value: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
}
}
return tableRows;
} catch (NotFoundException e) {
System.err.println("Failed to read a non-existent table: " + e.getMessage());
return null;
}
// [END bigtable_hw_scan_all]
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class Reads method readRowRanges.
public static void readRowRanges(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)) {
Query query = Query.create(tableId).range("phone#4c410523#20190501", "phone#4c410523#20190601").range("phone#5c10102#20190501", "phone#5c10102#20190601");
ServerStream<Row> rows = dataClient.readRows(query);
for (Row row : rows) {
printRow(row);
}
} catch (IOException e) {
System.out.println("Unable to initialize service client, as a network error occurred: \n" + e.toString());
}
}
Aggregations