Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java (revision )
@@ -74,59 +74,53 @@
super(Similarity.getDefault());
this.reader = reader;
this.field = field;
- matchExpl
+ matchExpl // fixme lucene (explain)
= new Explanation(Similarity.getDefault().idf(reader.maxDoc(),
reader.maxDoc()),
"matchAll");
calculateDocFilter(cache);
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void score(Collector collector) throws IOException {
collector.setScorer(this);
- while (next()) {
- collector.collect(doc());
+ while (nextDoc() != NO_MORE_DOCS) {
+ collector.collect(docID());
}
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
nextDoc = docFilter.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- nextDoc = target - 1;
- return next();
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
- }
+ }
- /**
- * {@inheritDoc}
- */
- public Explanation explain(int doc) {
- return matchExpl;
+ nextDoc = target - 1;
+ return nextDoc();
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java (revision )
@@ -16,10 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Set;
-
import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.jackrabbit.spi.Name;
import org.apache.lucene.index.IndexReader;
@@ -32,6 +28,10 @@
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Set;
+
/**
* Implements a Lucene Query which returns the nodes which have a
* reference property which matches the nodes of the subquery.
@@ -258,49 +258,44 @@
this.subQueryHits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
-
/**
* Perform the sub query
* For each reference property UUID
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java (revision )
@@ -316,44 +316,42 @@
hits = result;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * Returns an empty Explanation object.
- * @return an empty Explanation object.
- */
- public Explanation explain(int doc) {
- return new Explanation();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java (revision )
@@ -214,48 +214,44 @@
docs = sortedDocs.iterator();
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
if (docs.hasNext()) {
currentDoc = docs.next();
- return true;
}
- return false;
+ else {
+ currentDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- */
- public int doc() {
return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
+ public int docID() {
+ return currentDoc == null? -1 : currentDoc;
+ }
+
+ @Override
public float score() throws IOException {
return scores.get(currentDoc);
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
do {
- if (!next()) {
- return false;
+ if (nextDoc() == NO_MORE_DOCS) {
+ return NO_MORE_DOCS;
}
- } while (target > doc());
- return true;
+ } while (target > docID());
+ return docID();
}
- /**
- * {@inheritDoc}
- */
- public Explanation explain(int doc) throws IOException {
- return new Explanation();
- }
- }
+ }
+}
-}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java (revision )
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.core.query.lucene;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
@@ -180,14 +179,16 @@
this.reader = reader;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (docNo == NO_MORE_DOCS) {
+ return docNo;
+ }
+
if (docNo == -1) {
// get first doc of context scorer
int docId = contextScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+ if (docId != NO_MORE_DOCS) {
contextNo = docId;
}
}
@@ -200,50 +201,45 @@
while (contextNo != -1 && contextNo == docNo) {
docNo++;
int docId = contextScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
- contextNo = docId;
- } else {
+ if (docId == NO_MORE_DOCS) {
contextNo = -1;
+ } else {
+ contextNo = docId;
}
}
- return docNo < reader.maxDoc();
+ if (docNo >= reader.maxDoc()) {
+ docNo = NO_MORE_DOCS;
- }
+ }
+ return docNo;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return docNo;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (docNo == NO_MORE_DOCS) {
+ return docNo;
+ }
+
if (contextNo != -1 && contextNo < target) {
int docId = contextScorer.advance(target);
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+ if (docId != NO_MORE_DOCS) {
contextNo = docId;
} else {
contextNo = -1;
}
}
docNo = target - 1;
- return next();
+ return nextDoc();
}
- /**
- * @throws UnsupportedOperationException always
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
- }
+ }
+}
-}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (revision )
@@ -16,17 +16,16 @@
*/
package org.apache.jackrabbit.core.query.lucene;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.search.Sort;
-import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
+import org.apache.lucene.search.Weight;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,10 +33,10 @@
import javax.jcr.RepositoryException;
import java.io.IOException;
import java.util.BitSet;
-import java.util.Set;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
-import java.util.Iterator;
/**
* Implements a lucene Query which filters a sub query by checking
@@ -431,6 +430,8 @@
*/
private final int[] singleDoc = new int[1];
+ private int currentDoc = -1;
+
/**
* Creates a new DescendantSelfAxisScorer.
*
@@ -447,53 +448,57 @@
this.contextHits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
- collectContextHits();
- int nextDoc = subScorer.nextDoc();
- if (nextDoc == DocIdSetIterator.NO_MORE_DOCS || contextHits.isEmpty()) {
- return false;
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
}
- while (nextDoc != DocIdSetIterator.NO_MORE_DOCS) {
- if (isValid(nextDoc)) {
- return true;
+ collectContextHits();
+ currentDoc = subScorer.nextDoc();
+ if (contextHits.isEmpty()) {
+ currentDoc = NO_MORE_DOCS;
- }
+ }
+ while (currentDoc != NO_MORE_DOCS) {
+ if (isValid(currentDoc)) {
+ return currentDoc;
+ }
// try next
- nextDoc = subScorer.nextDoc();
+ currentDoc = subScorer.nextDoc();
}
- return false;
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return subScorer.docID();
+ @Override
+ public int docID() {
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return subScorer.score();
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- int docId = subScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
- collectContextHits();
- return isValid(docId) || next();
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
+ currentDoc = subScorer.nextDoc();
+ if (currentDoc == NO_MORE_DOCS) {
+ return NO_MORE_DOCS;
} else {
- return false;
+ collectContextHits();
+ if (isValid(currentDoc)) {
+ return currentDoc;
- }
+ }
+ else {
+ return nextDoc();
- }
+ }
+ }
+ }
private void collectContextHits() throws IOException {
if (!contextHitsCalculated) {
@@ -518,14 +523,6 @@
}
/**
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /**
* Returns true if doc is a valid match from
* the sub scorer against the context hits. The caller must ensure
* that the context hits are calculated before this method is called!
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java (revision )
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
@@ -49,6 +48,8 @@
*/
private boolean hasNext = true;
+ private int currentDoc = -1;
+
/**
* Creates a new MultiScorer that spans multiple
* scorers.
@@ -63,13 +64,16 @@
this.starts = starts;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
while (hasNext) {
- if (scorers[current].nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- return true;
+ if (scorers[current].nextDoc() != NO_MORE_DOCS) {
+ currentDoc = scorers[current].docID() + starts[current];
+ return currentDoc;
} else if (++current < scorers.length) {
// advance to next scorer
} else {
@@ -77,38 +81,41 @@
hasNext = false;
}
}
- return hasNext;
+
+ currentDoc = NO_MORE_DOCS;
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return scorers[current].docID() + starts[current];
+ @Override
+ public int docID() {
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return scorers[current].score();
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
current = scorerIndex(target);
- if (scorers[current].advance(target - starts[current]) != DocIdSetIterator.NO_MORE_DOCS) {
- return true;
+ if (scorers[current].advance(target - starts[current]) != NO_MORE_DOCS) {
+ currentDoc = scorers[current].docID() + starts[current];
+ return currentDoc;
} else {
if (++current < scorers.length) {
// simply move to the next if there is any
- return next();
+ currentDoc = nextDoc();
+ return currentDoc;
} else {
// no more document
hasNext = false;
- return hasNext;
+ currentDoc = NO_MORE_DOCS;
+ return currentDoc;
}
}
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java (revision )
@@ -16,14 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
@@ -39,8 +31,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
- * Implements a variant of the lucene class {@link org.apache.lucene.search.RangeQuery}.
+ * Implements a variant of the lucene class {@link org.apache.lucene.search.RangeQuery}. // fixme lucene
* This class does not rewrite to basic {@link org.apache.lucene.search.TermQuery}
* but will calculate the matching documents itself. That way a
* TooManyClauses can be avoided.
@@ -358,44 +358,42 @@
hits = result;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * Returns an empty Explanation object.
- * @return an empty Explanation object.
- */
- public Explanation explain(int doc) {
- return new Explanation();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java (revision )
@@ -258,46 +258,42 @@
this.hits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java (revision )
@@ -16,12 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.jackrabbit.core.query.lucene.hits.Hits;
import org.apache.jackrabbit.core.query.lucene.hits.ScorerHits;
@@ -34,6 +28,12 @@
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
/**
* ParentAxisQuery selects the parent nodes of a context query.
*/
@@ -268,25 +268,26 @@
this.hResolver = resolver;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateParent();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
Float score = scores.get(nextDoc);
if (score == null) {
@@ -295,23 +296,18 @@
return score;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateParent();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
private void calculateParent() throws IOException {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (revision )
@@ -387,52 +387,48 @@
this.hResolver = hResolver;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
do {
nextDoc = hits.next();
} while (nextDoc > -1 && !indexIsValid(nextDoc));
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.skipTo(target);
while (nextDoc > -1 && !indexIsValid(nextDoc)) {
- next();
+ nextDoc();
}
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
private void calculateChildren() throws IOException {