romseygeek commented on code in PR #16069:
URL: https://github.com/apache/lucene/pull/16069#discussion_r3260394903
##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreBulkScorer.java:
##########
@@ -164,12 +175,52 @@ private void scoreInnerWindow(
}
}
- private void scoreInnerWindowWithFilter(
+ private void scoreInnerWindowWithBitsetFilter(
LeafCollector collector, Bits acceptDocs, int max, DisiWrapper filter)
throws IOException {
+ DisiWrapper top = essentialQueue.top();
+ assert top.doc < max;
+ while (top.doc < filter.doc) {
+ // Must use the iterator as `top` might be a two-phase iterator
+ top.doc = top.iterator.advance(filter.doc);
+ top = essentialQueue.updateTop();
+ }
- // TODO: Sometimes load the filter into a bitset and use the more
optimized execution paths with
- // this bitset as `acceptDocs`
+ // Only score an inner window, after that we'll check if the min
competitive score has
+ // increased enough for a more favorable partitioning to be used.
+ int innerWindowMin = top.doc;
+ int innerWindowMax = MathUtil.unsignedMin(max, innerWindowMin +
INNER_WINDOW_SIZE);
+ if (top.doc >= max) {
+ return;
+ }
+ int innerWindowSize = innerWindowMax - innerWindowMin;
+ if (filterWindowMatches == null) {
+ filterWindowMatches = new FixedBitSet(INNER_WINDOW_SIZE);
+ } else {
+ filterWindowMatches.clear(0, innerWindowSize);
+ }
+ if (filter.doc < innerWindowMax) {
+ if (filter.doc < innerWindowMin) {
+ filter.doc = filter.approximation.advance(innerWindowMin);
+ }
+ if (filter.doc < innerWindowMax) {
+ filter.approximation.intoBitSet(innerWindowMax, filterWindowMatches,
innerWindowMin);
+ filter.doc = filter.approximation.docID();
+ }
+ }
+
+ filterBits.set(filterWindowMatches, innerWindowMin, acceptDocs);
Review Comment:
We can use `acceptDocs.applyMask(filterWindowMatches, innerWindowMin)` here
I think? No need for the FilterBits class. See DenseConjunctionBulkScorer for
an example.
##########
lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java:
##########
@@ -27,7 +28,7 @@
*/
public final class ConstantScoreScorer extends Scorer {
- private class DocIdSetIteratorWrapper extends DocIdSetIterator {
+ class DocIdSetIteratorWrapper extends DocIdSetIterator {
Review Comment:
This can stay private now I think?
##########
lucene/core/src/java/org/apache/lucene/search/MaxScoreBulkScorer.java:
##########
@@ -147,7 +156,9 @@ public int score(LeafCollector collector, Bits acceptDocs,
int min, int max) thr
private void scoreInnerWindow(
LeafCollector collector, Bits acceptDocs, int max, DisiWrapper filter)
throws IOException {
- if (filter != null) {
+ if (filter != null && loadFilterIntoBitset) {
Review Comment:
`filter != null` is always `true` if `loadFilterIntoBitset` is `true` so we
can simplify this a bit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]