Ler intervalos de linhas (HBase)

Lê linhas com vários intervalos.

Mais informações

Para ver a documentação detalhada que inclui este exemplo de código, consulte:

Exemplo de código

Java

Para saber como instalar e usar a biblioteca de cliente para o Bigtable, consulte Bibliotecas de cliente do Bigtable.

Para autenticar no Bigtable, configure o Application Default Credentials. Para mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.


/**
 * Example of reading a range of rows using a key range.
 */
public static void readRowRange() {
  // TODO(developer): Replace these variables before running the sample.
  String projectId = "my-project-id";
  String instanceId = "my-instance-id";
  String tableId = "mobile-time-series";
  readRowRange(projectId, instanceId, tableId);
}

public static void readRowRange(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));

    Scan rangeQuery =
        new Scan()
            .withStartRow(Bytes.toBytes("phone#4c410523#20190501"))
            .withStopRow(Bytes.toBytes("phone#4c410523#201906201"));

    ResultScanner rows = table.getScanner(rangeQuery);

    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());
  }
}

A seguir

Para pesquisar e filtrar amostras de código para outros produtos do Google Cloud, consulte o navegador de amostra do Google Cloud.