jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cki...@apache.org
Subject svn commit: r566778 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Date Thu, 16 Aug 2007 17:04:59 GMT
Author: ckiehl
Date: Thu Aug 16 10:04:58 2007
New Revision: 566778

URL: http://svn.apache.org/viewvc?view=rev&rev=566778
Log:
JCR-989: Fixed getSize() to take a possible limit into account

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java?view=diff&rev=566778&r1=566777&r2=566778
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyQueryResultImpl.java
Thu Aug 16 10:04:58 2007
@@ -396,7 +396,12 @@
          * nodes or the session does not have access to a node.
          */
         public long getSize() {
-            return numResults - invalid;
+            int totalSize = numResults - invalid;
+            if (limit > 0 && totalSize > limit) {
+                return limit;
+            } else {
+                return totalSize;
+            }
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java?view=diff&rev=566778&r1=566777&r2=566778
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitAndOffsetTest.java
Thu Aug 16 10:04:58 2007
@@ -95,4 +95,17 @@
         assertTrue(nodes.nextNode() == node3);
     }
 
+    public void testOffsetAndLimitWithGetSize() throws Exception {
+        query.setOffset(1);
+        QueryResult result = query.execute();
+        NodeIterator nodes = result.getNodes();
+        assertEquals(2, nodes.getSize());
+
+        query.setOffset(1);
+        query.setLimit(1);
+        result = query.execute();
+        nodes = result.getNodes();
+        assertEquals(1, nodes.getSize());
+    }
+
 }



Mime
View raw message