org.egothor.repository
Class Berkeley

java.lang.Object
  extended by org.egothor.repository.Berkeley
All Implemented Interfaces:
DataRepository

public class Berkeley
extends java.lang.Object
implements DataRepository

Author:
Leo Galambos

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.egothor.repository.DataRepository
DataRepository.TupleSequence
 
Constructor Summary
Berkeley(java.lang.String filename)
           
 
Method Summary
 int addItem(long key, byte[] d0, int l0)
          Adds another document into the repository.
 void close()
          Closes the repository.
 void destroy()
          Destroy the repository.
 DataInputStream elementAt(long key, int revision)
          Retrieves a data block.
 DataRepository.TupleSequence elements()
          The tuples are [long:uid;int:rev;Object:DataInputStream].
 void flush()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Berkeley

public Berkeley(java.lang.String filename)
         throws com.sleepycat.db.DatabaseException,
                java.io.FileNotFoundException
Throws:
com.sleepycat.db.DatabaseException
java.io.FileNotFoundException
Method Detail

close

public void close()
Description copied from interface: DataRepository
Closes the repository.

Specified by:
close in interface DataRepository

destroy

public void destroy()
Description copied from interface: DataRepository
Destroy the repository.

Specified by:
destroy in interface DataRepository

addItem

public int addItem(long key,
                   byte[] d0,
                   int l0)
Description copied from interface: DataRepository
Adds another document into the repository. If the implementation is able to recognize whether the incoming data block is still the same (as the existing in the repository), it would discard the insertion request and return 0 as the signal of no-op.

Specified by:
addItem in interface DataRepository
Returns:
revision number (0 iff unchanged) or -1 when fails

elementAt

public DataInputStream elementAt(long key,
                                 int revision)
Description copied from interface: DataRepository
Retrieves a data block.

Specified by:
elementAt in interface DataRepository
Parameters:
key - the key of the block
revision - revision number of the block, 0 is used for the latest (current) revision
Returns:
null if the revision is not available (or the key is unknown)

elements

public DataRepository.TupleSequence elements()
The tuples are [long:uid;int:rev;Object:DataInputStream].

Specified by:
elements in interface DataRepository

flush

public void flush()
Specified by:
flush in interface DataRepository