mirror of https://github.com/apache/lucene.git
LUCENE-7097: let IntroSorter go 2X deeper in quicksort before switching to heapsort
This commit is contained in:
parent
3c7e55da3a
commit
8cbe471377
|
@ -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>'
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue