public class ExternalRefSorter extends java.lang.Object implements BytesRefSorter, java.io.Closeable
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ExternalRefSorter.ByteSequenceIterator
Iterate over byte refs in a file.
|
Modifier and Type | Field and Description |
---|---|
private IndexOutput |
input |
private java.lang.String |
sortedFileName |
private OfflineSorter |
sorter |
private OfflineSorter.ByteSequencesWriter |
writer |
Constructor and Description |
---|
ExternalRefSorter(OfflineSorter sorter)
Will buffer all sequences to a temporary file and then sort (all on-disk).
|
Modifier and Type | Method and Description |
---|---|
void |
add(BytesRef utf8)
Adds a single suggestion entry (possibly compound with its bucket).
|
void |
close()
Removes any written temporary files.
|
private void |
closeWriter() |
java.util.Comparator<BytesRef> |
getComparator()
Comparator used to determine the sort order of entries.
|
BytesRefIterator |
iterator()
Sorts the entries added in
BytesRefSorter.add(BytesRef) and returns
an iterator over all sorted entries. |
private final OfflineSorter sorter
private OfflineSorter.ByteSequencesWriter writer
private IndexOutput input
private java.lang.String sortedFileName
public ExternalRefSorter(OfflineSorter sorter) throws java.io.IOException
java.io.IOException
public void add(BytesRef utf8) throws java.io.IOException
BytesRefSorter
add
in interface BytesRefSorter
java.io.IOException
- If an I/O exception occurs.public BytesRefIterator iterator() throws java.io.IOException
BytesRefSorter
BytesRefSorter.add(BytesRef)
and returns
an iterator over all sorted entries.iterator
in interface BytesRefSorter
java.io.IOException
- If an I/O exception occurs.private void closeWriter() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public java.util.Comparator<BytesRef> getComparator()
BytesRefSorter
getComparator
in interface BytesRefSorter