mikemccand commented on a change in pull request #1948:
URL: https://github.com/apache/lucene-solr/pull/1948#discussion_r504863887
##########
File path: lucene/core/src/java/org/apache/lucene/index/OrdinalMap.java
##########
@@ -271,13 +273,26 @@ protected boolean lessThan(TermsEnumIndex a,
TermsEnumIndex b) {
globalOrd++;
}
- this.firstSegments = firstSegments.build();
- this.globalOrdDeltas = globalOrdDeltas.build();
+ long ramBytesUsed = BASE_RAM_BYTES_USED + segmentMap.ramBytesUsed();
+ this.valueCount = globalOrd;
+
+ // If the first segment contains all of the global ords, then we can apply
a small optimization
+ // and hardcode the first segments and global ord deltas as all zeroes.
Review comment:
Insert possessive quote (`first segment's`)?
##########
File path: lucene/core/src/java/org/apache/lucene/index/OrdinalMap.java
##########
@@ -271,13 +273,26 @@ protected boolean lessThan(TermsEnumIndex a,
TermsEnumIndex b) {
globalOrd++;
}
- this.firstSegments = firstSegments.build();
- this.globalOrdDeltas = globalOrdDeltas.build();
+ long ramBytesUsed = BASE_RAM_BYTES_USED + segmentMap.ramBytesUsed();
+ this.valueCount = globalOrd;
+
+ // If the first segment contains all of the global ords, then we can apply
a small optimization
+ // and hardcode the first segments and global ord deltas as all zeroes.
+ if (ordDeltaBits.length > 0 && ordDeltaBits[0] == 0L &&
ordDeltas[0].size() == this.valueCount) {
Review comment:
Hmm why only the first segment? Couldn't it be the 3rd segment, in
addition, that matches the global ords?
Edit: ahh OK I understand now -- this opto is indeed specific to the first
segment, so we can store `this.firstSegments` as all 0s. Good!
Do we (somewhere, couldn't find it here) pre-sort all segments by the
cardinality descending? Then we could know all segments that meet this
optimization are at the start of the segments list, and possibly building the
ordinal map is faster (not sure). But then we would need to un-sort in the end
to return the final `OrdinalMap`. But it might enable this opto to apply more
often, except, I think we would then need an additional dereference on lookup,
hmm.
Does our `PackedLongValues.monotonicBuilder` already optimize for the case
where it is all 0s, for the case where another segment (not the first) has all
the global values as well?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]