net.obsearch.storage.bdb
Class AbstractBDBOBStoreJe<T extends net.obsearch.storage.Tuple>

java.lang.Object
  extended by net.obsearch.storage.bdb.AbstractBDBOBStoreJe<T>
All Implemented Interfaces:
net.obsearch.storage.OBStore<T>
Direct Known Subclasses:
BDBOBStoreJeByte, BDBOBStoreJeByteArray, BDBOBStoreJeDouble, BDBOBStoreJeFloat, BDBOBStoreJeInt, BDBOBStoreJeLong, BDBOBStoreJeShort

public abstract class AbstractBDBOBStoreJe<T extends net.obsearch.storage.Tuple>
extends Object
implements net.obsearch.storage.OBStore<T>

BDBOBStore is a storage abstraction for Berkeley DB. It is designed to work on byte array keys storing byte array values.

Author:
Arnoldo Jose Muller Molina

Nested Class Summary
protected  class AbstractBDBOBStoreJe.ByteArrayIterator
          Iterator used to process range results.
protected  class AbstractBDBOBStoreJe.CursorIterator<T>
          Base class used to iterate over cursors.
 
Field Summary
protected  com.sleepycat.je.Sequence counter
          Sequence counter
protected  com.sleepycat.je.Database db
          Berkeley DB database.
protected  com.sleepycat.je.Database sequence
          Database for sequences.
protected  hep.aida.bin.StaticBin1D stats
           
 
Constructor Summary
AbstractBDBOBStoreJe(String name, com.sleepycat.je.Database db, com.sleepycat.je.Database sequences, OBStoreFactory fact, boolean duplicates)
          Builds a new Storage system by receiving a Berkeley DB database.
 
Method Summary
 boolean allowsDuplicatedData()
           
 void close()
           
 net.obsearch.OperationStatus delete(byte[] key)
           
 void deleteAll()
           
 OBStoreFactory getFactory()
           
 String getName()
           
 hep.aida.bin.StaticBin1D getReadStats()
           
 Object getStats()
           
 byte[] getValue(byte[] key)
           
 long nextId()
          Returns the next id from the database (incrementing sequences).
 void optimize()
           
 byte[] prepareBytes(byte[] in)
           
 net.obsearch.storage.CloseIterator<byte[]> processAllKeys()
          Transform Bytes in a format that can be used by the underlying index.
 net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRange(byte[] low, byte[] high)
           
 net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeNoDup(byte[] low, byte[] high)
           
 net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeReverse(byte[] low, byte[] high)
           
 net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeReverseNoDup(byte[] low, byte[] high)
           
 net.obsearch.OperationStatus put(byte[] key, byte[] value)
           
 net.obsearch.OperationStatus putIfNew(byte[] key, byte[] value)
           
 void setReadStats(hep.aida.bin.StaticBin1D stats)
           
 long size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.obsearch.storage.OBStore
processAll
 

Field Detail

stats

protected hep.aida.bin.StaticBin1D stats

db

protected com.sleepycat.je.Database db
Berkeley DB database.


sequence

protected com.sleepycat.je.Database sequence
Database for sequences.


counter

protected com.sleepycat.je.Sequence counter
Sequence counter

Constructor Detail

AbstractBDBOBStoreJe

public AbstractBDBOBStoreJe(String name,
                            com.sleepycat.je.Database db,
                            com.sleepycat.je.Database sequences,
                            OBStoreFactory fact,
                            boolean duplicates)
                     throws com.sleepycat.je.DatabaseException
Builds a new Storage system by receiving a Berkeley DB database.

Parameters:
db - The database to be stored.
name - Name of the database.
sequences - Database used to store sequences.
Throws:
com.sleepycat.je.DatabaseException - if something goes wrong with the database.
Method Detail

getFactory

public OBStoreFactory getFactory()
Specified by:
getFactory in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

close

public void close()
           throws net.obsearch.exception.OBStorageException
Specified by:
close in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

delete

public net.obsearch.OperationStatus delete(byte[] key)
                                    throws net.obsearch.exception.OBStorageException
Specified by:
delete in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

deleteAll

public void deleteAll()
               throws net.obsearch.exception.OBStorageException
Specified by:
deleteAll in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

getName

public String getName()
Specified by:
getName in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

getValue

public byte[] getValue(byte[] key)
                throws IllegalArgumentException,
                       net.obsearch.exception.OBStorageException
Specified by:
getValue in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
IllegalArgumentException
net.obsearch.exception.OBStorageException

put

public net.obsearch.OperationStatus put(byte[] key,
                                        byte[] value)
                                 throws net.obsearch.exception.OBStorageException
Specified by:
put in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

putIfNew

public net.obsearch.OperationStatus putIfNew(byte[] key,
                                             byte[] value)
                                      throws net.obsearch.exception.OBStorageException
Throws:
net.obsearch.exception.OBStorageException

allowsDuplicatedData

public boolean allowsDuplicatedData()

processAllKeys

public net.obsearch.storage.CloseIterator<byte[]> processAllKeys()
                                                          throws net.obsearch.exception.OBStorageException
Transform Bytes in a format that can be used by the underlying index.

Parameters:
in - Input byte array
Returns:
transformed bytes ready to be sorted.`
Throws:
net.obsearch.exception.OBStorageException

prepareBytes

public byte[] prepareBytes(byte[] in)
Specified by:
prepareBytes in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

processRange

public net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRange(byte[] low,
                                                                                        byte[] high)
                                                                                 throws net.obsearch.exception.OBStorageException
Specified by:
processRange in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

processRangeNoDup

public net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeNoDup(byte[] low,
                                                                                             byte[] high)
                                                                                      throws net.obsearch.exception.OBStorageException
Specified by:
processRangeNoDup in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

processRangeReverse

public net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeReverse(byte[] low,
                                                                                               byte[] high)
                                                                                        throws net.obsearch.exception.OBStorageException
Specified by:
processRangeReverse in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

processRangeReverseNoDup

public net.obsearch.storage.CloseIterator<net.obsearch.storage.TupleBytes> processRangeReverseNoDup(byte[] low,
                                                                                                    byte[] high)
                                                                                             throws net.obsearch.exception.OBStorageException
Specified by:
processRangeReverseNoDup in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

size

public long size()
          throws net.obsearch.exception.OBStorageException
Specified by:
size in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Throws:
net.obsearch.exception.OBStorageException

optimize

public void optimize()
Specified by:
optimize in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

nextId

public long nextId()
            throws net.obsearch.exception.OBStorageException
Returns the next id from the database (incrementing sequences).

Specified by:
nextId in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>
Returns:
The next id that can be inserted.
Throws:
net.obsearch.exception.OBStorageException

getReadStats

public hep.aida.bin.StaticBin1D getReadStats()
Specified by:
getReadStats in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

setReadStats

public void setReadStats(hep.aida.bin.StaticBin1D stats)
Specified by:
setReadStats in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>

getStats

public Object getStats()
Specified by:
getStats in interface net.obsearch.storage.OBStore<T extends net.obsearch.storage.Tuple>


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.