Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 86652 invoked from network); 14 Apr 2010 16:58:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Apr 2010 16:58:51 -0000 Received: (qmail 75710 invoked by uid 500); 14 Apr 2010 16:58:51 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 75643 invoked by uid 500); 14 Apr 2010 16:58:51 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 75630 invoked by uid 99); 14 Apr 2010 16:58:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 16:58:51 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_HELO_PASS,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: 216.139.236.158 is neither permitted nor denied by domain of gadbury@googlemail.com) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 16:58:44 +0000 Received: from joe.nabble.com ([192.168.236.151]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1O25uw-00040X-SQ for users@jackrabbit.apache.org; Wed, 14 Apr 2010 09:58:22 -0700 Date: Wed, 14 Apr 2010 08:58:22 -0800 (PST) From: Gadbury To: users@jackrabbit.apache.org Message-ID: In-Reply-To: References: <1271232828988-1839436.post@n4.nabble.com> <1271235488423-1839484.post@n4.nabble.com> <1271241648976-1839593.post@n4.nabble.com> Subject: Re: NodeIterator.getSize() returns -1 for query with order by clause MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_94406_29764789.1271264302877" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_94406_29764789.1271264302877 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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] < ml-node+1839776-23308717-35600@n4.nabble.com > wrote: > On Wed, Apr 14, 2010 at 12:40, Gadbury <[hidden email]> > 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] > > > ------------------------------ > 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. ------=_Part_94406_29764789.1271264302877--