Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: lucene/core/src/java/org/apache/lucene/search/Filter.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/search/Filter.java (revision 1633246)
- +++ lucene/core/src/java/org/apache/lucene/search/Filter.java (working copy)
- @@ -56,4 +56,16 @@
- * in the case an <i>empty</i> {@link DocIdSet} is returned.
- */
- public abstract DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) throws IOException;
- +
- + /**
- + * Returns an iterator matching documents.
- + */
- + public DocIdSetIterator iterator(LeafReaderContext context, Bits acceptDocs) throws IOException {
- + DocIdSet set = getDocIdSet(context, acceptDocs);
- + if (set == null) {
- + return null;
- + } else {
- + return set.iterator();
- + }
- + }
- }
- Index: lucene/core/src/java/org/apache/lucene/search/Weight.java
- ===================================================================
- --- lucene/core/src/java/org/apache/lucene/search/Weight.java (revision 1633246)
- +++ lucene/core/src/java/org/apache/lucene/search/Weight.java (working copy)
- @@ -34,7 +34,7 @@
- * {@link org.apache.lucene.index.LeafReader} dependent state should reside in the {@link Scorer}.
- * <p>
- * Since {@link Weight} creates {@link Scorer} instances for a given
- - * {@link org.apache.lucene.index.LeafReaderContext} ({@link #scorer(org.apache.lucene.index.LeafReaderContext, Bits)})
- + * {@link org.apache.lucene.index.LeafReaderContext} ({@link #iterator(org.apache.lucene.index.LeafReaderContext, Bits)})
- * callers must maintain the relationship between the searcher's top-level
- * {@link IndexReaderContext} and the context used to create a {@link Scorer}.
- * <p>
- @@ -49,12 +49,12 @@
- * <li>The query normalization factor is passed to {@link #normalize(float, float)}. At
- * this point the weighting is complete.
- * <li>A <code>Scorer</code> is constructed by
- - * {@link #scorer(org.apache.lucene.index.LeafReaderContext, Bits)}.
- + * {@link #iterator(org.apache.lucene.index.LeafReaderContext, Bits)}.
- * </ol>
- *
- * @since 2.9
- */
- -public abstract class Weight {
- +public abstract class Weight extends Filter {
- /**
- * An explanation of the score computation for the named document.
- @@ -75,6 +75,21 @@
- /** Assigns the query normalization factor and boost from parent queries to this. */
- public abstract void normalize(float norm, float topLevelBoost);
- + @Override
- + public final DocIdSet getDocIdSet(final LeafReaderContext context, final Bits acceptDocs) throws IOException {
- + return new DocIdSet() {
- + @Override
- + public long ramBytesUsed() {
- + return 0;
- + }
- +
- + @Override
- + public DocIdSetIterator iterator() throws IOException {
- + return Weight.this.iterator(context, acceptDocs);
- + }
- + };
- + }
- +
- /**
- * Returns a {@link Scorer} which scores documents in/out-of order according
- * to <code>scoreDocsInOrder</code>.
- @@ -96,7 +111,7 @@
- * @return a {@link Scorer} which scores documents in/out-of order.
- * @throws IOException if there is a low-level I/O error
- */
- - public abstract Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException;
- + public abstract Scorer iterator(LeafReaderContext context, Bits acceptDocs) throws IOException;
- /**
- * Optional method, to return a {@link BulkScorer} to
- @@ -127,7 +142,7 @@
- */
- public BulkScorer bulkScorer(LeafReaderContext context, boolean scoreDocsInOrder, Bits acceptDocs) throws IOException {
- - Scorer scorer = scorer(context, acceptDocs);
- + Scorer scorer = iterator(context, acceptDocs);
- if (scorer == null) {
- // No docs match
- return null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement