iverase commented on code in PR #16061:
URL: https://github.com/apache/lucene/pull/16061#discussion_r3240315687
##########
lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesRangeQuery.java:
##########
@@ -119,39 +119,31 @@ public ScorerSupplier scorerSupplier(LeafReaderContext
context) throws IOExcepti
}
DocValuesSkipper skipper = context.reader().getDocValuesSkipper(field);
SortedSetDocValues values = DocValues.getSortedSet(context.reader(),
field);
+ final SortedDocValues singleton = DocValues.unwrapSingleton(values);
+ if (singleton != null && skipper != null &&
isDensePrimarySort(context.reader(), skipper)) {
+ final long minOrd = minOrd(values);
+ final long maxOrd = maxOrd(values);
+ if (minOrd > maxOrd || minOrd > skipper.maxValue() || maxOrd <
skipper.minValue()) {
+ return null;
+ }
+ if (skipper.minValue() >= minOrd && skipper.maxValue() <= maxOrd) {
+ return ConstantScoreScorerSupplier.matchAll(
+ score(), scoreMode, context.reader().maxDoc());
+ }
+ final DocIdSetIterator psIterator =
+ getDocIdSetIteratorForDensePrimarySort(
Review Comment:
I think we want to use the skipper directly here, I noticed we are being a
bit inefficient here. For example:
```
skipper.advance(minOrd, Long.MAX_VALUE);
skipperMinDocId = skipper.minDocID(0);
skipperMinDocIdSet = false;
```
we are visiting always the doc values but it can be change by:
```
skipper.advance(minOrd, Long.MAX_VALUE);
skipperMinDocId = skipper.minDocID(0);
skipperMinDocIdSet = skipper.minValue(0) == minOrd;
```
So we only visit the doc values if the block does not start from the minOrd.
This should be true very often because of the way we are building the blocks.
There are other tricks from the maxOrd too!
--
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]