Package org.apache.lucene.search.suggest
Class Sort.ByteSequencesReader
- java.lang.Object
-
- org.apache.lucene.search.suggest.Sort.ByteSequencesReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Enclosing class:
- Sort
public static class Sort.ByteSequencesReader extends java.lang.Object implements java.io.Closeable
Utility class to read length-prefixed byte[] entries from an input. Complementary toSort.ByteSequencesWriter
.
-
-
Constructor Summary
Constructors Constructor Description ByteSequencesReader(java.io.DataInput is)
Constructs a ByteSequencesReader from the provided DataInputByteSequencesReader(java.io.File file)
Constructs a ByteSequencesReader from the provided File
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the providedDataInput
if it isCloseable
.byte[]
read()
Reads the next entry and returns it if successful.boolean
read(BytesRef ref)
Reads the next entry into the providedBytesRef
.
-
-
-
Constructor Detail
-
ByteSequencesReader
public ByteSequencesReader(java.io.File file) throws java.io.IOException
Constructs a ByteSequencesReader from the provided File- Throws:
java.io.IOException
-
ByteSequencesReader
public ByteSequencesReader(java.io.DataInput is)
Constructs a ByteSequencesReader from the provided DataInput
-
-
Method Detail
-
read
public boolean read(BytesRef ref) throws java.io.IOException
Reads the next entry into the providedBytesRef
. The internal storage is resized if needed.- Returns:
- Returns
false
if EOF occurred when trying to read the header of the next sequence. Returnstrue
otherwise. - Throws:
java.io.EOFException
- if the file ends before the full sequence is read.java.io.IOException
-
read
public byte[] read() throws java.io.IOException
Reads the next entry and returns it if successful.- Returns:
- Returns
null
if EOF occurred before the next entry could be read. - Throws:
java.io.EOFException
- if the file ends before the full sequence is read.java.io.IOException
- See Also:
read(BytesRef)
-
close
public void close() throws java.io.IOException
Closes the providedDataInput
if it isCloseable
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-