net.obsearch.storage
Interface OBStore<T extends Tuple>

All Known Subinterfaces:
OBStoreByte, OBStoreDouble, OBStoreFloat, OBStoreInt, OBStoreLong, OBStoreShort
All Known Implementing Classes:
AbstractBDBOBStoreJe, AbstractTCOBStorage, BDBOBStoreJeByte, BDBOBStoreJeByteArray, BDBOBStoreJeDouble, BDBOBStoreJeFloat, BDBOBStoreJeInt, BDBOBStoreJeLong, BDBOBStoreJeShort, TCOBStorageBytesArray, TCOBStorageLong

public interface OBStore<T extends Tuple>

OBStore abstracts a generic storage system. The purpose of this class is to allow OBSearch to run on top of different storage systems (distributed, local, file system based, etc). The keys can be sorted, and range queries are possible. The base interface only allows operations on keys of arrays of bytes. Subclasses of this interface will provide specialized methods for Java's primitive types.

Author:
Arnoldo Jose Muller Molina

Method Summary
 void close()
          Closes the storage system.
 OperationStatus delete(byte[] key)
          Deletes the given key and its corresponding value from the database.
 void deleteAll()
          Deletes all the items in the storage system.
 OBStoreFactory getFactory()
          Return the factory associated to this storage device.
 String getName()
          Get the name of this storage system.
 hep.aida.bin.StaticBin1D getReadStats()
          Returns the read stats, it contains the avg # of bytes read the std deviation and also the number of reads.
 Object getStats()
          Return the stats of this object (to be printed for the user)
 byte[] getValue(byte[] key)
          Returns the associated value for the given key.
 long nextId()
          Returns the next id from the database (incrementing sequences).
 void optimize()
          Somehow optimizes the underlying storage representation.
 byte[] prepareBytes(byte[] in)
          Transform Bytes in a format that can be used by the underlying index.
 CloseIterator<T> processAll()
          Process all the elements in the DB.
 CloseIterator<TupleBytes> processRange(byte[] low, byte[] high)
          Process the given range of items (from low to high), including low and high.
 CloseIterator<TupleBytes> processRangeNoDup(byte[] low, byte[] high)
          Process the given range of items (from low to high), including low and high.
 CloseIterator<TupleBytes> processRangeReverse(byte[] low, byte[] high)
          Process the given range of items (from high to low), including low and high.
 CloseIterator<TupleBytes> processRangeReverseNoDup(byte[] low, byte[] high)
          Process the given range of items (from high to low), including low and high.
 OperationStatus put(byte[] key, byte[] value)
          Inserts the key value pair.
 void setReadStats(hep.aida.bin.StaticBin1D stats)
          Sets the stats object to the given stats.
 long size()
          Returns the number of elements in the database.
 

Method Detail

getName

String getName()
Get the name of this storage system.

Returns:
the name of this storage system.

getValue

byte[] getValue(byte[] key)
                throws IllegalArgumentException,
                       OBStorageException,
                       OBException
Returns the associated value for the given key. If the underlying storage system can hold multiple keys, then an IllegalArgumentException is thrown.

Parameters:
key - The key that will be searched.
Returns:
the associated value for the given key or null if the key could not be found.
Throws:
IllegalArgumentException - If the underlying storage system can hold multiple keys ( #allowsDuplicatedData() == true).
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
OBException
IOException

put

OperationStatus put(byte[] key,
                    byte[] value)
                    throws OBStorageException,
                           OBException
Inserts the key value pair. If the key existed, it will be overwritten.

Parameters:
key - Key to insert
value - The value that the key will hold after this operation completes.
Returns:
Status.OK the record was inserted/updated successfully. Status.ERROR if the record could not be updated.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
OBException

delete

OperationStatus delete(byte[] key)
                       throws OBStorageException,
                              IOException,
                              OBException
Deletes the given key and its corresponding value from the database. If the storage contains duplicates, then all the elements related to the key are removed.

Parameters:
key - The key that will be deleted.
Returns:
Status.OK if the key was found, otherwise, Status.NOT_EXISTS.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
OBException
IOException
IllegalAccessException
InstantiationException
OBException
OutOfRangeException

close

void close()
           throws OBStorageException
Closes the storage system.

Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
OBException
OBException

deleteAll

void deleteAll()
               throws OBStorageException
Deletes all the items in the storage system. Use with care!

Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
IllegalAccessException
InstantiationException
OBException
OutOfRangeException

size

long size()
          throws OBStorageException
Returns the number of elements in the database.

Returns:
The number of elements in the database.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.
OBException

nextId

long nextId()
            throws OBStorageException
Returns the next id from the database (incrementing sequences).

Returns:
The next id that can be inserted.
Throws:
OBStorageException

getReadStats

hep.aida.bin.StaticBin1D getReadStats()
Returns the read stats, it contains the avg # of bytes read the std deviation and also the number of reads.

Returns:

setReadStats

void setReadStats(hep.aida.bin.StaticBin1D stats)
Sets the stats object to the given stats. If null, then we stop storing the stats info.


getStats

Object getStats()
                throws OBException
Return the stats of this object (to be printed for the user)

Returns:
Throws:
OBException

processRange

CloseIterator<TupleBytes> processRange(byte[] low,
                                       byte[] high)
                                       throws OBStorageException
Process the given range of items (from low to high), including low and high. The TupleProcessor's process method will be called for each value found within the range.

Parameters:
low - lowest key value to return.
high - highest key value to return.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.

processRangeNoDup

CloseIterator<TupleBytes> processRangeNoDup(byte[] low,
                                            byte[] high)
                                            throws OBStorageException
Process the given range of items (from low to high), including low and high. The TupleProcessor's process method will be called for each value found within the range. No duplicate values will be returned.

Parameters:
low - lowest key value to return.
high - highest key value to return.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.

processRangeReverse

CloseIterator<TupleBytes> processRangeReverse(byte[] low,
                                              byte[] high)
                                              throws OBStorageException
Process the given range of items (from high to low), including low and high. The TupleProcessor's process method will be called for each value found within the range.

Parameters:
low - lowest key value to return.
high - highest key value to return.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.

processRangeReverseNoDup

CloseIterator<TupleBytes> processRangeReverseNoDup(byte[] low,
                                                   byte[] high)
                                                   throws OBStorageException
Process the given range of items (from high to low), including low and high. The TupleProcessor's process method will be called for each value found within the range. No duplicate values will be returned.

Parameters:
low - lowest key value to return.
high - highest key value to return.
Throws:
OBStorageException - If an exception occurs at the underlying storage system. You can query the exception to see more details regarding the nature of the error.

processAll

CloseIterator<T> processAll()
                                          throws OBStorageException,
                                                 OBException
Process all the elements in the DB. Useful for debugging.

Returns:
An iterator that goes through all the data in the DB.
Throws:
OBStorageException
OBException

getFactory

OBStoreFactory getFactory()
Return the factory associated to this storage device.


prepareBytes

byte[] prepareBytes(byte[] in)
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.`

optimize

void optimize()
              throws OBStorageException
Somehow optimizes the underlying storage representation.

Throws:
OBStorageException


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