|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfiftyone.mobile.detection.readers.TrieReader
public class TrieReader
Due to the size of the Trie tree structure, the data cannot fit into a single ByteBuffer. Therefore, this class is used to wrap the file channel and and become logically one channel.
| Nested Class Summary | |
|---|---|
private static class |
TrieReader.DataType
Defines what data type is being read from a given buffer. |
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
TrieReader(FileChannel reader)
Creates the class by creating multiple ByteBuffers that can be read from. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private ArrayList<MappedByteBuffer> _buffers
private final FileChannel _triFile
private final long _start
private long _position
private int _bufferIndex
private long _globalPosition
| Constructor Detail |
|---|
public TrieReader(FileChannel reader)
throws IOException
reader - File channel to read from.
IOException| Method Detail |
|---|
public 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
IOException
public int readInt()
throws IOException
IOExceptionpublic long readLong()
IOException
public 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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||