mirror of https://github.com/apache/lucene.git
Add a comment about the recursion threshold of StringMSBRadixSorter.
This commit is contained in:
parent
94c7ccd589
commit
2554b10692
|
@ -33,7 +33,7 @@ public abstract class InPlaceMergeSorter extends Sorter {
|
|||
}
|
||||
|
||||
void mergeSort(int from, int to) {
|
||||
if (to - from < THRESHOLD) {
|
||||
if (to - from < INSERTION_SORT_THRESHOLD) {
|
||||
insertionSort(from, to);
|
||||
} else {
|
||||
final int mid = (from + to) >>> 1;
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class IntroSorter extends Sorter {
|
|||
}
|
||||
|
||||
void quicksort(int from, int to, int maxDepth) {
|
||||
if (to - from < THRESHOLD) {
|
||||
if (to - from < INSERTION_SORT_THRESHOLD) {
|
||||
insertionSort(from, to);
|
||||
return;
|
||||
} else if (--maxDepth < 0) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Comparator;
|
|||
* @lucene.internal */
|
||||
public abstract class Sorter {
|
||||
|
||||
static final int THRESHOLD = 20;
|
||||
static final int INSERTION_SORT_THRESHOLD = 20;
|
||||
|
||||
/** Sole constructor, used for inheritance. */
|
||||
protected Sorter() {}
|
||||
|
|
|
@ -21,10 +21,13 @@ import java.util.Arrays;
|
|||
/** Radix sorter for variable-length strings. This class sorts based on the most
|
||||
* significant byte first and falls back to {@link IntroSorter} when the size
|
||||
* of the buckets to sort becomes small. It is <b>NOT</b> stable.
|
||||
* Worst-case memory usage is about {@code 2.3 KB} */
|
||||
* Worst-case memory usage is about {@code 2.3 KB}. */
|
||||
abstract class StringMSBRadixSorter extends Sorter {
|
||||
|
||||
// after that many levels of recursion we fall back to introsort anyway
|
||||
// this is used as a protection against the fact that radix sort performs
|
||||
// worse when there are long common prefixes (probably because of cache
|
||||
// locality)
|
||||
private static final int LEVEL_THRESHOLD = 8;
|
||||
// size of histograms: 256 + 1 to indicate that the string is finished
|
||||
private static final int HISTOGRAM_SIZE = 257;
|
||||
|
|
Loading…
Reference in New Issue