public class OfflineSorter extends Object
sort(String)
Modifier and Type | Class and Description |
---|---|
static class |
OfflineSorter.BufferSize
A bit more descriptive unit for constructors.
|
static class |
OfflineSorter.ByteSequencesReader
Utility class to read length-prefixed byte[] entries from an input.
|
static class |
OfflineSorter.ByteSequencesWriter
Utility class to emit length-prefixed byte[] entries to an output stream for sorting.
|
class |
OfflineSorter.SortInfo
Sort info (debugging mostly).
|
Modifier and Type | Field and Description |
---|---|
static long |
ABSOLUTE_MIN_SORT_BUFFER_SIZE
Absolute minimum required buffer size for sorting.
|
static Comparator<BytesRef> |
DEFAULT_COMPARATOR
Default comparator: sorts in binary (codepoint) order
|
static long |
GB
Convenience constant for gigabytes
|
static int |
MAX_TEMPFILES
Maximum number of temporary files before doing an intermediate merge.
|
static long |
MB
Convenience constant for megabytes
|
static long |
MIN_BUFFER_SIZE_MB
Minimum recommended buffer size for sorting.
|
Constructor and Description |
---|
OfflineSorter(Directory dir,
String tempFileNamePrefix)
Defaults constructor.
|
OfflineSorter(Directory dir,
String tempFileNamePrefix,
Comparator<BytesRef> comparator)
Defaults constructor with a custom comparator.
|
OfflineSorter(Directory dir,
String tempFileNamePrefix,
Comparator<BytesRef> comparator,
OfflineSorter.BufferSize ramBufferSize,
int maxTempfiles)
All-details constructor.
|
Modifier and Type | Method and Description |
---|---|
Comparator<BytesRef> |
getComparator()
Returns the comparator in use to sort entries
|
Directory |
getDirectory()
Returns the
Directory we use to create temp files. |
protected OfflineSorter.ByteSequencesReader |
getReader(ChecksumIndexInput in,
String name)
Subclasses can override to change how byte sequences are read from disk.
|
String |
getTempFileNamePrefix()
Returns the temp file name prefix passed to
Directory.createTempOutput(java.lang.String, java.lang.String, org.apache.lucene.store.IOContext) to generate temporary files. |
protected OfflineSorter.ByteSequencesWriter |
getWriter(IndexOutput out)
Subclasses can override to change how byte sequences are written to disk.
|
String |
sort(String inputFileName)
Sort input to a new temp file, returning its name.
|
protected String |
sortPartition(TrackingDirectoryWrapper trackingDir)
Sort a single partition in-memory.
|
public static final long MB
public static final long GB
public static final long MIN_BUFFER_SIZE_MB
public static final long ABSOLUTE_MIN_SORT_BUFFER_SIZE
public static final int MAX_TEMPFILES
public static final Comparator<BytesRef> DEFAULT_COMPARATOR
public OfflineSorter(Directory dir, String tempFileNamePrefix) throws IOException
IOException
OfflineSorter.BufferSize.automatic()
public OfflineSorter(Directory dir, String tempFileNamePrefix, Comparator<BytesRef> comparator) throws IOException
IOException
OfflineSorter.BufferSize.automatic()
public OfflineSorter(Directory dir, String tempFileNamePrefix, Comparator<BytesRef> comparator, OfflineSorter.BufferSize ramBufferSize, int maxTempfiles)
public String getTempFileNamePrefix()
Directory.createTempOutput(java.lang.String, java.lang.String, org.apache.lucene.store.IOContext)
to generate temporary files.public String sort(String inputFileName) throws IOException
IOException
protected String sortPartition(TrackingDirectoryWrapper trackingDir) throws IOException
IOException
protected OfflineSorter.ByteSequencesWriter getWriter(IndexOutput out) throws IOException
IOException
protected OfflineSorter.ByteSequencesReader getReader(ChecksumIndexInput in, String name) throws IOException
IOException
public Comparator<BytesRef> getComparator()
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.