Class ExternalRefSorter
java.lang.Object
org.apache.lucene.search.suggest.fst.ExternalRefSorter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BytesRefSorter
An implementation of a
BytesRefSorter
that allows appending BytesRef
s to an
OfflineSorter
and returns a Closeable
ExternalRefSorter.ByteSequenceIterator
that iterates
over sequences stored on disk.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Iterates overBytesRef
s in a file, closes the reader when the iterator is exhausted. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExternalRefSorter
(OfflineSorter sorter) Will buffer all sequences to a temporary file and then sort (all on-disk). -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a single suggestion entry (possibly compound with its bucket).void
close()
Close the writer and remove any temporary files.private void
Close the writer but leave any sorted output for iteration.Comparator used to determine the sort order of entries.iterator()
Sorts the entries added inBytesRefSorter.add(BytesRef)
and returns an iterator over all sorted entries.
-
Field Details
-
sorter
-
writer
-
tempOutput
-
sortedOutput
-
-
Constructor Details
-
ExternalRefSorter
Will buffer all sequences to a temporary file and then sort (all on-disk).- Throws:
IOException
-
-
Method Details
-
add
Description copied from interface:BytesRefSorter
Adds a single suggestion entry (possibly compound with its bucket).- Specified by:
add
in interfaceBytesRefSorter
- Throws:
IOException
- If an I/O exception occurs.
-
iterator
Description copied from interface:BytesRefSorter
Sorts the entries added inBytesRefSorter.add(BytesRef)
and returns an iterator over all sorted entries.- Specified by:
iterator
in interfaceBytesRefSorter
- Returns:
- Returns a
ExternalRefSorter.ByteSequenceIterator
that implementsBytesRefIterator
but is alsoCloseable
, ensuring any temporary resources are cleaned up if the iterator is either exhausted or closed. - Throws:
IOException
- If an I/O exception occurs.
-
closeWriter
Close the writer but leave any sorted output for iteration.- Throws:
IOException
-
close
Close the writer and remove any temporary files.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getComparator
Description copied from interface:BytesRefSorter
Comparator used to determine the sort order of entries.- Specified by:
getComparator
in interfaceBytesRefSorter
- Returns:
- Return the
Comparator
of theOfflineSorter
used to sort byte sequences.
-