org.egothor.repository
Class BlobRepository

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

public class BlobRepository
extends java.lang.Object
implements DataRepository

BLOB repository stores huge data objects which cannot be effectively stored within other repository types. This special repository assumes:

Storage method: Data objects are saved in separate files, one for each object, within a given directory. To bypass the file system limits, a directory structure is constructed to contain up to 16MAX_DIR_ENTRIES_HEX files or directories.

Author:
galambos

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.egothor.repository.DataRepository
DataRepository.TupleSequence
 
Constructor Summary
BlobRepository(java.lang.String root, boolean useGzip)
           
 
Method Summary
 int acceptInto(long key, File blob)
           
 int addItem(long key, byte[] document, int length)
          Adds another document into the repository.
 int addItem(long key, DataInput in)
           
 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

BlobRepository

public BlobRepository(java.lang.String root,
                      boolean useGzip)
Method Detail

acceptInto

public int acceptInto(long key,
                      File blob)

addItem

public int addItem(long key,
                   DataInput in)

addItem

public int addItem(long key,
                   byte[] document,
                   int length)
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()
Description copied from interface: DataRepository
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

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