derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
402 stars 141 forks source link

Query Size Limits Not Working #89

Open pluttrell opened 7 years ago

pluttrell commented 7 years ago

Based on this answer, it sounds like limiting the results returned to a specific number should be working. However the following example does not appear to work as I'm getting back many more results.

List<Event> eventList = eventRepository.findByArenaId(arenaId, new PageRequest(0,2));

For this example Repository:

public interface EventRepository extends CrudRepository<Event, EventId> {
    List<Event> findByArenaId(String arenaId, Pageable pageable);
}

Is this a bug or is there something else that I need to do to get limits working?

derjust commented 6 years ago

I'm a bit unsure about what you try achieve here: If the third element is read via the iterator or via List.get(int), the element is transparently loaded with a new request.

I guess you try to load at max 2 items - like a SQL TOP 2?

derjust commented 6 years ago

To be a bit more specific: AWS SDK will always load the whole list (in a lazy fashion) if asked about all elements (.size() etc.). Iterating over the list will fetch as many elements as requested via a provided Pageable as soon as #117 is merged :-)