uchiha-asha commented on code in PR #17045:
URL: https://github.com/apache/lucene/pull/17045#discussion_r4639306725
##########
lucene/core/src/java/org/apache/lucene/util/DocIdSetBuilder.java:
##########
@@ -367,6 +366,55 @@ private static Buffer concat(List<Buffer> buffers) {
return new Buffer(docs, totalLength);
}
+ /** Sort {@code docs[0:length]} in ascending order. */
+ private void sort(int[] docs, int length) {
+ LSBRadixSorter sorter = new LSBRadixSorter();
+ final int numBits = PackedInts.bitsRequired(maxDoc - 1);
+ if (length < LSBRadixSorter.INSERTION_SORT_THRESHOLD) {
+ // Small inputs are sorted with insertion sort, whose cost does not
depend on the number of
+ // bits of the values.
+ sorter.sort(numBits, docs, length);
+ return;
+ }
+ // The cost of the radix sort is proportional to the number of bits of the
values to sort. Doc
+ // IDs are often clustered in a small range of the doc ID space, e.g. when
a range query on a
+ // timestamp runs against a segment whose documents got indexed in
(approximate) timestamp
+ // order, or when the index is sorted. So we sort deltas from the minimum
doc ID rather than
+ // doc IDs if this saves sorting passes.
+ final int numPasses = numRadixSortPasses(numBits);
+ int min = docs[0];
+ int max = docs[0];
Review Comment:
moved to `LSBRadixSorter`
--
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]