jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gadbury <gadb...@googlemail.com>
Subject Re: NodeIterator.getSize() returns -1 for query with order by clause
Date Wed, 14 Apr 2010 16:58:22 GMT

Thanks for the response, Alex.

The order by trick does not always work.  Not being able to determine if a
certain query returns -1 or a valid number when sorted is bad news.  I had
assumed that I would not get a -1 if I used order by.

Back to the drawing board then, I guess.  I thought I had nailed our paging
solution.  The example I have read regarding Google Mail's count of your
inbox seems invalid as mine knows precisely how many items are in my inbox
on the first load.

On 14 April 2010 14:18, Alexander Klimetschek [via Jackrabbit] <
> wrote:

> On Wed, Apr 14, 2010 at 12:40, Gadbury <[hidden email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1839776&i=0>>
> wrote:
> > But no real answer as to why with a where clause the getSize() returns
> -1.
> The thing is that the spec allows the implementation to return -1.
> This makes it free to optimize certain queries so that they are
> fetched on demand (iteration over the result) without having to know
> the entire result and thus it's count in advance. Jackrabbit's search
> implementation was improved for 2.0 so that the -1 is seen more often
> now.
> Which queries trigger a -1 or the actual size can change any time, so
> client code should not rely on it (or be prepared to change). Counting
> yourself by iterating over the result set is an option, albeit it can
> be slower. A trick is to sort the result set (order by in xpath or
> sql), which will be slower than not sorting, but can be faster than
> manual counting (for large result sets).
> Regards,
> Alex
> --
> Alexander Klimetschek
> [hidden email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1839776&i=1>
> ------------------------------
>  View message @
> http://n4.nabble.com/NodeIterator-getSize-returns-1-for-query-with-order-by-clause-tp1839436p1839776.html
> To unsubscribe from Re: NodeIterator.getSize() returns -1 for query with
> order by clause, click here< (link removed) =>.

View this message in context: http://n4.nabble.com/NodeIterator-getSize-returns-1-for-query-with-order-by-clause-tp1839436p1840146.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message