Leer filas (HBase)

Lee varias filas.

Investigar más

Para obtener documentación detallada que incluya este código de muestra, consulta lo siguiente:

Código de ejemplo

Java

Para saber cómo instalar y usar la biblioteca de cliente de Bigtable, consulta el artículo Bibliotecas de cliente de Bigtable.

Para autenticarte en Bigtable, configura las credenciales predeterminadas de la aplicación. Para obtener más información, consulta el artículo Configurar la autenticación en un entorno de desarrollo local.


/**
 * Example of reading multiple row keys.
 */
public static void readRows() {
  // TODO(developer): Replace these variables before running the sample.
  String projectId = "my-project-id";
  String instanceId = "my-instance-id";
  String tableId = "mobile-time-series";
  readRows(projectId, instanceId, tableId);
}

public static void readRows(String projectId, String instanceId, String tableId) {
  // Initialize client that will be used to send requests. This client only needs to be created
  // once, and can be reused for multiple requests.
  try (Connection connection = BigtableConfiguration.connect(projectId, instanceId)) {
    Table table = connection.getTable(TableName.valueOf(tableId));
    List<Get> queryRowList = new ArrayList<Get>();
    queryRowList.add(new Get(Bytes.toBytes("phone#4c410523#20190501")));
    queryRowList.add(new Get(Bytes.toBytes("phone#4c410523#20190502")));

    Result[] rows = table.get(queryRowList);

    for (Result row : rows) {
      printRow(row);
    }
  } catch (IOException e) {
    System.out.println(
        "Unable to initialize service client, as a network error occurred: \n" + e.toString());
  }
}

Siguientes pasos

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