public final class Records
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer |
private int |
buffercount
number of entries in buffer
|
private static int |
maxWriteBuffer
stay below hard disc cache (is that necessary?)
|
private java.io.RandomAccessFile |
raf |
protected int |
recordsize
number of bytes in one record
|
private java.io.File |
tablefile |
private byte[] |
zero |
Constructor and Description |
---|
Records(java.io.File tablefile,
int recordsize) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] b,
int start) |
private void |
clean(long index) |
void |
cleanLast() |
void |
cleanLast(byte[] b,
int start) |
private void |
cleanLast0() |
private void |
cleanLast0(byte[] b,
int start)
this is like
clean(this.size() - 1, b, start); |
void |
clear() |
void |
close() |
void |
deleteOnExit() |
java.io.File |
filename() |
private long |
filesize() |
static void |
fixTableSize(java.io.File tablefile,
long recordsize) |
protected void |
flushBuffer()
write buffer to end of file
|
void |
get(long index,
byte[] b,
int start) |
private int |
inBuffer(long index,
long filesize)
checks if the index is inside the buffer
|
private static boolean |
isClean(byte[] b,
int offset,
int length) |
private boolean |
isClean(long index) |
static void |
main(java.lang.String[] args)
main - writes some data and checks the tables size (with time measureing)
|
void |
put(long index,
byte[] b,
int start) |
long |
size() |
static long |
tableSize(java.io.File tablefile,
long recordsize) |
private java.io.RandomAccessFile raf
private final java.io.File tablefile
protected final int recordsize
private int buffercount
private byte[] buffer
private final byte[] zero
private static final int maxWriteBuffer
public void clear()
public static final long tableSize(java.io.File tablefile, long recordsize) throws java.io.IOException
tablefile
- recordsize
- java.io.IOException
public static final void fixTableSize(java.io.File tablefile, long recordsize) throws java.io.IOException
java.io.IOException
public final long size() throws java.io.IOException
java.io.IOException
public final java.io.File filename()
private final long filesize() throws java.io.IOException
java.io.IOException
private final int inBuffer(long index, long filesize) throws java.io.IOException
index
- java.io.IOException
protected final void flushBuffer()
public final void close()
public final void get(long index, byte[] b, int start) throws java.io.IOException
index
- record which should be readb
- destination arraystart
- offset in b to store datajava.io.IOException
public final void put(long index, byte[] b, int start) throws java.io.IOException
java.io.IOException
public final void add(byte[] b, int start) throws java.io.IOException
java.io.IOException
private static final boolean isClean(byte[] b, int offset, int length)
private final boolean isClean(long index) throws java.io.IOException
java.io.IOException
private final void clean(long index) throws java.io.IOException
index
- java.io.IOException
clean(long, byte[], int)
public final void cleanLast(byte[] b, int start) throws java.io.IOException
b
- start
- java.io.IOException
clean(long, byte[], int)
private final void cleanLast0(byte[] b, int start) throws java.io.IOException
clean(this.size() - 1, b, start);
b
- start
- java.io.IOException
clean(long, byte[], int)
public final void cleanLast() throws java.io.IOException
java.io.IOException
clean(long, byte[], int)
private final void cleanLast0() throws java.io.IOException
java.io.IOException
public final void deleteOnExit()
public static void main(java.lang.String[] args)
args
-