public final class Heap extends HeapModifier implements BLOB
HeapReader.entries, HeapReader.entry
BLOB.Reducer, BLOB.Rewriter
Modifier and Type | Field and Description |
---|---|
private java.util.SortedMap<byte[],byte[]> |
buffer |
private int |
buffermax |
private int |
buffersize |
Constructor and Description |
---|
Heap(java.io.File heapFile,
int keylength,
ByteOrder ordering,
int buffermax)
create a heap file: a arbitrary number of BLOBs, indexed by an access key
The heap file will be indexed upon initialization.
|
Modifier and Type | Method and Description |
---|---|
private void |
add(byte[] key,
byte[] blob)
add a BLOB to the heap: this adds the blob always to the end of the file
|
void |
clear()
clears the content of the database
|
void |
close() |
void |
close(boolean writeIDX)
close the BLOB table
|
boolean |
containsKey(byte[] key)
test if a key is in the heap file.
|
void |
delete(byte[] key)
remove a BLOB
|
void |
finalize() |
void |
flushBuffer()
flush the buffer completely
this is like adding all elements of the buffer, but it needs only one IO access
|
byte[] |
get(byte[] key)
read a blob from the heap
|
int |
getBuffermax() |
static void |
heaptest() |
void |
insert(byte[] key,
byte[] b)
write a whole byte array as BLOB to the table
|
CloneableIterator<byte[]> |
keys(boolean up,
boolean rotating)
iterator over all keys
|
CloneableIterator<byte[]> |
keys(boolean up,
byte[] firstKey)
iterate over all keys
|
long |
length()
retrieve the size of the database
|
long |
length(byte[] key)
retrieve the size of the BLOB
|
static void |
main(java.lang.String[] args) |
private static java.util.Map<java.lang.String,java.lang.String> |
map(java.lang.String a,
java.lang.String b) |
static void |
maptest() |
private boolean |
putToGap(byte[] key,
byte[] b) |
int |
size()
the number of BLOBs in the heap
|
reduce, replace, shrinkWithGapsAtEnd
checkKey, deleteFingerprint, fingerprintFileHash, first, firstKey, get, isEmpty, keylength, last, lastKey, location, mem, name, normalizeKey, normalizeKey, optimize, ordering
private java.util.SortedMap<byte[],byte[]> buffer
private int buffersize
private final int buffermax
public Heap(java.io.File heapFile, int keylength, ByteOrder ordering, int buffermax) throws java.io.IOException
heapFile
- keylength
- ordering
- java.io.IOException
public int size()
size
in interface BLOB
size
in class HeapReader
public boolean containsKey(byte[] key)
containsKey
in interface BLOB
containsKey
in class HeapReader
key
- private void add(byte[] key, byte[] blob) throws java.io.IOException
key
- blob
- java.io.IOException
SpaceExceededException
public void flushBuffer() throws java.io.IOException
java.io.IOException
SpaceExceededException
public byte[] get(byte[] key) throws java.io.IOException, SpaceExceededException
get
in interface BLOB
get
in class HeapReader
key
- java.io.IOException
SpaceExceededException
public long length(byte[] key) throws java.io.IOException
length
in interface BLOB
length
in class HeapReader
key
- java.io.IOException
public void clear() throws java.io.IOException
clear
in interface BLOB
clear
in class HeapModifier
java.io.IOException
public void close(boolean writeIDX)
close
in interface BLOB
close
in class HeapModifier
public void close()
close
in class HeapModifier
public void finalize()
finalize
in class HeapModifier
public int getBuffermax()
public void insert(byte[] key, byte[] b) throws java.io.IOException
insert
in interface BLOB
insert
in class HeapModifier
key
- the primary keyb
- java.io.IOException
SpaceExceededException
SpaceExceededException
private boolean putToGap(byte[] key, byte[] b) throws java.io.IOException, SpaceExceededException
java.io.IOException
SpaceExceededException
public void delete(byte[] key) throws java.io.IOException
delete
in interface BLOB
delete
in class HeapModifier
key
- the primary keyjava.io.IOException
public CloneableIterator<byte[]> keys(boolean up, boolean rotating) throws java.io.IOException
keys
in interface BLOB
keys
in class HeapReader
up
- rotating
- java.io.IOException
public CloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws java.io.IOException
keys
in interface BLOB
keys
in class HeapReader
up
- firstKey
- java.io.IOException
public long length()
BLOB
length
in interface BLOB
length
in class HeapReader
public static void heaptest()
private static java.util.Map<java.lang.String,java.lang.String> map(java.lang.String a, java.lang.String b)
public static void maptest()
public static void main(java.lang.String[] args)