public class DBHash
extends java.lang.Object
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
Modifier and Type | Field and Description |
---|---|
boolean |
DEBUG |
long |
numQueries |
long |
stepCount |
static java.lang.String |
V1_FILE_ID |
Constructor and Description |
---|
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. |
DBHash(java.io.File hashFile,
int hashLength,
int cacheSize,
boolean readOnly)
Create/open a hashed index file with a hashtable of
hashLength
entries and a cache with a maximum of cacheSize records. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the random-access file.
|
void |
copyTo(java.io.File newJDBFile)
Method to backup the DBHash file to given named file.
|
void |
deleteAllRecords()
Delete every record in the file.
|
boolean |
deleteValue(byte[] key)
Delete the specified key and it's associated value from the database.
|
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.
|
void |
finalize() |
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) |
void |
setValue(byte[] key,
byte[] data)
Set the data value associated with the specified key.
|
public static final java.lang.String V1_FILE_ID
public long stepCount
public long numQueries
public boolean DEBUG
public 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
public DBHash(java.io.File hashFile, int hashLength, int cacheSize, boolean readOnly) throws java.lang.Exception
hashLength
entries and a cache with a maximum of cacheSize
records.java.lang.Exception
public void deleteAllRecords() throws java.lang.Exception
java.lang.Exception
public void close() throws java.lang.Exception
java.lang.Exception
public void finalize()
finalize
in class java.lang.Object
public final byte[] getValue(byte[] key) throws java.lang.Exception
java.lang.Exception
public final void setValue(byte[] key, byte[] data) throws java.lang.Exception
java.lang.Exception
public final boolean deleteValue(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 void copyTo(java.io.File newJDBFile) throws java.lang.Exception
newJDBFile
- File to copy this database tojava.lang.Exception
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception