Todos os produtos
Search
Central de documentação

Tablestore:Consultar dados em um índice Lastpoint

Última atualização: Jun 30, 2026

Este tópico descreve como consultar dados em um índice Lastpoint com o Tablestore SDK for Java.

Observações de uso

O recurso de índice Lastpoint exige o Tablestore SDK for Java V5.17.1 ou posterior. Atualize o SDK se você executar uma versão anterior.

Nota

Para obter informações sobre como baixar uma nova versão do Tablestore SDK for Java, consulte Histórico de versões do Tablestore SDK for Java.

Pré-requisitos

Antes de começar, verifique se você tem:

Código de exemplo

O exemplo a seguir chama a operação GetRange para ler todas as linhas de um índice Lastpoint. A varredura usa INF_MIN e INF_MAX como valores inicial e final da chave primária em todas as colunas de chave primária para cobrir todo o intervalo de chaves. Se a resposta incluir nextStartPrimaryKey, o loop continuará a leitura dessa posição até recuperar todas as linhas.

private static void getRange(SyncClient client) {
    // Specify the name of the Lastpoint index.
    RangeRowQueryCriteria rangeRowQueryCriteria = new RangeRowQueryCriteria("<LASTPOINT_INDEX_NAME>");
    
    // Set the start primary key to INF_MIN and the end primary key to INF_MAX for each primary key column.
    PrimaryKey startPrimaryKey = PrimaryKeyBuilder.createPrimaryKeyBuilder()
            .addPrimaryKeyColumn("_#h", PrimaryKeyValue.INF_MIN)
            .addPrimaryKeyColumn("_m_name", PrimaryKeyValue.INF_MIN)
            .addPrimaryKeyColumn("_data_source", PrimaryKeyValue.INF_MIN)
            .addPrimaryKeyColumn("_tags", PrimaryKeyValue.INF_MIN)
            .build();
    rangeRowQueryCriteria.setInclusiveStartPrimaryKey(startPrimaryKey);
    PrimaryKey endPrimaryKey = PrimaryKeyBuilder.createPrimaryKeyBuilder()
            .addPrimaryKeyColumn("_#h", PrimaryKeyValue.INF_MAX)
            .addPrimaryKeyColumn("_m_name", PrimaryKeyValue.INF_MAX)
            .addPrimaryKeyColumn("_data_source", PrimaryKeyValue.INF_MAX)
            .addPrimaryKeyColumn("_tags", PrimaryKeyValue.INF_MAX)
            .build();
    rangeRowQueryCriteria.setExclusiveEndPrimaryKey(endPrimaryKey);
    // Set the maximum number of versions to 1. Time series tables do not support multiple versions.
    rangeRowQueryCriteria.setMaxVersions(1);
    
    System.out.println("Scan results:");
    while (true) {
        GetRangeResponse getRangeResponse = client.getRange(new GetRangeRequest(rangeRowQueryCriteria));
        for (Row row : getRangeResponse.getRows()) {
            System.out.println(row);
        }
        // If nextStartPrimaryKey is not null, continue reading.
        if (getRangeResponse.getNextStartPrimaryKey() != null) {
            rangeRowQueryCriteria.setInclusiveStartPrimaryKey(getRangeResponse.getNextStartPrimaryKey());
        } else {
            break;
        }
    }
}

Próximos passos

  • Para saber como ler dados com o Tablestore SDK for Java, consulte Ler dados.

  • Crie um índice de pesquisa para o índice Lastpoint caso precise consultar dados com métodos avançados, como consulta booleana, pesquisa de texto completo, consulta por prefixo e consulta difusa. Para mais detalhes, consulte Recuperar um índice Lastpoint.