## grendel.storage.intertwingle
Class SimpleDB

    java.lang.Object
      |
      +--grendel.storage.intertwingle.BaseDB
            |
            +--grendel.storage.intertwingle.SimpleDB

public final class SimpleDB
extends grendel.storage.intertwingle.BaseDB

Simplistic implementation of a RDF-ish database. This is basically a massive hashtable hack. Almost certainly we shouldn't ship this, but it ought to be good enough to play with for a while.

Here's how it works:

There are five files. One is the "store", and it stores the data. All data is accessed via a hash table, so each entry in the store contains one or two pointers to other entries with the same hash. ("two" is in the case where there are two hash tables into the same data.)

The other four files are head pointers into the hashtable, for various hashes.

Random strings are stored in the store. They get hashed using String.hashCode(), the hash value is masked off to HASHMASK, and the first pointer to the hashtable appear in the "strhead" file. Each entry consists of a pointer to the next string with the same hashcode, and then a refcount, and then the UTF version of the string itself.

Assertions are stored in the store. Each assertion is three strings: name, slot, and value. The strings are first put into the store, and then the assertion is recorded by writing down the location of the strings. Each assertion is hashed twice: once by combining the name and slot, and once by combining the value and slot. So, each assertion records the next value for both hash tables, followed by the three string locations. So, each assertion costs 20 bytes on disk, not counting the string storage. The "head[]" files are the first pointers for each hashtable.

Finally, a free list of unused chunks in the store are kept. The "freehead" file points to the first free entry of a given size; each free entry points to the next free entry of the same size.

Constructor Summary
`SimpleDB(java.io.File f)`

Method Summary
`void` | `assert(java.lang.String name, java.lang.String slot, java.lang.String value)`
`void` | `dump(java.io.PrintStream out)`
`java.util.Enumeration` | `findAll(java.lang.String name, java.lang.String slot, boolean reverse)`
`java.lang.String` | `findFirst(java.lang.String name, java.lang.String slot, boolean reverse)`
`void` | `unassert(java.lang.String name, java.lang.String slot, java.lang.String value)`

Methods inherited from class grendel.storage.intertwingle.BaseDB
`isAsserted`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleDB

    public SimpleDB(java.io.File f)
             throws java.io.IOException

Method Detail

### assert

    public void assert(java.lang.String name,
                       java.lang.String slot,
                       java.lang.String value)
                throws java.io.IOException

### unassert

    public void unassert(java.lang.String name,
                         java.lang.String slot,
                         java.lang.String value)
                  throws java.io.IOException

### findFirst

    public java.lang.String findFirst(java.lang.String name,
                                      java.lang.String slot,
                                      boolean reverse)
                               throws java.io.IOException

### findAll

    public java.util.Enumeration findAll(java.lang.String name,
                                         java.lang.String slot,
                                         boolean reverse)
                                  throws java.io.IOException

### dump

    public void dump(java.io.PrintStream out)
              throws java.io.IOException