BLOB.Reducer, BLOB.Rewriter
Modifier and Type | Field and Description |
---|---|
private BLOB |
backend |
private java.util.TreeMap<byte[],byte[]> |
buffer |
private long |
bufferlength |
private static byte[] |
gzipMagic |
private long |
maxbufferlength |
private static byte[] |
plainMagic |
Constructor and Description |
---|
Compressor(BLOB backend,
long buffersize) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
clears the content of the database
|
void |
close(boolean writeIDX)
close the BLOB table
|
private static byte[] |
compress(byte[] b) |
private static byte[] |
compressAddMagic(byte[] b) |
boolean |
containsKey(byte[] key)
check if a specific key is in the database
|
private static byte[] |
decompress(byte[] b) |
void |
delete(byte[] key)
remove a BLOB
|
void |
flushAll() |
private boolean |
flushOne() |
byte[] |
get(byte[] key)
retrieve the whole BLOB from the table
|
byte[] |
get(java.lang.Object key) |
private void |
initBuffer() |
void |
insert(byte[] key,
byte[] b)
write a whole byte array as BLOB to the table
|
boolean |
isEmpty()
ask if the BLOB is empty
|
java.util.Iterator<byte[]> |
iterator() |
int |
keylength()
ask for the length of the primary key
|
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
|
private static byte[] |
markWithPlainMagic(byte[] b) |
long |
mem()
calculate the memory in RAM that the BLOB occupies
|
java.lang.String |
name()
return a name of the BLOB; can be the file name
|
void |
optimize()
trim the index of the database: this releases memory not currently used
|
ByteOrder |
ordering()
return the underlying odering
|
int |
reduce(byte[] key,
BLOB.Reducer reducer)
a reduce method is the same as the replace.
|
private int |
removeFromQueues(byte[] key) |
int |
replace(byte[] key,
BLOB.Rewriter rewriter)
replace an existing entry in the BLOB with a new entry
this method is similar to put, but it is necessary that a blob entry existed before
and contains an entry of same size or bigger than the new entry.
|
int |
size()
ask for the number of entries
|
private static byte[] gzipMagic
private static byte[] plainMagic
private final BLOB backend
private java.util.TreeMap<byte[],byte[]> buffer
private long bufferlength
private final long maxbufferlength
public Compressor(BLOB backend, long buffersize)
public long mem()
BLOB
public void optimize()
BLOB
public java.lang.String name()
BLOB
public void clear() throws java.io.IOException
BLOB
private void initBuffer()
public ByteOrder ordering()
BLOB
public void close(boolean writeIDX)
BLOB
private static byte[] compress(byte[] b)
private static byte[] compressAddMagic(byte[] b)
private static byte[] markWithPlainMagic(byte[] b)
private static byte[] decompress(byte[] b)
public byte[] get(byte[] key) throws java.io.IOException, SpaceExceededException
BLOB
get
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException
public boolean containsKey(byte[] key)
BLOB
containsKey
in interface BLOB
key
- the primary keypublic int keylength()
BLOB
public long length()
BLOB
public long length(byte[] key) throws java.io.IOException
BLOB
private int removeFromQueues(byte[] key)
public void insert(byte[] key, byte[] b) throws java.io.IOException
BLOB
public void delete(byte[] key) throws java.io.IOException
BLOB
public int size()
BLOB
public boolean isEmpty()
BLOB
public CloneableIterator<byte[]> keys(boolean up, boolean rotating) throws java.io.IOException
BLOB
public CloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws java.io.IOException
BLOB
public java.util.Iterator<byte[]> iterator()
iterator
in interface java.lang.Iterable<byte[]>
private boolean flushOne()
public void flushAll()
public int replace(byte[] key, BLOB.Rewriter rewriter) throws java.io.IOException, SpaceExceededException
BLOB
replace
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException
public int reduce(byte[] key, BLOB.Reducer reducer) throws java.io.IOException, SpaceExceededException
BLOB
reduce
in interface BLOB
key
- the primary keyjava.io.IOException
SpaceExceededException