|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.handle.jdb.RO_DBHash
public class RO_DBHash
Object used to store key/value pairs in a fast, persistent index. Uses a hashing algorithm (with configurable hash size) to locate records in the file quickly, and a memory cache (also with configurable size) to speed up access to heavily used records. Potential improvement: Currently the memory cache for is rather crude. If the cache gets over the configured size, *all* items are removed. It would probably be better if there were some sort of least-recently used algorithm or something. It may also be good to purge the cache asynchronously.
BC_REC_START Block Format: ----------------------------------------------------- | Block Code == BC_REC_START (1 byte) | | Key Length (4 bytes) | | Data Length (4 bytes) | | Next Record Ptr (8 bytes) | | [ Cont. Block Ptr (8 bytes) | | if ((KeyLen+DataLen) > (BlockSz-HeaderSz)) ] | | Data (BlockSz-HeaderSz bytes) | | ... | ----------------------------------------------------- BC_REC_CONT Block Format: ----------------------------------------------------- | Block Code == BC_REC_CONT (1 byte) | | Remainder Length (4 bytes) | | [ Cont. Block Ptr (8 bytes) | | if this is not the last continuation block ] | | Data | | ... | ----------------------------------------------------- BC_REC_UNUSED Block Format: ----------------------------------------------------- | Block Code == BC_REC_UNUSED (1 byte) | | Anything. (BlockSz-1 bytes) | ----------------------------------------------------- TODO: Create pack() method to compress file
Field Summary | |
---|---|
boolean |
DEBUG
|
static java.lang.String |
V1_FILE_ID
|
Constructor Summary | |
---|---|
RO_DBHash(java.io.File hashFile,
int hashLength,
int cacheSize)
Create/open a hashed index file with a hashtable of hashLength
entries and a cache with a maximum of cacheSize records. |
Method Summary | |
---|---|
void |
close()
Close the random-access file. |
void |
dumpDataStructure(java.io.PrintStream out)
Dump a human-readable display of all of the records in the table and cache. |
void |
dumpDepthGraph()
Display a crude text-based graph of the hash distribution. |
void |
dumpRecords(java.io.PrintStream out)
Dump all of the records in the table in hexadecimal format with the keys separated from the values by a colon. |
java.util.Enumeration |
getEnumerator()
Return an enumeration used to iterate over all of the records in the table. |
byte[] |
getValue(byte[] key)
Get the data value associated with the specified key. |
static void |
main(java.lang.String[] argv)
Main routine |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String V1_FILE_ID
public boolean DEBUG
Constructor Detail |
---|
public RO_DBHash(java.io.File hashFile, int hashLength, int cacheSize) throws java.lang.Exception
hashLength
entries and a cache with a maximum of cacheSize
records.
java.lang.Exception
Method Detail |
---|
public void close() throws java.lang.Exception
java.lang.Exception
public final byte[] getValue(byte[] key) throws java.lang.Exception
java.lang.Exception
public void dumpDepthGraph() throws java.lang.Exception
java.lang.Exception
public void dumpRecords(java.io.PrintStream out)
public java.util.Enumeration getEnumerator()
public void dumpDataStructure(java.io.PrintStream out)
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |