jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1181086 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/
Date Mon, 10 Oct 2011 17:31:34 GMT
Author: alexparvulescu
Date: Mon Oct 10 17:31:33 2011
New Revision: 1181086

URL: http://svn.apache.org/viewvc?rev=1181086&view=rev
Log:
JCR-3091 Lucene Scorer implementations should handle the 'advance' to NO_MORE_DOCS optimisation
better

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
Mon Oct 10 17:31:33 2011
@@ -419,6 +419,14 @@ class ChildAxisQuery extends Query imple
             if (nextDoc == NO_MORE_DOCS) {
                 return nextDoc;
             }
+            
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                hits.skipTo(target);
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
 
             calculateChildren();
             nextDoc = hits.skipTo(target);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
Mon Oct 10 17:31:33 2011
@@ -289,6 +289,13 @@ class DerefQuery extends Query {
                 return nextDoc;
             }
 
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
+
             calculateChildren();
             nextDoc = hits.nextSetBit(target);
             if (nextDoc < 0) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
Mon Oct 10 17:31:33 2011
@@ -109,6 +109,13 @@ class MatchAllScorer extends Scorer {
             return nextDoc;
         }
 
+        // optimize in the case of an advance to finish.
+        // see https://issues.apache.org/jira/browse/JCR-3091
+        if (target == NO_MORE_DOCS) {
+            nextDoc = NO_MORE_DOCS;
+            return nextDoc;
+        }
+
         nextDoc = target - 1;
         return nextDoc();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
Mon Oct 10 17:31:33 2011
@@ -75,7 +75,6 @@ class MultiScorer extends Scorer {
                 currentDoc = NO_MORE_DOCS;
             }
         }
-
         return currentDoc;
     }
 
@@ -94,6 +93,18 @@ class MultiScorer extends Scorer {
         if (currentDoc == NO_MORE_DOCS) {
             return currentDoc;
         }
+        // optimize in the case of an advance to finish.
+        // see https://issues.apache.org/jira/browse/JCR-3091
+        if (target == NO_MORE_DOCS) {
+            // exhaust all the internal scorers
+            for (Scorer s : scorers) {
+                if (s.docID() != target) {
+                    s.advance(target);
+                }
+            }
+            currentDoc = NO_MORE_DOCS;
+            return currentDoc;
+        }
 
         currentScorer = scorerIndex(target);
         if (scorers[currentScorer].advance(target - starts[currentScorer]) != NO_MORE_DOCS)
{

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
Mon Oct 10 17:31:33 2011
@@ -226,6 +226,14 @@ class NotQuery extends Query {
                 return docNo;
             }
 
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                contextScorer.advance(target);
+                docNo = NO_MORE_DOCS;
+                return docNo;
+            }
+
             if (contextNo != -1 && contextNo < target) {
                 int docId = contextScorer.advance(target);
                 contextNo = docId == NO_MORE_DOCS ? -1 : docId;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
Mon Oct 10 17:31:33 2011
@@ -302,7 +302,12 @@ class ParentAxisQuery extends Query {
             if (nextDoc == NO_MORE_DOCS) {
                 return nextDoc;
             }
-
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
             calculateParent();
             nextDoc = hits.nextSetBit(target);
             if (nextDoc < 0) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
Mon Oct 10 17:31:33 2011
@@ -287,6 +287,12 @@ public class PredicateDerefQuery extends
             if (nextDoc == NO_MORE_DOCS) {
                 return nextDoc;
             }
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
 
             calculateChildren();
             nextDoc = hits.nextSetBit(target);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
Mon Oct 10 17:31:33 2011
@@ -239,6 +239,12 @@ public class QueryHitsQuery extends Quer
             if (currentDoc == NO_MORE_DOCS) {
                 return currentDoc;
             }
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                currentDoc = NO_MORE_DOCS;
+                return currentDoc;
+            }
 
             do {
                 if (nextDoc() == NO_MORE_DOCS) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
Mon Oct 10 17:31:33 2011
@@ -387,6 +387,12 @@ public class RangeQuery extends Query im
             if (nextDoc == NO_MORE_DOCS) {
                 return nextDoc;
             }
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
 
             calculateHits();
             nextDoc = hits.nextSetBit(target);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java?rev=1181086&r1=1181085&r2=1181086&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
Mon Oct 10 17:31:33 2011
@@ -351,6 +351,12 @@ public class WildcardQuery extends Query
             if (nextDoc == NO_MORE_DOCS) {
                 return nextDoc;
             }
+            // optimize in the case of an advance to finish.
+            // see https://issues.apache.org/jira/browse/JCR-3091
+            if (target == NO_MORE_DOCS) {
+                nextDoc = NO_MORE_DOCS;
+                return nextDoc;
+            }
 
             calculateHits();
             nextDoc = hits.nextSetBit(target);



Mime
View raw message