net.obsearch.storage.bdb
Class BDBOBStoreJeInt

java.lang.Object
  extended by net.obsearch.storage.bdb.AbstractBDBOBStoreJe<TupleInt>
      extended by net.obsearch.storage.bdb.BDBOBStoreJeInt
All Implemented Interfaces:
net.obsearch.storage.OBStore<TupleInt>, OBStoreInt

public final class BDBOBStoreJeInt
extends AbstractBDBOBStoreJe<TupleInt>
implements OBStoreInt

BDBOBStoreInt is a wrapper for Berkeley indexes that assumes that keys are ints and values are byte[].

Author:
Arnoldo Jose Muller Molina

Nested Class Summary
 
Nested classes/interfaces inherited from class net.obsearch.storage.bdb.AbstractBDBOBStoreJe
AbstractBDBOBStoreJe.ByteArrayIterator, AbstractBDBOBStoreJe.CursorIterator<T>
 
Field Summary
 
Fields inherited from class net.obsearch.storage.bdb.AbstractBDBOBStoreJe
counter, db, sequence, stats
 
Constructor Summary
BDBOBStoreJeInt(String name, com.sleepycat.je.Database db, com.sleepycat.je.Database seq, OBStoreFactory fact, boolean duplicates)
          Builds a new Storage system by receiving a Berkeley DB database that uses ints as a primary indexing method.
 
Method Summary
 int bytesToValue(byte[] entry)
          Converts the value of the given entry into its primitive type.
 net.obsearch.OperationStatus delete(int key)
          Deletes the given key and its corresponding value from the database.
 byte[] getValue(int key)
          Returns the associated value for the given key.
 net.obsearch.storage.CloseIterator<TupleInt> processAll()
           
 net.obsearch.storage.CloseIterator<TupleInt> processRange(int low, int high)
          Process the given range of items (from low to high), including low and high.
 net.obsearch.storage.CloseIterator<TupleInt> processRangeNoDup(int low, int high)
           
 net.obsearch.storage.CloseIterator<TupleInt> processRangeReverse(int low, int high)
          Process the given range of items (from high to low), including low and high.
 net.obsearch.storage.CloseIterator<TupleInt> processRangeReverseNoDup(int low, int high)
           
 net.obsearch.OperationStatus put(int key, byte[] value)
          Inserts the key value pair.
 
Methods inherited from class net.obsearch.storage.bdb.AbstractBDBOBStoreJe
allowsDuplicatedData, close, delete, deleteAll, getFactory, getName, getReadStats, getStats, getValue, nextId, optimize, prepareBytes, processAllKeys, processRange, processRangeNoDup, processRangeReverse, processRangeReverseNoDup, put, putIfNew, setReadStats, 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
close, delete, deleteAll, getFactory, getName, getReadStats, getStats, getValue, nextId, optimize, prepareBytes, processRange, processRangeNoDup, processRangeReverse, processRangeReverseNoDup, put, setReadStats, size
 

Constructor Detail

BDBOBStoreJeInt

public BDBOBStoreJeInt(String name,
                       com.sleepycat.je.Database db,
                       com.sleepycat.je.Database seq,
                       OBStoreFactory fact,
                       boolean duplicates)
                throws com.sleepycat.je.DatabaseException
Builds a new Storage system by receiving a Berkeley DB database that uses ints as a primary indexing method.

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

delete

public net.obsearch.OperationStatus delete(int key)
                                    throws net.obsearch.exception.OBStorageException
Description copied from interface: OBStoreInt
Deletes the given key and its corresponding value from the database.

Specified by:
delete in interface OBStoreInt
Parameters:
key - The key that will be deleted.
Returns:
net.obsearch.OperationStatus.Status#OK if the key was found, otherwise, net.obsearch.OperationStatus.Status#NOT_EXISTS.
Throws:
net.obsearch.exception.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.

bytesToValue

public int bytesToValue(byte[] entry)
Converts the value of the given entry into its primitive type.

Specified by:
bytesToValue in interface OBStoreInt
Parameters:
entry - The place where we will put the entry.

getValue

public byte[] getValue(int key)
                throws IllegalArgumentException,
                       net.obsearch.exception.OBStorageException
Description copied from interface: OBStoreInt
Returns the associated value for the given key. If the underlying storage system can hold repeated keys, then an IllegalArgumentException is thrown.

Specified by:
getValue in interface OBStoreInt
Parameters:
key - the key that will be searched.
Returns:
the associated value for the given key.
Throws:
IllegalArgumentException - If the underlying storage system can hold multiple keys.
net.obsearch.exception.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.

put

public net.obsearch.OperationStatus put(int key,
                                        byte[] value)
                                 throws IllegalArgumentException,
                                        net.obsearch.exception.OBStorageException
Description copied from interface: OBStoreInt
Inserts the key value pair. If the key existed, it will be overwritten.

Specified by:
put in interface OBStoreInt
Parameters:
key - Key to insert
value - The value that the key will hold after this operation completes.
Returns:
net.obsearch.OperationStatus.Status#OK the record was inserted/updated successfully. net.obsearch.OperationStatus.Status#ERROR if the record could not be updated.
Throws:
net.obsearch.exception.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.
IllegalArgumentException

processRange

public net.obsearch.storage.CloseIterator<TupleInt> processRange(int low,
                                                                 int high)
                                                          throws net.obsearch.exception.OBStorageException
Description copied from interface: OBStoreInt
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.

Specified by:
processRange in interface OBStoreInt
Throws:
net.obsearch.exception.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

public net.obsearch.storage.CloseIterator<TupleInt> processRangeNoDup(int low,
                                                                      int high)
                                                               throws net.obsearch.exception.OBStorageException
Throws:
net.obsearch.exception.OBStorageException

processRangeReverse

public net.obsearch.storage.CloseIterator<TupleInt> processRangeReverse(int low,
                                                                        int high)
                                                                 throws net.obsearch.exception.OBStorageException
Description copied from interface: OBStoreInt
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.

Specified by:
processRangeReverse in interface OBStoreInt
Throws:
net.obsearch.exception.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

public net.obsearch.storage.CloseIterator<TupleInt> processRangeReverseNoDup(int low,
                                                                             int high)
                                                                      throws net.obsearch.exception.OBStorageException
Throws:
net.obsearch.exception.OBStorageException

processAll

public net.obsearch.storage.CloseIterator<TupleInt> processAll()
                                                        throws net.obsearch.exception.OBStorageException
Specified by:
processAll in interface net.obsearch.storage.OBStore<TupleInt>
Throws:
net.obsearch.exception.OBStorageException


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