jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: The infamous getSize() == -1 (Was: [jira] [Created] (OAK-300) Query: QueryResult.getRows().getSize())
Date Wed, 12 Sep 2012 08:23:45 GMT

Hi,

On 11.9.12 11:08, Jukka Zitting wrote:

>
> Instead I'd propose the following design:
>
> * The getSize() method always returns the size, by buffering all
> results in memory if necessary.
> * A separate hasSize() method can be used to check if the size is
> quickly available (i.e. if getSize() will complete in O(1) time).
>

As an alternative: we could use a separate method getSize(int max) which

* if called with max == -1 returns the exact size if quickly available,
* returns -1 otherwise, and
* returns the exact size but not more then max when called with max >= 0.

This allows for estimates but leaves the caller in control.

Michael

Mime
View raw message