LUCENE-6272: Scorer extends DocIdSetIterator directly

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1661376 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alan Woodward 2015-02-21 15:02:46 +00:00
parent 7a471df801
commit 299c492dd3
47 changed files with 43 additions and 973 deletions

View File

@ -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

View File

@ -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(); }

View File

@ -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();

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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()");

View File

@ -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;

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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
*/

View File

@ -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;
}

View File

@ -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>
*

View File

@ -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.

View File

@ -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);

View File

@ -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; }

View File

@ -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;
}
};
}

View File

@ -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;

View File

@ -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() {

View File

@ -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;

View File

@ -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() {

View File

@ -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;

View File

@ -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()");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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"));

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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();