Package org.apache.lucene.search.suggest
Class Sort
- java.lang.Object
-
- org.apache.lucene.search.suggest.Sort
-
public final class Sort extends java.lang.ObjectOn-disk sorting of byte arrays. Each byte array (entry) is a composed of the following fields:- (two bytes) length of the following byte array,
- exactly the above count of bytes for the sequence to be sorted.
- See Also:
sort(File, File)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSort.BufferSizeA bit more descriptive unit for constructors.static classSort.ByteSequencesReaderUtility class to read length-prefixed byte[] entries from an input.static classSort.ByteSequencesWriterUtility class to emit length-prefixed byte[] entries to an output stream for sorting.classSort.SortInfoSort info (debugging mostly).
-
Field Summary
Fields Modifier and Type Field Description static longABSOLUTE_MIN_SORT_BUFFER_SIZEAbsolute minimum required buffer size for sorting.static java.util.Comparator<BytesRef>DEFAULT_COMPARATORDefault comparator: sorts in binary (codepoint) orderstatic longGBConvenience constant for gigabytesstatic intMAX_TEMPFILESMaximum number of temporary files before doing an intermediate merge.static longMBConvenience constant for megabytesstatic longMIN_BUFFER_SIZE_MBMinimum recommended buffer size for sorting.
-
Constructor Summary
Constructors Constructor Description Sort()Defaults constructor.Sort(java.util.Comparator<BytesRef> comparator)Defaults constructor with a custom comparator.Sort(java.util.Comparator<BytesRef> comparator, Sort.BufferSize ramBufferSize, java.io.File tempDirectory, int maxTempfiles)All-details constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.io.FiledefaultTempDir()Returns the default temporary directory.java.util.Comparator<BytesRef>getComparator()Returns the comparator in use to sort entriesSort.SortInfosort(java.io.File input, java.io.File output)Sort input to output, explicit hint for the buffer size.
-
-
-
Field Detail
-
MB
public static final long MB
Convenience constant for megabytes- See Also:
- Constant Field Values
-
GB
public static final long GB
Convenience constant for gigabytes- See Also:
- Constant Field Values
-
MIN_BUFFER_SIZE_MB
public static final long MIN_BUFFER_SIZE_MB
Minimum recommended buffer size for sorting.- See Also:
- Constant Field Values
-
ABSOLUTE_MIN_SORT_BUFFER_SIZE
public static final long ABSOLUTE_MIN_SORT_BUFFER_SIZE
Absolute minimum required buffer size for sorting.- See Also:
- Constant Field Values
-
MAX_TEMPFILES
public static final int MAX_TEMPFILES
Maximum number of temporary files before doing an intermediate merge.- See Also:
- Constant Field Values
-
DEFAULT_COMPARATOR
public static final java.util.Comparator<BytesRef> DEFAULT_COMPARATOR
Default comparator: sorts in binary (codepoint) order
-
-
Constructor Detail
-
Sort
public Sort() throws java.io.IOExceptionDefaults constructor.- Throws:
java.io.IOException- See Also:
defaultTempDir(),Sort.BufferSize.automatic()
-
Sort
public Sort(java.util.Comparator<BytesRef> comparator) throws java.io.IOException
Defaults constructor with a custom comparator.- Throws:
java.io.IOException- See Also:
defaultTempDir(),Sort.BufferSize.automatic()
-
Sort
public Sort(java.util.Comparator<BytesRef> comparator, Sort.BufferSize ramBufferSize, java.io.File tempDirectory, int maxTempfiles)
All-details constructor.
-
-
Method Detail
-
sort
public Sort.SortInfo sort(java.io.File input, java.io.File output) throws java.io.IOException
Sort input to output, explicit hint for the buffer size. The amount of allocated memory may deviate from the hint (may be smaller or larger).- Throws:
java.io.IOException
-
defaultTempDir
public static java.io.File defaultTempDir() throws java.io.IOExceptionReturns the default temporary directory. By default, java.io.tmpdir. If not accessible or not available, an IOException is thrown- Throws:
java.io.IOException
-
getComparator
public java.util.Comparator<BytesRef> getComparator()
Returns the comparator in use to sort entries
-
-