public class TrieReader extends Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
TrieReader.DataType
Defines what data type is being read from a given buffer.
|
| Modifier and Type | Field and Description |
|---|---|
private int |
_bufferIndex
The index of the buffer that _position is pointed at.
|
private ArrayList<MappedByteBuffer> |
_buffers
Buffers mapped to the files channel.
|
private long |
_globalPosition |
private long |
_position
Logical position of the data needed in the file.
|
private long |
_start
The start position of the tree in the trie file.
|
private FileChannel |
_triFile
The File Channel linked to the trie data.
|
| Constructor and Description |
|---|
TrieReader(FileChannel reader)
Creates the class by creating multiple ByteBuffers that can be read from.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Clears the ByteBuffers and closes the File Channel.
|
private byte |
getNextByte()
Gets the MappedByteBuffer for that this class is currently positioned on,
automatically incrementing position and changing buffer if required.
|
long |
getPos()
Returns the current logical position value.
|
private byte[] |
getValue(TrieReader.DataType dataType)
Reads a certain data type from the file e.g.
|
byte |
readByte() |
byte[] |
readBytes(int length) |
int |
readInt()
Read an signed integer from the file at the current location.
|
long |
readLong()
Read an signed long from the file at the current location.
|
long |
readLong(long position)
Read an signed long from the file at a specified location.
|
short |
readUByte()
Read an Unsigned byte from the file at the current location.
|
short |
readUByte(long position)
Read an Unsigned byte from the file at a specified location.
|
long |
readUInt()
Read an Unsigned integer from the file at the current location.
|
int |
readUShort()
Read an Unsigned short from the file at the current location.
|
int |
readUShort(long position)
Read an Unsigned short from the file at a specified location.
|
void |
setPos(long position)
Sets the logical position in the file.
|
private ArrayList<MappedByteBuffer> _buffers
private final FileChannel _triFile
private final long _start
private long _position
private int _bufferIndex
private long _globalPosition
public TrieReader(FileChannel reader) throws IOException
reader - File channel to read from.IOExceptionpublic long getPos()
public void setPos(long position)
position - position value.public short readUByte()
public short readUByte(long position)
position - Position to read from.public int readUShort()
public int readUShort(long position)
position - Position to read from.public long readUInt()
throws IOException
IOExceptionpublic int readInt()
throws IOException
IOExceptionpublic long readLong()
IOExceptionpublic long readLong(long position)
throws IOException
position - Position to read from.IOExceptionprivate byte getNextByte()
public byte readByte()
public byte[] readBytes(int length)
private byte[] getValue(TrieReader.DataType dataType)
dataType - Type of data to read.public void close()
throws IOException
IOException