gf2121 commented on a change in pull request #510:
URL: https://github.com/apache/lucene/pull/510#discussion_r762940276
##########
File path: lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java
##########
@@ -44,13 +44,21 @@ static void writeDocIds(int[] docIds, int start, int count,
DataOutput out) thro
}
}
- if (strictlySorted && (docIds[start + count - 1] - docIds[start] + 1) <=
(count << 4)) {
- // Only trigger this optimization when max - min + 1 <= 16 * count in
order to avoid expanding
- // too much storage.
- // A field with lower cardinality will have higher probability to
trigger this optimization.
- out.writeByte((byte) -1);
- writeIdsAsBitSet(docIds, start, count, out);
- return;
+ int min2max = docIds[start + count - 1] - docIds[start] + 1;
+ if (strictlySorted) {
+ if (min2max == count) {
+ // continuous ids, typically happens when segment is sorted
+ out.writeByte((byte) -2);
+ out.writeVInt(docIds[start]);
+ return;
+ } else if (min2max <= (count << 4)) {
+ // Only trigger bitset optimization when max - min + 1 <= 16 * count
in order to avoid
Review comment:
+1, fixed
--
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]