Class ExternalRefSorter
- java.lang.Object
-
- org.apache.lucene.search.suggest.fst.ExternalRefSorter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BytesRefSorter
public class ExternalRefSorter extends java.lang.Object implements BytesRefSorter, java.io.Closeable
Builds and iterates over sequences stored on disk.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classExternalRefSorter.ByteSequenceIteratorIterate over byte refs in a file.
-
Field Summary
Fields Modifier and Type Field Description private IndexOutputinputprivate java.lang.StringsortedFileNameprivate OfflineSortersorterprivate OfflineSorter.ByteSequencesWriterwriter
-
Constructor Summary
Constructors Constructor Description ExternalRefSorter(OfflineSorter sorter)Will buffer all sequences to a temporary file and then sort (all on-disk).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(BytesRef utf8)Adds a single suggestion entry (possibly compound with its bucket).voidclose()Removes any written temporary files.private voidcloseWriter()java.util.Comparator<BytesRef>getComparator()Comparator used to determine the sort order of entries.BytesRefIteratoriterator()Sorts the entries added inBytesRefSorter.add(BytesRef)and returns an iterator over all sorted entries.
-
-
-
Field Detail
-
sorter
private final OfflineSorter sorter
-
writer
private OfflineSorter.ByteSequencesWriter writer
-
input
private IndexOutput input
-
sortedFileName
private java.lang.String sortedFileName
-
-
Constructor Detail
-
ExternalRefSorter
public ExternalRefSorter(OfflineSorter sorter) throws java.io.IOException
Will buffer all sequences to a temporary file and then sort (all on-disk).- Throws:
java.io.IOException
-
-
Method Detail
-
add
public void add(BytesRef utf8) throws java.io.IOException
Description copied from interface:BytesRefSorterAdds a single suggestion entry (possibly compound with its bucket).- Specified by:
addin interfaceBytesRefSorter- Throws:
java.io.IOException- If an I/O exception occurs.
-
iterator
public BytesRefIterator iterator() throws java.io.IOException
Description copied from interface:BytesRefSorterSorts the entries added inBytesRefSorter.add(BytesRef)and returns an iterator over all sorted entries.- Specified by:
iteratorin interfaceBytesRefSorter- Throws:
java.io.IOException- If an I/O exception occurs.
-
closeWriter
private void closeWriter() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionRemoves any written temporary files.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getComparator
public java.util.Comparator<BytesRef> getComparator()
Description copied from interface:BytesRefSorterComparator used to determine the sort order of entries.- Specified by:
getComparatorin interfaceBytesRefSorter
-
-