Hi,
On 17/02/15 11:42, "Julian Reschke" <[email protected]> wrote:
>On 2015-02-17 09:49, Marcel Reutegger wrote:
>>I also don't particularly like the List as return value. we used it
>> for other methods and it always turns out to be problematic to find
>> a reasonable number for the limit (aka batch size). the number depends
>> very much on the size of the returned documents.
>
>Well, there are two questions here: List vs Iterator, and what type to
>actually use.
If we want to go with Proposal #1, my preference would be a
ClosableIterator (extends Iterator, Closable).
>>we could also implement a combination of both. something like this:
>>
>> <T extends Document> void query(Collection<T> collection,
>> List<Constraint> constraints,
>> ResultCollector<T> collector);
>>
>> interface ResultCollector<T extends Document> {
>> public boolean collect(T document);
>> }
>>
>>
>> Advantages:
>>
>> - no need for limit and closeable. a client either collects
>> all results or interrupts by returning false in collect(). this
>> indicates to the DocumentStore that resources can be freed.
>
>But it lacks the declarative part of "limit" (it's useful to be able to
>tell the DB upfront how many results we want to see).
If needed we could add this to the signature as well...
Regards
Marcel