Class OfflineSorter
On-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.
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public sealed class OfflineSorter
Constructors
OfflineSorter()
Defaults constructor.
Declaration
public OfflineSorter()
See Also
OfflineSorter(IComparer<BytesRef>)
Defaults constructor with a custom comparer.
Declaration
public OfflineSorter(IComparer<BytesRef> comparer)
Parameters
Type | Name | Description |
---|---|---|
IComparer<BytesRef> | comparer |
See Also
OfflineSorter(IComparer<BytesRef>, BufferSize, DirectoryInfo, int)
All-details constructor.
Declaration
public OfflineSorter(IComparer<BytesRef> comparer, OfflineSorter.BufferSize ramBufferSize, DirectoryInfo tempDirectory, int maxTempfiles)
Parameters
Type | Name | Description |
---|---|---|
IComparer<BytesRef> | comparer | |
OfflineSorter.BufferSize | ramBufferSize | |
DirectoryInfo | tempDirectory | |
int | maxTempfiles |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentOutOfRangeException |
|
OfflineSorter(IComparer<BytesRef>, BufferSize, string, int)
All-details constructor.
Declaration
public OfflineSorter(IComparer<BytesRef> comparer, OfflineSorter.BufferSize ramBufferSize, string tempDirectoryPath, int maxTempfiles)
Parameters
Type | Name | Description |
---|---|---|
IComparer<BytesRef> | comparer | |
OfflineSorter.BufferSize | ramBufferSize | |
string | tempDirectoryPath | |
int | maxTempfiles |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentOutOfRangeException |
|
Fields
ABSOLUTE_MIN_SORT_BUFFER_SIZE
Absolute minimum required buffer size for sorting.
Declaration
public const long ABSOLUTE_MIN_SORT_BUFFER_SIZE = 524288
Field Value
Type | Description |
---|---|
long |
DEFAULT_COMPARER
Default comparer: sorts in binary (codepoint) order
Declaration
public static readonly IComparer<BytesRef> DEFAULT_COMPARER
Field Value
Type | Description |
---|---|
IComparer<BytesRef> |
DEFAULT_ENCODING
The default encoding (UTF-8 without a byte order mark) used by OfflineSorter.ByteSequencesReader and OfflineSorter.ByteSequencesWriter. This encoding should always be used when calling the constructor overloads that accept BinaryReader or BinaryWriter.
Declaration
public static readonly Encoding DEFAULT_ENCODING
Field Value
Type | Description |
---|---|
Encoding |
DEFAULT_FILESTREAM_BUFFER_SIZE
The recommended buffer size to use on Sort(FileStream, FileStream) or when creating a OfflineSorter.ByteSequencesReader and OfflineSorter.ByteSequencesWriter.
Declaration
public const int DEFAULT_FILESTREAM_BUFFER_SIZE = 8192
Field Value
Type | Description |
---|---|
int |
GB
Convenience constant for gigabytes
Declaration
public const long GB = 1073741824
Field Value
Type | Description |
---|---|
long |
MAX_TEMPFILES
Maximum number of temporary files before doing an intermediate merge.
Declaration
public const int MAX_TEMPFILES = 128
Field Value
Type | Description |
---|---|
int |
MB
Convenience constant for megabytes
Declaration
public const long MB = 1048576
Field Value
Type | Description |
---|---|
long |
MIN_BUFFER_SIZE_MB
Minimum recommended buffer size for sorting.
Declaration
public const long MIN_BUFFER_SIZE_MB = 32
Field Value
Type | Description |
---|---|
long |
Properties
Comparer
Returns the comparer in use to sort entries
Declaration
public IComparer<BytesRef> Comparer { get; }
Property Value
Type | Description |
---|---|
IComparer<BytesRef> |
DefaultTempDir
Returns the default temporary directory. By default, the System's temp folder.
Declaration
public static string DefaultTempDir { get; }
Property Value
Type | Description |
---|---|
string |
Methods
Sort(FileInfo, FileInfo)
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).
Declaration
public OfflineSorter.SortInfo Sort(FileInfo input, FileInfo output)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | input | |
FileInfo | output |
Returns
Type | Description |
---|---|
OfflineSorter.SortInfo |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sort(FileStream, FileStream)
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).
Declaration
public OfflineSorter.SortInfo Sort(FileStream input, FileStream output)
Parameters
Type | Name | Description |
---|---|---|
FileStream | input | The input stream. Must be both seekable and readable. |
FileStream | output | The output stream. Must be seekable and writable. |
Returns
Type | Description |
---|---|
OfflineSorter.SortInfo |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
input is not readable.
-or-
output is not writable.
|
ArgumentException |
|