Skip to content

Apache Lucene open-source search software

LUCENE-6272: Scorer extends DocIdSetIterator directly

Alan Woodward299c492dd31a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d22e8cc5ce4..7bd0cb599e1 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -146,6 +146,9 @@ API Changes
* LUCENE-6266: Remove unnecessary Directory params from SegmentInfo.toString,
SegmentInfos.files/toString, and SegmentCommitInfo.toString. (Robert Muir)
+* LUCENE-6272: Scorer extends DocSetIdIterator rather than DocsEnum (Alan
+ Woodward)
+
Other
* LUCENE-6248: Remove unused odd constants from StandardSyntaxParser.jj
diff --git a/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java b/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
index 4ea0fad0f36..f0156b79f8e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.RamUsageEstimator;
/**
@@ -74,26 +73,6 @@ public abstract class CachingCollector extends FilterCollector {
@Override
public final int freq() { throw new UnsupportedOperationException(); }
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public final int nextDoc() { throw new UnsupportedOperationException(); }
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
index 885a82aa9e3..2f6f46dc806 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java
@@ -22,8 +22,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.lucene.util.BytesRef;
-
/** Scorer for conjunctions, sets of queries, all of which are required. */
class ConjunctionScorer extends Scorer {
@@ -79,26 +77,6 @@ class ConjunctionScorer extends Scorer {
return scorers.length;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public long cost() {
return disi.cost();
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
index 228e70306cd..bc48b8b8eef 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java
@@ -26,7 +26,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -235,26 +234,6 @@ public class ConstantScoreQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int target) throws IOException {
return docIdSetIterator.advance(target);
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
index f6e812d81c8..ef9f3b3e27b 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionScorer.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.List;
import org.apache.lucene.search.ScorerPriorityQueue.ScorerWrapper;
-import org.apache.lucene.util.BytesRef;
/**
* Base class for Scorers that score disjunctions.
@@ -232,23 +231,4 @@ abstract class DisjunctionScorer extends Scorer {
return children;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/DocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/DocValuesRangeQuery.java
index c72b56061b3..86f1f3c1864 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DocValuesRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DocValuesRangeQuery.java
@@ -348,26 +348,6 @@ public final class DocValuesRangeQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return disi.docID();
diff --git a/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java b/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java
index dc35f88c971..02a43e160e0 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.BytesRef;
final class ExactPhraseScorer extends Scorer {
@@ -106,26 +105,6 @@ final class ExactPhraseScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return conjunction.docID();
diff --git a/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java b/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
index 8c7f419046b..e2a50c8f37d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
@@ -17,11 +17,8 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.io.IOException;
import java.util.Collection;
-import org.apache.lucene.util.BytesRef;
-
/** Used by {@link BulkScorer}s that need to pass a {@link
* Scorer} to {@link LeafCollector#setScorer}. */
final class FakeScorer extends Scorer {
@@ -48,26 +45,6 @@ final class FakeScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException("FakeScorer doesn't support nextPosition()");
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException("FakeScorer doesn't support startOffset()");
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException("FakeScorer doesn't support endOffset()");
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException("FakeScorer doesn't support getPayload()");
- }
-
@Override
public int nextDoc() {
throw new UnsupportedOperationException("FakeScorer doesn't support nextDoc()");
diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldValueQuery.java b/lucene/core/src/java/org/apache/lucene/search/FieldValueQuery.java
index 7cd679f00ac..3ae1c6b5b5e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FieldValueQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FieldValueQuery.java
@@ -24,7 +24,6 @@ import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.Bits.MatchNoBits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -155,31 +154,11 @@ public final class FieldValueQuery extends Query {
return disi.advance(target);
}
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int freq() throws IOException {
return 1;
}
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
@Override
public float score() throws IOException {
return queryWeight;
diff --git a/lucene/core/src/java/org/apache/lucene/search/Filter.java b/lucene/core/src/java/org/apache/lucene/search/Filter.java
index cedf5e5c5cd..72dbe057e92 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Filter.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Filter.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
/**
* Convenient base class for building queries that only perform matching, but
@@ -123,26 +122,6 @@ public abstract class Filter extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return iterator.docID();
diff --git a/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java b/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
index 5ff8206b3f0..22b96b7e79d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FilterScorer.java
@@ -19,9 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
-import org.apache.lucene.util.AttributeSource;
-import org.apache.lucene.util.BytesRef;
-
/**
* A {@code FilterScorer} contains another {@code Scorer}, which it
* uses as its basic source of data, possibly transforming the data along the
@@ -74,11 +71,6 @@ public abstract class FilterScorer extends Scorer {
return in.nextDoc();
}
- @Override
- public int nextPosition() throws IOException {
- return in.nextPosition();
- }
-
@Override
public int advance(int target) throws IOException {
return in.advance(target);
@@ -89,23 +81,4 @@ public abstract class FilterScorer extends Scorer {
return in.cost();
}
- @Override
- public int startOffset() throws IOException {
- return in.startOffset();
- }
-
- @Override
- public int endOffset() throws IOException {
- return in.endOffset();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return in.getPayload();
- }
-
- @Override
- public AttributeSource attributes() {
- return in.attributes();
- }
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
index 8817abc0eed..5cd2a8f4412 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
@@ -24,7 +24,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -73,26 +72,6 @@ public class MatchAllDocsQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int target) throws IOException {
doc = target-1;
diff --git a/lucene/core/src/java/org/apache/lucene/search/MinShouldMatchSumScorer.java b/lucene/core/src/java/org/apache/lucene/search/MinShouldMatchSumScorer.java
index fe8b2498c13..d989ff41c7a 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MinShouldMatchSumScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MinShouldMatchSumScorer.java
@@ -24,7 +24,6 @@ import java.util.Collections;
import java.util.List;
import org.apache.lucene.search.ScorerPriorityQueue.ScorerWrapper;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.PriorityQueue;
import static org.apache.lucene.search.ScorerPriorityQueue.leftNode;
@@ -230,26 +229,6 @@ final class MinShouldMatchSumScorer extends Scorer {
}
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
/** Advance tail to the lead until there is a match. */
private int doNext() throws IOException {
while (freq < minShouldMatch) {
diff --git a/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java b/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
index 5755976550b..dde72f76ae4 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ReqOptSumScorer.java
@@ -20,8 +20,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import org.apache.lucene.util.BytesRef;
-
/** A Scorer for queries with a required part and an optional part.
* Delays skipTo() on the optional part until a score() is needed.
* <br>
@@ -99,26 +97,6 @@ class ReqOptSumScorer extends Scorer {
return (optScorer != null && optScorer.docID() == reqScorer.docID()) ? 2 : 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public Collection<ChildScorer> getChildren() {
ArrayList<ChildScorer> children = new ArrayList<>(2);
diff --git a/lucene/core/src/java/org/apache/lucene/search/Scorer.java b/lucene/core/src/java/org/apache/lucene/search/Scorer.java
index e234f455e86..fd1f19b53b4 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Scorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Scorer.java
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
-import org.apache.lucene.index.PostingsEnum;
-
/**
* Expert: Common scoring functionality for different types of queries.
*
@@ -41,7 +39,7 @@ import org.apache.lucene.index.PostingsEnum;
* TopScoreDocCollector}) will not properly collect hits
* with these scores.
*/
-public abstract class Scorer extends PostingsEnum {
+public abstract class Scorer extends DocIdSetIterator {
/** the Scorer's parent Weight. in some cases this may be null */
// TODO can we clean this up?
protected final Weight weight;
@@ -61,6 +59,9 @@ public abstract class Scorer extends PostingsEnum {
*/
public abstract float score() throws IOException;
+ /** Returns the freq of this Scorer on the current document */
+ public abstract int freq() throws IOException;
+
/** returns parent Weight
* @lucene.experimental
*/
diff --git a/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java b/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
index 805113b72cf..70b1984e896 100644
--- a/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
@@ -27,7 +27,6 @@ import java.util.LinkedHashMap;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
final class SloppyPhraseScorer extends Scorer {
@@ -529,26 +528,6 @@ final class SloppyPhraseScorer extends Scorer {
return numMatches;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
float sloppyFreq() {
return sloppyFreq;
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/TermScorer.java b/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
index 70808359bf4..94951dc663b 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermScorer.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.BytesRef;
/** Expert: A <code>Scorer</code> for documents matching a <code>Term</code>.
*/
@@ -56,26 +55,6 @@ final class TermScorer extends Scorer {
return postingsEnum.freq();
}
- @Override
- public int nextPosition() throws IOException {
- return postingsEnum.nextPosition();
- }
-
- @Override
- public int startOffset() throws IOException {
- return postingsEnum.startOffset();
- }
-
- @Override
- public int endOffset() throws IOException {
- return postingsEnum.endOffset();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return postingsEnum.getPayload();
- }
-
/**
* Advances to the next document matching the query. <br>
*
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanScorer.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanScorer.java
index 35cf7b94bce..56b25713aa6 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanScorer.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.BytesRef;
/**
* Public for extension only.
@@ -98,26 +97,6 @@ public class SpanScorer extends Scorer {
return numMatches;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException("SpanQueries do not support nextPosition() iteration");
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
/** Returns the intermediate "sloppy freq" adjusted for edit distance
* @lucene.internal */
// only public so .payloads can see it.
diff --git a/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java b/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
index 67c31219047..51c37124cec 100644
--- a/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
+++ b/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
@@ -23,7 +23,6 @@ import org.apache.lucene.index.FieldInvertState;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.PriorityQueue;
/**
@@ -199,26 +198,6 @@ final class JustCompileSearch {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException(UNSUPPORTED_MSG);
- }
-
@Override
public int docID() {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestCachingCollector.java b/lucene/core/src/test/org/apache/lucene/search/TestCachingCollector.java
index 3b71b4131a4..c03f7290ae9 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestCachingCollector.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestCachingCollector.java
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
public class TestCachingCollector extends LuceneTestCase {
@@ -38,26 +37,6 @@ public class TestCachingCollector extends LuceneTestCase {
@Override
public int freq() throws IOException { return 0; }
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() { return 0; }
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java b/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
index 0df7c9cb161..03acfc566b7 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestConjunctionDISI.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.Arrays;
import org.apache.lucene.util.BitDocIdSet;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
@@ -105,26 +104,6 @@ public class TestConjunctionDISI extends LuceneTestCase {
return 0;
}
- @Override
- public int nextPosition() throws IOException {
- return 0;
- }
-
- @Override
- public int startOffset() throws IOException {
- return 0;
- }
-
- @Override
- public int endOffset() throws IOException {
- return 0;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
};
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java b/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
index 829ba688bb3..23f4e6b2518 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
@@ -355,26 +355,6 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
return currentMatched;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return currentDoc;
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java b/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
index 3279ab47a2a..c8017a9ced6 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
@@ -17,14 +17,11 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.io.IOException;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
public class TestPositiveScoresOnlyCollector extends LuceneTestCase {
@@ -44,26 +41,6 @@ public class TestPositiveScoresOnlyCollector extends LuceneTestCase {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override public int docID() { return idx; }
@Override public int nextDoc() {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java b/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
index 0aac3165da9..17e12d995f3 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
@@ -36,7 +36,6 @@ import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
@@ -454,26 +453,6 @@ public class TestQueryRescorer extends LuceneTestCase {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public long cost() {
return 1;
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
index 449acf00b6f..4fe88f43d23 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
@@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
public class TestScoreCachingWrappingScorer extends LuceneTestCase {
@@ -48,26 +47,6 @@ public class TestScoreCachingWrappingScorer extends LuceneTestCase {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override public int docID() { return doc; }
@Override public int nextDoc() {
diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/FakeScorer.java b/lucene/expressions/src/java/org/apache/lucene/expressions/FakeScorer.java
index 133e0439079..d521d22b689 100644
--- a/lucene/expressions/src/java/org/apache/lucene/expressions/FakeScorer.java
+++ b/lucene/expressions/src/java/org/apache/lucene/expressions/FakeScorer.java
@@ -20,7 +20,6 @@ package org.apache.lucene.expressions;
import java.io.IOException;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.util.BytesRef;
class FakeScorer extends Scorer {
@@ -57,26 +56,6 @@ class FakeScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public float score() throws IOException {
return score;
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java
index a618231edde..6996b295410 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java
@@ -21,8 +21,8 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
-import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.search.BulkScorer;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.DocIdSetIterator;
@@ -30,7 +30,6 @@ import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
class DrillSidewaysScorer extends BulkScorer {
@@ -653,26 +652,6 @@ class DrillSidewaysScorer extends BulkScorer {
return 1+dims.length;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException("FakeScorer doesn't support nextPosition()");
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public int nextDoc() {
throw new UnsupportedOperationException("FakeScorer doesn't support nextDoc()");
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FakeScorer.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FakeScorer.java
index 27b30b6c965..c4028577e45 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FakeScorer.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FakeScorer.java
@@ -20,7 +20,6 @@ package org.apache.lucene.facet.taxonomy;
import java.io.IOException;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.util.BytesRef;
class FakeScorer extends Scorer {
@@ -57,26 +56,6 @@ class FakeScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public float score() throws IOException {
return score;
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/FakeScorer.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/FakeScorer.java
index b5afcdcd3ff..0fc685c1e11 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/FakeScorer.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/FakeScorer.java
@@ -20,7 +20,6 @@ package org.apache.lucene.search.grouping;
import java.io.IOException;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.util.BytesRef;
class FakeScorer extends Scorer {
@@ -57,26 +56,6 @@ class FakeScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public float score() throws IOException {
return score;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/FakeScorer.java b/lucene/join/src/java/org/apache/lucene/search/join/FakeScorer.java
index eed50ddcba7..58fd79330e9 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/FakeScorer.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/FakeScorer.java
@@ -20,7 +20,6 @@ package org.apache.lucene.search.join;
import java.io.IOException;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.util.BytesRef;
class FakeScorer extends Scorer {
@@ -57,26 +56,6 @@ class FakeScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public float score() throws IOException {
return score;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
index 286f5109094..7c7528fc7f2 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
@@ -21,9 +21,9 @@ import java.io.IOException;
import java.util.Locale;
import java.util.Set;
-import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
@@ -224,26 +224,6 @@ class TermsIncludingScoreQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return currentDoc;
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
index 0a85dbcdb3a..91a76add8d2 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
@@ -33,7 +33,6 @@ import org.apache.lucene.search.Weight;
import org.apache.lucene.util.BitDocIdSet;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
/**
* Just like {@link ToParentBlockJoinQuery}, except this
@@ -264,26 +263,6 @@ public class ToChildBlockJoinQuery extends Query {
return parentFreq;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int childTarget) throws IOException {
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
index 324d5ed2a91..cd14443f884 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
@@ -39,7 +39,6 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BitDocIdSet;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
/**
* This query requires that you index
@@ -365,26 +364,6 @@ public class ToParentBlockJoinQuery extends Query {
return parentFreq;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int parentTarget) throws IOException {
diff --git a/lucene/misc/src/java/org/apache/lucene/index/Sorter.java b/lucene/misc/src/java/org/apache/lucene/index/Sorter.java
index 1892e658cac..42703b87410 100644
--- a/lucene/misc/src/java/org/apache/lucene/index/Sorter.java
+++ b/lucene/misc/src/java/org/apache/lucene/index/Sorter.java
@@ -24,7 +24,6 @@ import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TimSorter;
import org.apache.lucene.util.packed.PackedInts;
import org.apache.lucene.util.packed.PackedLongValues;
@@ -290,26 +289,6 @@ final class Sorter {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public float score() throws IOException {
return score;
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
index ddf60cd5681..68e00c15a56 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
@@ -35,7 +35,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.ToStringUtils;
/**
@@ -325,26 +324,6 @@ public class CustomScoreQuery extends Query {
return subQueryScorer.freq();
}
- @Override
- public int nextPosition() throws IOException {
- return subQueryScorer.nextPosition();
- }
-
- @Override
- public int startOffset() throws IOException {
- return subQueryScorer.startOffset();
- }
-
- @Override
- public int endOffset() throws IOException {
- return subQueryScorer.endOffset();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return subQueryScorer.getPayload();
- }
-
@Override
public Collection<ChildScorer> getChildren() {
return Collections.singleton(new ChildScorer(subQueryScorer, "CUSTOM"));
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
index b338452f99b..b29b336ca94 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
@@ -31,7 +31,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
/**
@@ -168,26 +167,6 @@ public class FunctionQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
public Explanation explain(int doc) throws IOException {
float sc = qWeight * vals.floatVal(doc);
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
index 5b786c0ebd7..d1b62c44362 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSourceScorer.java
@@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
/**
* {@link Scorer} which returns the result of {@link FunctionValues#floatVal(int)} as
@@ -93,26 +92,6 @@ public class ValueSourceScorer extends Scorer {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public long cost() {
return maxDoc;
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
index c7f25caebc7..106c307574a 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonScorer.java
@@ -325,26 +325,6 @@ class TermAutomatonScorer extends Scorer {
return freq;
}
- @Override
- public int nextPosition() throws IOException {
- return -1; // TODO can we get positional information out of this Scorer?
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return docID;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java b/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
index b51fea9bb26..fbe853b7194 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
@@ -25,12 +25,11 @@ import java.util.Map;
import java.util.Random;
import java.util.WeakHashMap;
-import org.apache.lucene.index.AssertingLeafReader;
-import org.apache.lucene.util.BytesRef;
-
/** Wraps a Scorer with additional checks */
public class AssertingScorer extends Scorer {
+ static enum IteratorState { START, ITERATING, FINISHED };
+
// we need to track scorers using a weak hash map because otherwise we
// could loose references because of eg.
// AssertingScorer.score(Collector) which needs to delegate to work correctly
@@ -64,13 +63,14 @@ public class AssertingScorer extends Scorer {
final Random random;
final Scorer in;
- final AssertingLeafReader.AssertingPostingsEnum docsEnumIn;
+
+ IteratorState state = IteratorState.START;
+ int doc = -1;
private AssertingScorer(Random random, Scorer in) {
super(in.weight);
this.random = random;
this.in = in;
- this.docsEnumIn = new AssertingLeafReader.AssertingPostingsEnum(in);
}
public Scorer getIn() {
@@ -111,30 +111,6 @@ public class AssertingScorer extends Scorer {
return in.freq();
}
- @Override
- public int nextPosition() throws IOException {
- assert iterating();
- return in.nextPosition();
- }
-
- @Override
- public int startOffset() throws IOException {
- assert iterating();
- return in.startOffset();
- }
-
- @Override
- public int endOffset() throws IOException {
- assert iterating();
- return in.endOffset();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- assert iterating();
- return in.getPayload();
- }
-
@Override
public int docID() {
return in.docID();
@@ -142,12 +118,31 @@ public class AssertingScorer extends Scorer {
@Override
public int nextDoc() throws IOException {
- return docsEnumIn.nextDoc();
+ assert state != IteratorState.FINISHED : "nextDoc() called after NO_MORE_DOCS";
+ int nextDoc = in.nextDoc();
+ assert nextDoc > doc : "backwards nextDoc from " + doc + " to " + nextDoc + " " + in;
+ if (nextDoc == DocIdSetIterator.NO_MORE_DOCS) {
+ state = IteratorState.FINISHED;
+ } else {
+ state = IteratorState.ITERATING;
+ }
+ assert in.docID() == nextDoc;
+ return doc = nextDoc;
}
@Override
public int advance(int target) throws IOException {
- return docsEnumIn.advance(target);
+ assert state != IteratorState.FINISHED : "advance() called after NO_MORE_DOCS";
+ assert target > doc : "target must be > docID(), got " + target + " <= " + doc;
+ int advanced = in.advance(target);
+ assert advanced >= target : "backwards advance from: " + target + " to: " + advanced;
+ if (advanced == DocIdSetIterator.NO_MORE_DOCS) {
+ state = IteratorState.FINISHED;
+ } else {
+ state = IteratorState.ITERATING;
+ }
+ assert in.docID() == advanced;
+ return doc = advanced;
}
@Override
diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java b/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
index 67dd35740d0..e682d9ddbe3 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
@@ -20,8 +20,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.lucene.util.BytesRef;
-
/**
* A {@link BulkScorer}-backed scorer.
*/
@@ -80,26 +78,6 @@ public class BulkScorerWrapperScorer extends Scorer {
return freqs[i];
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int docID() {
return doc;
diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java b/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
index 0bd63e24dcf..3d4a2783253 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
@@ -1,6 +1,13 @@
package org.apache.lucene.search;
import java.io.IOException;
+import java.util.Random;
+
+import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.util.Bits;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,14 +24,6 @@ import java.io.IOException;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import java.util.Random;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
-
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
/**
* A {@link Query} that adds random approximations to its scorers.
@@ -142,26 +141,6 @@ public class RandomApproximationQuery extends Query {
return scorer.freq();
}
- @Override
- public int nextPosition() throws IOException {
- return scorer.nextPosition();
- }
-
- @Override
- public int startOffset() throws IOException {
- return scorer.startOffset();
- }
-
- @Override
- public int endOffset() throws IOException {
- return scorer.endOffset();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return scorer.getPayload();
- }
-
@Override
public int docID() {
return scorer.docID();
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index 89835d70b9c..a260ca70303 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -1349,26 +1349,6 @@ public class QueryComponent extends SearchComponent
throw new UnsupportedOperationException();
}
- @Override
- public int nextPosition() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int startOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int endOffset() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- throw new UnsupportedOperationException();
- }
-
@Override
public int nextDoc() throws IOException {
throw new UnsupportedOperationException();
diff --git a/solr/core/src/java/org/apache/solr/schema/LatLonType.java b/solr/core/src/java/org/apache/solr/schema/LatLonType.java
index f9521fbed7a..08a4461b4ed 100644
--- a/solr/core/src/java/org/apache/solr/schema/LatLonType.java
+++ b/solr/core/src/java/org/apache/solr/schema/LatLonType.java
@@ -44,7 +44,6 @@ import org.apache.lucene.search.SortField;
import org.apache.lucene.search.Weight;
import org.apache.lucene.uninverting.UninvertingReader.Type;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.SolrException;
import org.apache.solr.response.TextResponseWriter;
import org.apache.solr.search.DelegatingCollector;
@@ -482,26 +481,6 @@ class SpatialDistanceQuery extends ExtendedQueryBase implements PostFilter {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public long cost() {
return maxDoc;
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index c5603084f0d..f59abc2903f 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -365,26 +365,6 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return 0;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
public int advance(int i) {
return -1;
}
diff --git a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
index 8a3c9f701f8..9b9cee0ebfa 100644
--- a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
@@ -622,26 +622,6 @@ class JoinQuery extends Query {
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int target) throws IOException {
return iter.advance(target);
diff --git a/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java b/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java
index 0051d66791c..8cf9ec3953a 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java
@@ -18,7 +18,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.SolrException;
/*
@@ -198,26 +197,6 @@ public class SolrConstantScoreQuery extends ConstantScoreQuery implements Extend
return 1;
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int advance(int target) throws IOException {
return docIdSetIterator.advance(target);
diff --git a/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java b/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java
index ed0f0b06171..ccbd2e690aa 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java
@@ -35,9 +35,9 @@ import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.LeafFieldComparator;
+import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Sort;
@@ -45,7 +45,6 @@ import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopDocsCollector;
import org.apache.lucene.search.Weight;
-import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.InPlaceMergeSorter;
import org.apache.lucene.util.PriorityQueue;
import org.apache.solr.client.solrj.SolrServerException;
@@ -477,26 +476,6 @@ public class TestRankQueryPlugin extends QParserPlugin {
throw new UnsupportedOperationException();
}
- @Override
- public int nextPosition() throws IOException {
- return -1;
- }
-
- @Override
- public int startOffset() throws IOException {
- return -1;
- }
-
- @Override
- public int endOffset() throws IOException {
- return -1;
- }
-
- @Override
- public BytesRef getPayload() throws IOException {
- return null;
- }
-
@Override
public int nextDoc() throws IOException {
throw new UnsupportedOperationException();