public final class DataAccess
extends java.lang.Object
| Constructor and Description |
|---|
DataAccess(IOFile f)
Constructor, initializing the file reader.
|
| Modifier and Type | Method and Description |
|---|---|
long |
appendNums(int[] v)
Appends integers to the file in compressed form.
|
void |
close()
Closes the data access.
|
long |
cursor()
Returns the current file position.
|
void |
cursor(long p)
Sets the disk cursor.
|
void |
flush()
Flushes the buffered data.
|
long |
free(long pos,
int size)
Returns the offset to a free slot for writing an entry with the
specified length.
|
long |
length()
Returns the file length.
|
boolean |
more()
Checks if more bytes can be read.
|
byte |
read1()
Reads a byte value.
|
byte |
read1(long p)
Reads a byte value from the specified position.
|
int |
read4()
Reads an integer value.
|
int |
read4(long p)
Reads an integer value from the specified position.
|
long |
read5()
Reads a 5-byte value.
|
long |
read5(long p)
Reads a 5-byte value from the specified file offset.
|
byte[] |
readBytes(int n)
Reads a number of bytes.
|
byte[] |
readBytes(long p,
int l)
Reads a number of bytes from the specified offset.
|
int |
readNum()
Reads the next compressed number and returns it as integer.
|
int |
readNum(long p)
Reads a
Num value from disk. |
byte[] |
readToken()
Reads the next token from disk.
|
byte[] |
readToken(long p)
Reads a token from disk.
|
void |
write4(int v)
Writes an integer value to the current position.
|
void |
write4(long p,
int v)
Writes an integer value to the specified position.
|
void |
write5(long p,
long v)
Writes a 5-byte value to the specified position.
|
void |
writeNum(long p,
int v)
Write a value to the file.
|
void |
writeNums(long p,
int[] v)
Writes integers to the file in compressed form.
|
void |
writeToken(byte[] buf,
int offset,
int length)
Write a token to the file.
|
void |
writeToken(long p,
byte[] v)
Appends a value to the file and return it's offset.
|
public DataAccess(IOFile f) throws java.io.IOException
f - the file to be readjava.io.IOException - I/O Exceptionpublic void flush()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic void close()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic long cursor()
public long length()
public boolean more()
public byte read1(long p)
p - positionpublic byte read1()
public int read4(long p)
p - positionpublic int read4()
public long read5(long p)
p - positionpublic long read5()
public int readNum(long p)
Num value from disk.p - text positionpublic byte[] readToken(long p)
p - text positionpublic byte[] readToken()
public byte[] readBytes(long p,
int l)
p - positionl - lengthpublic byte[] readBytes(int n)
n - lengthpublic void cursor(long p)
p - read positionpublic int readNum()
public void write5(long p,
long v)
p - position in the filev - value to be writtenpublic void write4(long p,
int v)
p - write positionv - byte array to be appendedpublic void write4(int v)
v - value to be writtenpublic void writeNum(long p,
int v)
p - write positionv - value to be writtenpublic void writeNums(long p,
int[] v)
p - write positionv - integer valuespublic long appendNums(int[] v)
v - integer valuespublic void writeToken(long p,
byte[] v)
p - write positionv - byte array to be appendedpublic void writeToken(byte[] buf,
int offset,
int length)
buf - buffer containing the tokenoffset - offset in the buffer where the token startslength - token lengthpublic long free(long pos,
int size)
pos - original offsetsize - size of new text entry