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

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

How to get lastEvaluatedKey ? #1153

ipsi-apant opened this issue May 15, 2024 · 2 comments
Labels
status: waiting-for-feedback Waiting for feedback from issuer

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
@MatejNedic
Copy link
Member

Hey @ipsi-apant , Instead of using .items() you have to use for example .iterator().next().lastEvaluatedKey() on that level you have .items() as well

@MatejNedic MatejNedic added the status: waiting-for-feedback Waiting for feedback from issuer label Jul 30, 2024
@maciejwalkowiak
Copy link
Contributor

Closing due to lack of feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback Waiting for feedback from issuer
Projects
None yet
Development

No branches or pull requests

3 participants