net.obsearch.storage.bdb
Class BDBFactoryJe

java.lang.Object
  extended by net.obsearch.storage.bdb.BDBFactoryJe
All Implemented Interfaces:
OBStoreFactory

public final class BDBFactoryJe
extends Object
implements OBStoreFactory

BDBFactory generates an environment in the given directory, and creates databases as OBSearch requests.

Author:
Arnoldo Jose Muller Molina

Constructor Summary
BDBFactoryJe(File directory)
          Creates a new factory that will be based in the given directory.
 
Method Summary
static byte bytesToByte(byte[] value)
           
static double bytesToDouble(byte[] value)
           
static float bytesToFloat(byte[] value)
           
static int bytesToInt(byte[] value)
           
static long bytesToLong(byte[] value)
           
static short bytesToShort(byte[] value)
           
static byte[] byteToBytes(byte value)
           
 void close()
          Close the factory.
protected  com.sleepycat.je.DatabaseConfig createDefaultDatabaseConfig()
          Creates a default database configuration.
 OBStore<TupleBytes> createOBStore(String name, OBStorageConfig config)
          Creates a generic OBStore.
 OBStoreByte createOBStoreByte(String name, OBStorageConfig config)
          Creates an OBStoreByte whose key is based on bytes.
 OBStoreDouble createOBStoreDouble(String name, OBStorageConfig config)
          Creates an OBStoreDouble whose key is based on doubles.
 OBStoreFloat createOBStoreFloat(String name, OBStorageConfig config)
          Creates an OBStoreFloat whose key is based on floats.
 OBStoreInt createOBStoreInt(String name, OBStorageConfig config)
          Creates an OBStoreInt whose key is based on ints.
 OBStoreLong createOBStoreLong(String name, OBStorageConfig config)
          Creates an OBStoreLong whose key is based on longs.
 OBStoreShort createOBStoreShort(String name, OBStorageConfig config)
          Creates an OBStoreShort whose key is based on shorts.
 BigInteger deSerializeBigInteger(byte[] value)
          Creates a BigInteger of the given value.
 byte deSerializeByte(byte[] value)
          Creates a byte of the given value.
 double deSerializeDouble(byte[] value)
          Creates a double of the given value.
 float deSerializeFloat(byte[] value)
          Creates a float of the given value.
 int deSerializeInt(byte[] value)
          Creates a int of the given value.
 long deSerializeLong(byte[] value)
          Creates a long of the given value.
 short deSerializeShort(byte[] value)
          Creates a short of the given value.
static byte[] doubleToBytes(double value)
           
static byte[] floatToBytes(float value)
           
 String getFactoryLocation()
          Return the url where this factory is located.
static byte[] intToBytes(int value)
           
static byte[] longToBytes(long value)
           
 void removeOBStore(OBStore storage)
          Removes all indexes and structures related to the given storage device.
 byte[] serializeBigInteger(BigInteger value)
          Creates a binary representation of the given value.
 byte[] serializeByte(byte value)
          Creates a binary representation of the given value.
 byte[] serializeDouble(double value)
          Creates a binary representation of the given value.
 byte[] serializeFloat(float value)
          Creates a binary representation of the given value.
 byte[] serializeInt(int value)
          Creates a binary representation of the given value.
 byte[] serializeLong(long value)
          Creates a binary representation of the given value.
 byte[] serializeShort(short value)
          Creates a binary representation of the given value.
static byte[] shortToBytes(short value)
           
 Object stats()
          Return a stats object that is to be printed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BDBFactoryJe

public BDBFactoryJe(File directory)
             throws IOException,
                    com.sleepycat.je.DatabaseException,
                    OBStorageException
Creates a new factory that will be based in the given directory.

Parameters:
directory - The directory where the Berkeley DB files will be stored.
Throws:
IOException - If the given directory does not exist.
com.sleepycat.je.DatabaseException
OBStorageException
Method Detail

getFactoryLocation

public String getFactoryLocation()
Description copied from interface: OBStoreFactory
Return the url where this factory is located.

Specified by:
getFactoryLocation in interface OBStoreFactory

close

public void close()
           throws OBStorageException
Description copied from interface: OBStoreFactory
Close the factory. All opened OBStores must be closed before this method is called.

Specified by:
close in interface OBStoreFactory
Throws:
OBStorageException - if something goes wrong with the underlying storage system.

createOBStore

public OBStore<TupleBytes> createOBStore(String name,
                                         OBStorageConfig config)
                                  throws OBStorageException
Description copied from interface: OBStoreFactory
Creates a generic OBStore.

Specified by:
createOBStore in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStore ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

createDefaultDatabaseConfig

protected com.sleepycat.je.DatabaseConfig createDefaultDatabaseConfig()
Creates a default database configuration.

Returns:
default database configuration.

removeOBStore

public void removeOBStore(OBStore storage)
                   throws OBStorageException
Description copied from interface: OBStoreFactory
Removes all indexes and structures related to the given storage device.

Specified by:
removeOBStore in interface OBStoreFactory
Parameters:
storage - The storage device to remove.
Throws:
OBStorageException - If something goes wrong with the delete operation.

createOBStoreByte

public OBStoreByte createOBStoreByte(String name,
                                     OBStorageConfig config)
                              throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreByte whose key is based on bytes.

Specified by:
createOBStoreByte in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreByte ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeByte

public byte[] serializeByte(byte value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeByte in interface OBStoreFactory

deSerializeByte

public byte deSerializeByte(byte[] value)
Description copied from interface: OBStoreFactory
Creates a byte of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeByte in interface OBStoreFactory

byteToBytes

public static byte[] byteToBytes(byte value)

bytesToByte

public static byte bytesToByte(byte[] value)

createOBStoreShort

public OBStoreShort createOBStoreShort(String name,
                                       OBStorageConfig config)
                                throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreShort whose key is based on shorts.

Specified by:
createOBStoreShort in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreShort ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeShort

public byte[] serializeShort(short value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeShort in interface OBStoreFactory

deSerializeShort

public short deSerializeShort(byte[] value)
Description copied from interface: OBStoreFactory
Creates a short of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeShort in interface OBStoreFactory

shortToBytes

public static byte[] shortToBytes(short value)

bytesToShort

public static short bytesToShort(byte[] value)

createOBStoreInt

public OBStoreInt createOBStoreInt(String name,
                                   OBStorageConfig config)
                            throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreInt whose key is based on ints.

Specified by:
createOBStoreInt in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreInt ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeInt

public byte[] serializeInt(int value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeInt in interface OBStoreFactory

deSerializeInt

public int deSerializeInt(byte[] value)
Description copied from interface: OBStoreFactory
Creates a int of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeInt in interface OBStoreFactory

intToBytes

public static byte[] intToBytes(int value)

bytesToInt

public static int bytesToInt(byte[] value)

createOBStoreLong

public OBStoreLong createOBStoreLong(String name,
                                     OBStorageConfig config)
                              throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreLong whose key is based on longs.

Specified by:
createOBStoreLong in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreLong ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeLong

public byte[] serializeLong(long value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeLong in interface OBStoreFactory

deSerializeLong

public long deSerializeLong(byte[] value)
Description copied from interface: OBStoreFactory
Creates a long of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeLong in interface OBStoreFactory

longToBytes

public static byte[] longToBytes(long value)

bytesToLong

public static long bytesToLong(byte[] value)

createOBStoreFloat

public OBStoreFloat createOBStoreFloat(String name,
                                       OBStorageConfig config)
                                throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreFloat whose key is based on floats.

Specified by:
createOBStoreFloat in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreFloat ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeFloat

public byte[] serializeFloat(float value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeFloat in interface OBStoreFactory

deSerializeFloat

public float deSerializeFloat(byte[] value)
Description copied from interface: OBStoreFactory
Creates a float of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeFloat in interface OBStoreFactory

floatToBytes

public static byte[] floatToBytes(float value)

bytesToFloat

public static float bytesToFloat(byte[] value)

createOBStoreDouble

public OBStoreDouble createOBStoreDouble(String name,
                                         OBStorageConfig config)
                                  throws OBStorageException
Description copied from interface: OBStoreFactory
Creates an OBStoreDouble whose key is based on doubles.

Specified by:
createOBStoreDouble in interface OBStoreFactory
Parameters:
name - The name of the database.
Returns:
An OBStoreDouble ready to be used.
Throws:
OBStorageException - If the DB cannot be created.

serializeDouble

public byte[] serializeDouble(double value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeDouble in interface OBStoreFactory

deSerializeDouble

public double deSerializeDouble(byte[] value)
Description copied from interface: OBStoreFactory
Creates a double of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeDouble in interface OBStoreFactory

doubleToBytes

public static byte[] doubleToBytes(double value)

bytesToDouble

public static double bytesToDouble(byte[] value)

serializeBigInteger

public byte[] serializeBigInteger(BigInteger value)
Description copied from interface: OBStoreFactory
Creates a binary representation of the given value. The value must be returned in such a way that it can be sorted with bytes.

Specified by:
serializeBigInteger in interface OBStoreFactory

deSerializeBigInteger

public BigInteger deSerializeBigInteger(byte[] value)
Description copied from interface: OBStoreFactory
Creates a BigInteger of the given value. Only the required bytes are taken from the input.

Specified by:
deSerializeBigInteger in interface OBStoreFactory

stats

public Object stats()
             throws OBStorageException
Description copied from interface: OBStoreFactory
Return a stats object that is to be printed

Specified by:
stats in interface OBStoreFactory
Throws:
OBStorageException - if something goes wrong with the underlying storage system.


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