LUCENE-7097: let IntroSorter go 2X deeper in quicksort before switching to heapsort

This commit is contained in:
Mike McCandless 2016-03-14 06:03:17 -04:00
parent 3c7e55da3a
commit 8cbe471377
2 changed files with 4 additions and 5 deletions

View File

@ -21,6 +21,9 @@ Optimizations
* LUCENE-7099: LatLonPoint's newDistanceQuery supports two-phase
iteration. (Robert Muir)
* LUCENE-7097: IntroSorter now recurses to 2 * log_2(count) quicksort
stack depth before switching to heapsort (Adrien Grand, Mike McCandless)
Other
* LUCENE-7087: Let MemoryIndex#fromDocument(...) accept 'Iterable<? extends IndexableField>'

View File

@ -28,17 +28,13 @@ package org.apache.lucene.util;
*/
public abstract class IntroSorter extends Sorter {
static int ceilLog2(int n) {
return Integer.SIZE - Integer.numberOfLeadingZeros(n - 1);
}
/** Create a new {@link IntroSorter}. */
public IntroSorter() {}
@Override
public final void sort(int from, int to) {
checkRange(from, to);
quicksort(from, to, ceilLog2(to - from));
quicksort(from, to, 2 * MathUtil.log(to - from, 2));
}
void quicksort(int from, int to, int maxDepth) {