use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class Filters method readFilter.
// [END bigtable_filters_composing_condition]
// [END_EXCLUDE]
private static void readFilter(String projectId, String instanceId, String tableId, Filter filter) {
// 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).filter(filter);
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());
}
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class Reads method readRows.
public static void readRows(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).rowKey("phone#4c410523#20190501").rowKey("phone#4c410523#20190502");
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());
}
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class Reads method readRowRange.
public static void readRowRange(String projectId, String instanceId, String tableId) {
String start = "phone#4c410523#20190501";
String end = "phone#4c410523#201906201";
// 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(start, end);
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());
}
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class ReadRowsBatchingDescriptorTest method requestBuilderTest.
@Test
public void requestBuilderTest() {
BatchingRequestBuilder<ByteString, Query> requestBuilder = underTest.newRequestBuilder(Query.create("table-Id"));
requestBuilder.add(ByteString.copyFromUtf8("row-key-1"));
requestBuilder.add(ByteString.copyFromUtf8("row-key-2"));
Query request = requestBuilder.build();
ReadRowsRequest readRowsRequest = request.toProto(RequestContext.create("project", "instance", "appProfile"));
assertThat(readRowsRequest.getTableName()).contains("table-Id");
assertThat(readRowsRequest.getRows().getRowKeysList()).isEqualTo(ImmutableList.of(ByteString.copyFromUtf8("row-key-1"), ByteString.copyFromUtf8("row-key-2")));
}
use of com.google.cloud.bigtable.data.v2.models.Query in project java-bigtable by googleapis.
the class NativeImageBigtableSample method readData.
static void readData(BigtableDataClient client, String tableId) {
Query query = Query.create(tableId).prefix("");
ServerStream<Row> rows = client.readRows(query);
System.out.println("Reading phone data in table:");
for (Row row : rows) {
System.out.println("Key: " + row.getKey().toStringUtf8());
for (RowCell cell : row.getCells()) {
System.out.printf("\t%s: %s @%s\n", cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
}
System.out.println();
}
}
Aggregations