org.gcube.indexmanagement.bdbwrapper
Class BDBWrapper

java.lang.Object
  extended by org.gcube.indexmanagement.bdbwrapper.BDBWrapper
All Implemented Interfaces:
ForwardIndex

public class BDBWrapper
extends Object
implements ForwardIndex

Class to store key and value pairs in the berkeley database


Field Summary
static String EXACT
           
static String[] SupportedRelations
           
static String WITHIN
           
 
Constructor Summary
BDBWrapper(String baseDir, String dbName, String resourceId, String[] keyNames, ForwardIndexType[] dbT)
          Provides the ability to store simple key-value pairs.
 
Method Summary
 void close()
          Closes this BDBWrapper by deleting the whole index
protected  void finalize()
           
 String getAllDec(String keyName, ResultType resType)
          Gets all.
 String getAllInc(String keyName, ResultType resType)
          Gets all.
 String getEQ(String keyName, Object key, ResultType resType)
          Gets the values where the key equals the input key.
 String getGE(String keyName, Object keyGE, ResultType resType)
          Gets values >= keyGE.
 String getGEandLE(String keyName, Object keyGE, Object keyLE, ResultType resType)
          Gets keyGE <= values <= keyLE
 String getGEandLT(String keyName, Object keyGE, Object keyLT, ResultType resType)
          Gets keyGE <= values < keyLT
 String getGT(String keyName, Object keyGT, ResultType resType)
          Gets keyGT < values
 String getGTandLE(String keyName, Object keyGT, Object keyLE, ResultType resType)
          Gets keyGT < values <= keyLE
 String getGTandLT(String keyName, Object keyGT, Object keyLT, ResultType resType)
          Gets keyGT < values < keyLT
 String getLE(String keyName, Object keyLE, ResultType resType)
          Gets values <= keyLE
 String getLT(String keyName, Object keyLT, ResultType resType)
          Gets values < keyLT
 int getNumDocs()
          Returns the number of stored documents(values)
 int[] getNumKeys()
          Returns the number of entries for each indexed field
 long getPackageSize()
          Returns the package size that determines how keys and values are multiplexed.
static ArrayList<String> getPresentableFromXML(String fieldsString, String colID, String colLang)
          Parses the XML containing the presentable information for a document (FORMAT: fieldvalue ) and returns an array containing the unique field names.
static HashMap<String,String> getPresentationFieldsFromXML(String fieldsString)
          Parses the XML containing the presentable information for a document (FORMAT: fieldvalue ) and returns a map containing the field name - value pairs.
 void 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.
 URI processQuery(String cqlQuery, ArrayList<String> presentable, ArrayList<String> searchable, RRadaptor adaptor)
           
 void setPackageSize(long packageSize)
          Sets the package size that determines how keys and values are multiplexed.
 void updateIndex()
          Updates the index.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXACT

public static final String EXACT
See Also:
Constant Field Values

WITHIN

public static final String WITHIN
See Also:
Constant Field Values

SupportedRelations

public static String[] SupportedRelations
Constructor Detail

BDBWrapper

public BDBWrapper(String baseDir,
                  String dbName,
                  String resourceId,
                  String[] keyNames,
                  ForwardIndexType[] dbT)
           throws IndexException
Provides the ability to store simple key-value pairs.

Parameters:
baseDir - The base directory - it must exist before the call to the constructor
dbName - The name of the database to be used
resourceId - The ID of the collection to be indexed
keyNames - The names of the keys. One index is created for each keyName
dbT - The corresponding type of each keyName(int,string or float,string or string,string date,string).
Throws:
IndexException - - in case of failure.
Method Detail

getNumDocs

public int getNumDocs()
Returns the number of stored documents(values)

Returns:
the number of stored documents

getNumKeys

public int[] getNumKeys()
Returns the number of entries for each indexed field

Returns:
array with the number of entries for each indexed field

getPackageSize

public long getPackageSize()
Returns the package size that determines how keys and values are multiplexed. Package size refers to how many key values will be sent before the corresponding values are sent.

Returns:
package size

setPackageSize

public void setPackageSize(long packageSize)
Sets the package size that determines how keys and values are multiplexed. Package size refers to how many key values will be sent before the corresponding values are sent.

Parameters:
packageSize - - package size

close

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

Throws:
Exception

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getEQ

public String getEQ(String keyName,
                    Object key,
                    ResultType resType)
             throws IndexException
Gets the values where the key equals the input key.

Specified by:
getEQ in interface ForwardIndex
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(String keyName,
                    Object keyGE,
                    ResultType resType)
             throws IndexException
Gets values >= keyGE.

Specified by:
getGE in interface ForwardIndex
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(String keyName,
                    Object keyGT,
                    ResultType resType)
             throws IndexException
Gets keyGT < values

Specified by:
getGT in interface ForwardIndex
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(String keyName,
                    Object keyLE,
                    ResultType resType)
             throws IndexException
Gets values <= keyLE

Specified by:
getLE in interface ForwardIndex
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(String keyName,
                    Object keyLT,
                    ResultType resType)
             throws IndexException
Gets values < keyLT

Specified by:
getLT in interface ForwardIndex
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(String keyName,
                         Object keyGE,
                         Object keyLE,
                         ResultType resType)
                  throws IndexException
Gets keyGE <= values <= keyLE

Specified by:
getGEandLE in interface ForwardIndex
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(String keyName,
                         Object keyGE,
                         Object keyLT,
                         ResultType resType)
                  throws IndexException
Gets keyGE <= values < keyLT

Specified by:
getGEandLT in interface ForwardIndex
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(String keyName,
                         Object keyGT,
                         Object keyLE,
                         ResultType resType)
                  throws IndexException
Gets keyGT < values <= keyLE

Specified by:
getGTandLE in interface ForwardIndex
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(String keyName,
                         Object keyGT,
                         Object keyLT,
                         ResultType resType)
                  throws IndexException
Gets keyGT < values < keyLT

Specified by:
getGTandLT in interface ForwardIndex
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(String keyName,
                        ResultType resType)
                 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(String keyName,
                        ResultType resType)
                 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.

processQuery

public URI processQuery(String cqlQuery,
                        ArrayList<String> presentable,
                        ArrayList<String> searchable,
                        RRadaptor adaptor)
                 throws gr.uoa.di.madgik.grs.writer.GRS2WriterException
Throws:
gr.uoa.di.madgik.grs.writer.GRS2WriterException

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 void 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.
Throws:
IndexException - - in case of error.

getPresentationFieldsFromXML

public static HashMap<String,String> getPresentationFieldsFromXML(String fieldsString)
Parses the XML containing the presentable information for a document (FORMAT: fieldvalue ) and returns a map containing the field name - value pairs.

Parameters:
fieldsString - - XML containing the presentable information for a document
Returns:
HashMap containing the field pairs

getPresentableFromXML

public static ArrayList<String> getPresentableFromXML(String fieldsString,
                                                      String colID,
                                                      String colLang)
Parses the XML containing the presentable information for a document (FORMAT: fieldvalue ) and returns an array containing the unique field names.

Parameters:
fieldsString - - XML containing the presentable information for a document
Returns:
ArrayList containing the unique field names

updateIndex

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

Throws:
IndexException - - in case of error


Copyright © 2012. All Rights Reserved.