epotyom commented on code in PR #16268:
URL: https://github.com/apache/lucene/pull/16268#discussion_r3444819290
##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/facet/cutters/ranges/LongRangeFacetCutter.java:
##########
@@ -252,21 +313,48 @@ abstract static class
LongRangeSingleValuedLeafFacetCutter implements LeafFacetC
IntervalTracker requestedIntervalTracker;
+ // Skip index for the faceted field, or null when disabled.
+ private final DocValuesSkipper skipper;
+
+ // Cached decision from advanceSkipper, valid for every doc up to (and
including) upToInclusive:
+ // when upToSameInterval is true, all those docs map to elementary
interval upToIntervalOrd.
+ private int upToInclusive = -1;
+ private boolean upToSameInterval;
+ private int upToIntervalOrd;
+
LongRangeSingleValuedLeafFacetCutter(LongValues longValues, long[]
boundaries, int[] pos) {
+ this(longValues, boundaries, pos, null);
+ }
+
+ LongRangeSingleValuedLeafFacetCutter(
+ LongValues longValues, long[] boundaries, int[] pos, DocValuesSkipper
skipper) {
this.longValues = longValues;
this.boundaries = boundaries;
this.pos = pos;
+ this.skipper = skipper;
}
@Override
public boolean advanceExact(int doc) throws IOException {
- if (longValues.advanceExact(doc) == false) {
+ if (skipper != null && doc > upToInclusive) {
+ advanceSkipper(doc);
+ }
+
+ int intervalOrd;
+ if (upToSameInterval) {
+ // We are inside a dense skip block that maps entirely to one
elementary interval, so reuse
+ // the cached ordinal and skip the per-doc value lookup and binary
search.
+ intervalOrd = upToIntervalOrd;
+ } else if (longValues.advanceExact(doc)) {
+ intervalOrd = processValue(longValues.longValue());
+ } else {
return false;
}
+
if (requestedIntervalTracker != null) {
Review Comment:
Do we also want to reuse requestedIntervalTracker if intervalOrd is the same
for the previous doc?
--
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]