Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get lastEvaluatedKey ? #1153

Open
ipsi-apant opened this issue May 15, 2024 · 0 comments
Open

How to get lastEvaluatedKey ? #1153

ipsi-apant opened this issue May 15, 2024 · 0 comments

Comments

@ipsi-apant
Copy link

Type: Question

Component:

DynamoDB

Describe
I am using io.awspring.cloud.dynamodb.DynamoDbTemplate for querying records by global secondary index.
The result of this API is PageIterable<T> which works if I need to return these records. However, the table contain millions of records, therefore planning query in chunks with filter criteria and use lastEvaluatedKey to fetch next set of records.
I am unable to find any workable example using DynamoDbTemplate.

Can you please advise?

Tech stack

  • Springboot 3.2.5
  • awspring 3.1.1
  • AWS SDK 2.25.47
  • Java 21
  • WebFlux functional routes

Sample

private Flux<Person> getAllByIndex(String globalSecondaryIndex, final Consumer<Builder> expressionConsumer,)  {

    Expression.Builder expressionBuilder = Expression.builder();
    expressionConsumer.accept(expressionBuilder);

    return Flux.fromIterable(dynamoDbTemplate
                                 .query(
                                     QueryEnhancedRequest.builder()
                                                         .queryConditional(
                                                             QueryConditional
                                                                 .keyEqualTo(keyBuilder -> keyBuilder
                                                                     .partitionValue(globalSecondaryIndex)
                                                                 )
                                                         )
                                                         .filterExpression(expressionBuilder.build())
                                                         .build(),
                                     Person.class,
                                     PERSON_INDEX
                                 )
                                 .items()
    );
}
@ipsi-apant ipsi-apant changed the title How to get latEvaluatedKey ? How to get lastEvaluatedKey ? May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant