phelps.io
public class DiskHash extends Object
Performance is biased toward an access pattern of many reads, some writes, few deletions.
To do: data space recycling, database dump, separate constructors for create and open new, automatic compression (java.util.zip.Deflater) and encryption (RC4) with flags to constructor.
Version: $Revision: 1.11 $ $Date: 2003/06/01 08:09:25 $
See Also: jdbm
UNKNOWN: Sleepycat Software for a commercial, supported version of gdbm, with Java bindings and ACID properties
Field Summary | |
---|---|
static long | NO_RECORD |
Constructor Summary | |
---|---|
DiskHash(String filename, int keyblocksize)
Open disk hash on passed file.
| |
DiskHash(String filename) |
Method Summary | |
---|---|
void | close()
Hash must be closed.
|
boolean | exists(String key) |
void | flush() Write pending key and data changes to disk. |
byte[] | get(String key)
Return data at given key, or null if no such key. |
byte[] | get(String key, byte[] b, int offset, int length) |
Iterator<String> | iterator() Returns Iterator over keys, in sorted order. |
Iterator<String> | iterator(String key1, String key2)
Returns Iterator over keys range from key1 to key2, inclusive.
|
void | optimize()
Optimize for space by squeezing out holes in the data stream which were created by overriding data with shorter data.
|
void | optimizeAtomic(KeyStore newkey, DataStore keydata) |
void | put(String key, byte[] data, int offset, int length)
Save data at given key.
|
void | put(String key, byte[] data) |
void | remove(String key) Remove/delete key and associated data. |
Parameters: keyblocksize indirectly determines the number of keys per node, and thus the depth of tree and number of disk accesses it takes to locate the key's value.
Throws: IOException
null
if no such key.