Lee con claves

Organiza tus páginas con colecciones Guarda y categoriza el contenido según tus preferencias.

Lee con un conjunto no contiguo de claves de fila.

Explora más

Para obtener documentación en la que se incluye esta muestra de código, consulta lo siguiente:

Muestra de código

Go

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

log.Printf("Getting a single greeting by row key:")
row, err := tbl.ReadRow(ctx, rowKeys[0], bigtable.RowFilter(bigtable.ColumnFilter(columnName)))
if err != nil {
	log.Fatalf("Could not read row with key %s: %v", rowKeys[0], err)
}
log.Printf("\t%s = %s\n", rowKeys[0], string(row[columnFamilyName][0].Value))

Java

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

try {
  System.out.println("\nReading a single row by row key");
  Row row = dataClient.readRow(tableId, ROW_KEY_PREFIX + 0);
  System.out.println("Row: " + row.getKey().toStringUtf8());
  for (RowCell cell : row.getCells()) {
    System.out.printf(
        "Family: %s    Qualifier: %s    Value: %s%n",
        cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
  }
  return row;
} catch (NotFoundException e) {
  System.err.println("Failed to read from a non-existent table: " + e.getMessage());
  return null;
}
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;
}

¿Qué sigue?

Para buscar y filtrar muestras de código en otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.