org.egothor.store
Class Documents

java.lang.Object
  extended by org.egothor.store.Documents

public class Documents
extends java.lang.Object

Documents implements a documents DB structure on disc. The structure consists of two files: the first one is used as an index, and the second one as a data store. When you want to read the element with key uid the algorithm works as follows:

  1. Read an offset of the element: firstfile.seek( uid*SIZEOFOFFSET ); offset = firstfile.read();
  2. Read the element: secondfile.seek( offset ); object = secondfile.readTheObject();

Author:
Leo Galambos

Constructor Summary
Documents(java.lang.String location)
          Constructor for the Documents object.
 
Method Summary
 void close()
          Closes the structure.
 void destroy()
          Destroy this data structure.
static void destroy(java.lang.String location)
           
 DocumentData elementAt(long uid)
          Return the element with the given uid.
protected  void finalize()
          Close this structure and attempt garbage collection.
 IMetaReader getReader(Bitmap map)
          Open this structure for sequential reading.
 long size()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Documents

public Documents(java.lang.String location)
          throws java.io.IOException
Constructor for the Documents object. Open the structure in the given directory. Three files are created, all with the name doc , with varying extensions depending on the file's function: information about removed elements is stored in doc.btm , the first file of offsets in doc.idx , and the second file with elements data in doc.dta .

Parameters:
location - the location where the files will be created
Throws:
java.io.IOException - if an I/O error occurs
Method Detail

getReader

public IMetaReader getReader(Bitmap map)
Open this structure for sequential reading.

Returns:
an IndexDataReader

destroy

public void destroy()
Destroy this data structure. First, it calls close(). Then it removes these files from the directory where the structure is stored: bitmap, idocs, docs.


destroy

public static void destroy(java.lang.String location)

elementAt

public DocumentData elementAt(long uid)
Return the element with the given uid.

Parameters:
uid - the key of the element to fetch
Returns:
the element

close

public void close()
Closes the structure. It calls #commit and then it closes both data files (idocs and docs).

See Also:
Documents(String)

finalize

protected void finalize()
                 throws java.lang.Throwable
Close this structure and attempt garbage collection.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - you never know what might happen!

size

public long size()