Package org.apache.lucene.util
Class MSBRadixSorter
- java.lang.Object
-
- org.apache.lucene.util.Sorter
-
- org.apache.lucene.util.MSBRadixSorter
-
public abstract class MSBRadixSorter extends Sorter
Radix sorter for variable-length strings. This class sorts based on the most significant byte first and falls back toIntroSorter
when the size of the buckets to sort becomes small. It is NOT stable. Worst-case memory usage is about2.3 KB
.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MSBRadixSorter(int maxLength)
Sole constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract int
byteAt(int i, int k)
Return the k-th byte of the entry at indexi
, or-1
if its length is less than or equal tok
.protected int
compare(int i, int j)
Compare entries found in slotsi
andj
.protected Sorter
getFallbackSorter(int k)
Get a fall-back sorter which may assume that the first k bytes of all compared strings are equal.void
sort(int from, int to)
Sort the slice which starts atfrom
(inclusive) and ends atto
(exclusive).-
Methods inherited from class org.apache.lucene.util.Sorter
comparePivot, setPivot, swap
-
-
-
-
Constructor Detail
-
MSBRadixSorter
protected MSBRadixSorter(int maxLength)
Sole constructor.- Parameters:
maxLength
- the maximum length of keys, passInteger.MAX_VALUE
if unknown.
-
-
Method Detail
-
byteAt
protected abstract int byteAt(int i, int k)
Return the k-th byte of the entry at indexi
, or-1
if its length is less than or equal tok
. This may only be called with a value ofi
between0
included andmaxLength
excluded.
-
getFallbackSorter
protected Sorter getFallbackSorter(int k)
Get a fall-back sorter which may assume that the first k bytes of all compared strings are equal.
-
compare
protected final int compare(int i, int j)
Description copied from class:Sorter
Compare entries found in slotsi
andj
. The contract for the returned value is the same asComparator.compare(Object, Object)
.
-
-