Class PaginatedList<T>
java.lang.Object
com.amazonaws.services.dynamodbv2.datamodeling.PaginatedList<T>
- Type Parameters:
T
- The domain object type stored in this list.
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
- Direct Known Subclasses:
PaginatedParallelScanList
,PaginatedQueryList
,PaginatedScanList
Unmodifiable list supporting paginated result sets from Amazon DynamoDB.
Pages of results are fetched lazily from DynamoDB as they are needed. Some
methods, such as size()
and
toArray()
, require fetching the entire result set
eagerly. See the javadoc of individual methods for details on which are lazy.
-
Field Summary
FieldsModifier and TypeFieldDescriptionAll currently loaded results for this list.protected boolean
Tracks if all results have been loaded yet or notThe class annotated with DynamoDB tags declaring how to load/store objects into DynamoDBprotected final AmazonDynamoDB
The client for working with DynamoDBprotected final DynamoDBMapper
Reference to the DynamoDB mapper for marshalling DynamoDB attributes back into objectsLazily loaded next results waiting to be added into allResults -
Constructor Summary
ConstructorsConstructorDescriptionPaginatedList
(DynamoDBMapper mapper, Class<T> clazz, AmazonDynamoDB dynamo) Constructs a PaginatedList instance using the default PaginationLoadingStrategyPaginatedList
(DynamoDBMapper mapper, Class<T> clazz, AmazonDynamoDB dynamo, DynamoDBMapperConfig.PaginationLoadingStrategy paginationLoadingStrategy) Constructs a PaginatedList instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int arg0, Collection<? extends T> arg1) boolean
addAll
(Collection<? extends T> arg0) protected abstract boolean
Returns whether we have reached the end of the result set.void
clear()
boolean
Returns whether the collection contains the given element.boolean
containsAll
(Collection<?> arg0) Fetches the next page of results (which may be empty) and returns any items found.get
(int n) Returns the Nth element of the list.int
Returns the first index of the object given in the list.boolean
isEmpty()
Returns whether the collection is empty.iterator()
Returns an iterator over this list that lazily initializes results as necessary.int
lastIndexOf
(Object arg0) listIterator
(int arg0) void
Eagerly loads all results for this list.remove
(int arg0) boolean
boolean
removeAll
(Collection<?> arg0) boolean
retainAll
(Collection<?> arg0) int
size()
subList
(int arg0, int arg1) Returns a sub-list in the range specified, loading more results as necessary.Object[]
toArray()
<X> X[]
toArray
(X[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
mapper
Reference to the DynamoDB mapper for marshalling DynamoDB attributes back into objects -
clazz
The class annotated with DynamoDB tags declaring how to load/store objects into DynamoDB -
dynamo
The client for working with DynamoDB -
allResultsLoaded
protected boolean allResultsLoadedTracks if all results have been loaded yet or not -
allResults
All currently loaded results for this list. In ITERATION_ONLY mode, this list will at most keep one page of the loaded results, and all previous results will be cleared from the memory. -
nextResults
Lazily loaded next results waiting to be added into allResults
-
-
Constructor Details
-
PaginatedList
Constructs a PaginatedList instance using the default PaginationLoadingStrategy -
PaginatedList
public PaginatedList(DynamoDBMapper mapper, Class<T> clazz, AmazonDynamoDB dynamo, DynamoDBMapperConfig.PaginationLoadingStrategy paginationLoadingStrategy) Constructs a PaginatedList instance.- Parameters:
mapper
- The mapper for marshalling DynamoDB attributes into objects.clazz
- The class of the annotated model.dynamo
- The DynamoDB client for making low-level request calls.paginationLoadingStrategy
- The strategy used for loading paginated results. Caller has to explicitly set this parameter, since the DynamoDBMapperConfig set in the mapper is not accessible here. If null value is provided, LAZY_LOADING will be set by default.
-
-
Method Details
-
loadAllResults
public void loadAllResults()Eagerly loads all results for this list.Not supported in ITERATION_ONLY mode.
-
fetchNextPage
Fetches the next page of results (which may be empty) and returns any items found. -
atEndOfResults
protected abstract boolean atEndOfResults()Returns whether we have reached the end of the result set. -
iterator
Returns an iterator over this list that lazily initializes results as necessary.If it configured with ITERARTION_ONLY mode, then the iterator could be only retrieved once, and any previously loaded results will be cleared in the memory during the iteration.
-
isEmpty
public boolean isEmpty()Returns whether the collection is empty. At most one (non-empty) page of results is loaded to make the check.Not supported in ITERATION_ONLY mode.
-
get
Returns the Nth element of the list. Results are loaded until N elements are present, if necessary.Not supported in ITERATION_ONLY mode.
-
contains
Returns whether the collection contains the given element. Results are loaded and checked incrementally until a match is found or the end of the result set is reached.Not supported in ITERATION_ONLY mode.
-
subList
Returns a sub-list in the range specified, loading more results as necessary.Not supported in ITERATION_ONLY mode.
-
indexOf
Returns the first index of the object given in the list. Additional results are loaded incrementally as necessary.Not supported in ITERATION_ONLY mode.
-
size
public int size() -
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceList<T>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<T>
-
toArray
-
toArray
public <X> X[] toArray(X[] a) -
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear()
-