The Java code snippet within the Amazon DynamoDB documentation for the DynamoDBMapper Class is a bit unfortunate here (though technologically correct), the AWS SDK for Java API documentation for Class DynamoDBMapper is (naturally) more precise in this regard, see method query():
public <T> PaginatedQueryList<T> query(Class<T> clazz, DynamoDBQueryExpression queryExpression)
So the returned type is actually a Class PaginatedQueryList:
Implementation of the List interface that represents the results from a query in AWS DynamoDB. Paginated results are loaded on demand when the user executes an operation that requires them. Some operations, such as size(), must fetch the entire list, but results are lazily fetched page by page when possible. [emphasize mine]
That is, you really do not need to explicitly load anything during normal usage, insofar it is implicitly taken care of by the lazy-loading implementation of PaginatedQueryList<T>
; however, if so desired for whatever reason, you can trigger it by operations requiring access to the entire collection, with the explicitly mentioned size() method being one of them apparently.
Read full article from java - How can I retrieve all items from the paginated result of a DynamoDBMapper query()? - Stack Overflow
No comments:
Post a Comment