Created
November 3, 2017 08:00
-
-
Save unicolet/c2d794987d68fc4976c45017f639b567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BulkScorer bulkScorer(LeafReaderContext context) throws IOException { | |
final float score = score(); | |
final int maxDoc = context.reader().maxDoc(); | |
return new BulkScorer() { | |
@Override | |
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException { | |
max = Math.min(max, maxDoc); | |
FakeScorer scorer = new FakeScorer(); | |
scorer.score = score; | |
collector.setScorer(scorer); | |
for (int doc = min; doc < max; ++doc) { | |
scorer.doc = doc; | |
if (acceptDocs == null || acceptDocs.get(doc)) { | |
collector.collect(doc); | |
} | |
} | |
return max == maxDoc ? DocIdSetIterator.NO_MORE_DOCS : max; | |
} | |
@Override | |
public long cost() { | |
return maxDoc; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment