use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class Filters method filterLimitCellsPerRow.
public static void filterLimitCellsPerRow(String projectId, String instanceId, String tableId) {
// A filter that matches the first 2 cells of each row
Filter filter = FILTERS.limit().cellsPerRow(2);
readFilter(projectId, instanceId, tableId, filter);
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class HelloWorld method readSpecificCells.
/**
* Demonstrates how to access specific cells by family and qualifier.
*/
public List<RowCell> readSpecificCells() {
// [START bigtable_hw_get_by_key]
try {
System.out.println("\nReading specific cells by family and qualifier");
Row row = dataClient.readRow(tableId, ROW_KEY_PREFIX + 0);
System.out.println("Row: " + row.getKey().toStringUtf8());
List<RowCell> cells = row.getCells(COLUMN_FAMILY, COLUMN_QUALIFIER_NAME);
for (RowCell cell : cells) {
System.out.printf("Family: %s Qualifier: %s Value: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
}
return cells;
} catch (NotFoundException e) {
System.err.println("Failed to read from a non-existent table: " + e.getMessage());
return null;
}
// [END bigtable_hw_get_by_key]
}
use of com.google.cloud.bigtable.data.v2.models.Row 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.Row 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());
}
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class Reads method readFilter.
public static void readFilter(String projectId, String instanceId, String tableId) {
Filters.Filter filter = FILTERS.value().regex("PQ2A.*");
// 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());
}
}
Aggregations