jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mueller <muel...@adobe.com>
Subject Re: The infamous getSize() == -1 (Was: [jira] [Created] (OAK-300) Query: QueryResult.getRows().getSize())
Date Fri, 14 Sep 2012 05:41:51 GMT

>The idea with the timeout sounds good, but what should we recommend an
>application to do if getSize() takes too long and returns -1?
>Imagine while paging search results, the first page query is fast enough
>(getSize() returns something), but the second is too long and now returns
>-1: should the application give up and "loose" the page navigation or
>should it count itself, now taking ages again....

If getSize() returns -1 then you know for sure there are more than 20
results, so you know you have to display 'next page'. If it returns 0 you
know there are no rows. If it returns a value between 1 and 20 you know
that there are this many rows. Does this answer your question?

>In that case the oak getSize(max) is probably a better fit.

If you call getSize(Integer.MAX_VALUE), then no, it's worse, because that
call might take hours. The only thing where it helps is if you have a
different page size than 20.

Please note if you use offset and limit, getSize() will return the size of
the result minus the offset (it will give you the number of rows you can
read from the result).


View raw message