org.gcube.indexmanagement.jdbmwrapper
Class JdbmWrapper

java.lang.Object
  extended by org.gcube.indexmanagement.jdbmwrapper.JdbmWrapper

public class JdbmWrapper
extends Object

Class to store key and value pairs in the jdbm database


Nested Class Summary
static class JdbmWrapper.DbTypeEnum
          The enum forward index types datebase type.
 
Constructor Summary
JdbmWrapper(String treeDir, String dbName, String treeName, JdbmWrapper.DbTypeEnum dbT)
          Provides the ability to store simple key-value pairs.
 
Method Summary
 void close()
          Closes this jdbmWrapper by deleting the whole index
 void deletePairInDb(Object key)
          Deletes a key and value pair in the the tree.
 String getAllDec(boolean bKeysOnly)
          Gets all.
 String getAllInc(boolean bKeysOnly)
          Gets all.
 String getEQ(Object key, boolean bKeysOnly)
          Gets the values where the key equals the input key.
 String getGE(Object keyGE, boolean bKeysOnly)
          Gets values >= keyGE.
 String getGEandLE(Object keyGE, Object keyLE, boolean bKeysOnly)
          Gets keyGE <= values <= keyLE
 String getGEandLT(Object keyGE, Object keyLT, boolean bKeysOnly)
          Gets keyGE <= values < keyLT
 String getGT(Object keyGT, boolean bKeysOnly)
          Gets keyGT < values
 String getGTandLE(Object keyGT, Object keyLE, boolean bKeysOnly)
          Gets keyGT < values <= keyLE
 String getGTandLT(Object keyGT, Object keyLT, boolean bKeysOnly)
          Gets keyGT < values < keyLT
 String getLE(Object keyLE, boolean bKeysOnly)
          Gets values <= keyLE
 String getLT(Object keyLT, boolean bKeysOnly)
          Gets values < keyLT
 void insertPairInDb(Object key, Object value)
          Insert a key and value pair in the the tree.
 void insertRowSet(String rowset)
          Inserts tuples in a rowset into the tree, parsing the values from a String.
static void main(String[] args)
          Test main.
 int mergeAddition(File inputIndex)
          Receives the file with rowsets that is to be merged into the index.
 int mergeDeletion(File deletionFile)
          THIS METHOD IS NEVER CALLED IN FORWARD INDEX.
 void updateIndex()
          Updates the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbmWrapper

public JdbmWrapper(String treeDir,
                   String dbName,
                   String treeName,
                   JdbmWrapper.DbTypeEnum dbT)
            throws IndexException
Provides the ability to store simple key-value pairs.

Parameters:
treeDir - The base directory
dbName - The nameof the database
treeName - The name of the tree
dbT - The type of DB (int,string or float,string or string,string date,string).
Throws:
IndexException - - in case of failure.
Method Detail

close

public void close()
           throws Exception
Closes this jdbmWrapper by deleting the whole index

Throws:
Exception

insertPairInDb

public void insertPairInDb(Object key,
                           Object value)
                    throws IndexException
Insert a key and value pair in the the tree.

Parameters:
key - - the tuple key.
value - - the tuple value.
Throws:
IndexException - - when IOException is received.

deletePairInDb

public void deletePairInDb(Object key)
                    throws IndexException
Deletes a key and value pair in the the tree.

Parameters:
key - - the tuple key.
value - - the tuple value.
Throws:
IndexException - - when IOException is received.

insertRowSet

public void insertRowSet(String rowset)
                  throws IndexException
Inserts tuples in a rowset into the tree, parsing the values from a String. Deletes tuples in a rowset from the tree, parsing the values from a String.

Parameters:
rowset - - the rowset containing the tuples
Throws:
IndexException - - when parsing goes bonk.

getEQ

public String getEQ(Object key,
                    boolean bKeysOnly)
             throws IndexException
Gets the values where the key equals the input key.

Parameters:
key - - The equality key for the search
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGE

public String getGE(Object keyGE,
                    boolean bKeysOnly)
             throws IndexException
Gets values >= keyGE.

Parameters:
keyGE - - the key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGT

public String getGT(Object keyGT,
                    boolean bKeysOnly)
             throws IndexException
Gets keyGT < values

Parameters:
keyGT - - The lower exclusive bound key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getLE

public String getLE(Object keyLE,
                    boolean bKeysOnly)
             throws IndexException
Gets values <= keyLE

Parameters:
keyLE - - The upper inclusive bound key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getLT

public String getLT(Object keyLT,
                    boolean bKeysOnly)
             throws IndexException
Gets values < keyLT

Parameters:
keyLT - - The upper exclusive bound key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGEandLE

public String getGEandLE(Object keyGE,
                         Object keyLE,
                         boolean bKeysOnly)
                  throws IndexException
Gets keyGE <= values <= keyLE

Parameters:
keyGE - - The lower inclusive bound
keyLE - - The upper inclusive bound
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGEandLT

public String getGEandLT(Object keyGE,
                         Object keyLT,
                         boolean bKeysOnly)
                  throws IndexException
Gets keyGE <= values < keyLT

Parameters:
keyGE - - The lower inclusive bound key
keyLT - - The upper exclusive bound key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGTandLE

public String getGTandLE(Object keyGT,
                         Object keyLE,
                         boolean bKeysOnly)
                  throws IndexException
Gets keyGT < values <= keyLE

Parameters:
keyGT - - The lower exclusive bound
keyLE - - The upper inclusive bound
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getGTandLT

public String getGTandLT(Object keyGT,
                         Object keyLT,
                         boolean bKeysOnly)
                  throws IndexException
Gets keyGT < values < keyLT

Parameters:
keyGT - - The lower exclusive bound key
keyLT - - The upper exclusive bound key
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getAllDec

public String getAllDec(boolean bKeysOnly)
                 throws IndexException
Gets all.

Parameters:
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

getAllInc

public String getAllInc(boolean bKeysOnly)
                 throws IndexException
Gets all.

Parameters:
bKeysOnly - return only keys, or full tuples?
Returns:
String - The EPR of the result set containing the result.
Throws:
IndexException - - when IOException is received.

mergeDeletion

public int mergeDeletion(File deletionFile)
                  throws IndexException
THIS METHOD IS NEVER CALLED IN FORWARD INDEX. Merge deletion is used to update the index with documents to be deleted.

Parameters:
deletionFile - - the file with the content to delete .
Throws:
IndexException - - in case of failure.

mergeAddition

public int mergeAddition(File inputIndex)
                  throws IndexException
Receives the file with rowsets that is to be merged into the index.

Parameters:
inputIndex - - The file with rowsets that is merged into the index.
Returns:
- number of added documents.
Throws:
IndexException - - in case of error.

updateIndex

public void updateIndex()
                 throws IndexException
Updates the index. NOT USED IN THE FORWARDINDEX

Throws:
IndexException - - in case of error

main

public static void main(String[] args)
Test main.

Parameters:
args - - the array of arguments.


Copyright © 2013. All Rights Reserved.