org.gcube.indexmanagement.lucenewrapper
Class LuceneGenerator

java.lang.Object
  extended by org.gcube.indexmanagement.lucenewrapper.LuceneGenerator
All Implemented Interfaces:
IndexGenerator

public class LuceneGenerator
extends Object
implements IndexGenerator

An IndexGenerator implementation responsible for creating and updating a Lucene index.


Constructor Summary
LuceneGenerator(String baseIndexDir, String deletionDir)
          A constructor which sets the base directory for Index directories, and the directory in which to store deletion files.
 
Method Summary
 void abort()
          Deletes inserted rowsets since last commit()
 void close()
          Frees any resources used for updating indexes if any.
 void closeIndex()
          Closes the index committing any uncommitted insertions
 void commit()
          Commits inserted rowsets
 void createIndex(String indexName, FullTextIndexType idxType, boolean forceCreate)
          Creates a new index
 File deleteDocuments(String[] documentIDs)
          Deletes the listed documents both from the local storage and the main index
 int deleteDocumentsLocally(String[] documentIDs)
          Deletes the listed documents from the local storage
 void deleteIndex()
          Deletes the entire index with all it's inserted rowsets.
 long getCommittedFileSize()
          Returns the size of the committed files
 long getIndexFileSize()
          Shows the current file size of the index
 long getUnCommittedFileSize()
          Returns the size of the uncommitted files
 int insertRowSet(String rowsetXML)
          Inserts rowset of supported a supported indexType.
 int mergeDeletionFile(File deletionFile)
          Deletes the documents from the file from the index
 int mergeIndex(File inputIndex)
          Merges the named index into the open index
 void openIndex(String indexName)
          Opens the index for insertion of rowsets
 void setIndexType(FullTextIndexType idxType)
          Updates the Index' state object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneGenerator

public LuceneGenerator(String baseIndexDir,
                       String deletionDir)
A constructor which sets the base directory for Index directories, and the directory in which to store deletion files.

Parameters:
baseIndexDir - - The base directory for Index directories.
deletionDir - - The directory in which to store deletion files.
Method Detail

createIndex

public void createIndex(String indexName,
                        FullTextIndexType idxType,
                        boolean forceCreate)
                 throws IndexException
Creates a new index

Specified by:
createIndex in interface IndexGenerator
Parameters:
indexName - - name of the index
idxType - - the IndexType of the index to create
Throws:
IndexException - - an error creating the index to create

openIndex

public void openIndex(String indexName)
               throws IndexException
Opens the index for insertion of rowsets

Specified by:
openIndex in interface IndexGenerator
Parameters:
indexName - name of the index
Throws:
IndexException - - an error opening the index

setIndexType

public void setIndexType(FullTextIndexType idxType)
                  throws IndexException
Updates the Index' state object

Specified by:
setIndexType in interface IndexGenerator
Throws:
IndexException - - an error setting the indexType

getIndexFileSize

public long getIndexFileSize()
                      throws IndexException
Shows the current file size of the index

Specified by:
getIndexFileSize in interface IndexGenerator
Throws:
IndexException - - an error deleting documents

abort

public void abort()
           throws IndexException
Deletes inserted rowsets since last commit()

Specified by:
abort in interface IndexGenerator
Throws:
IndexException - - an error aborting

commit

public void commit()
            throws IndexException
Commits inserted rowsets

Specified by:
commit in interface IndexGenerator
Throws:
IndexException - - an error committing

getCommittedFileSize

public long getCommittedFileSize()
                          throws IndexException
Returns the size of the committed files

Specified by:
getCommittedFileSize in interface IndexGenerator
Throws:
IndexException - - an error getting the fileSize

getUnCommittedFileSize

public long getUnCommittedFileSize()
                            throws IndexException
Returns the size of the uncommitted files

Specified by:
getUnCommittedFileSize in interface IndexGenerator
Throws:
IndexException - - an error getting the fileSize

mergeIndex

public int mergeIndex(File inputIndex)
               throws IndexException
Merges the named index into the open index

Specified by:
mergeIndex in interface IndexGenerator
Throws:
IndexException - - an merging the index

mergeDeletionFile

public int mergeDeletionFile(File deletionFile)
                      throws IndexException
Deletes the documents from the file from the index

Specified by:
mergeDeletionFile in interface IndexGenerator
Parameters:
deletionFile - a file identifying the documents to delete
Throws:
IndexException - - an error merging the deletion file

closeIndex

public void closeIndex()
                throws IndexException
Closes the index committing any uncommitted insertions

Specified by:
closeIndex in interface IndexGenerator
Throws:
IndexException - - an error closing the Index

close

public void close()
Frees any resources used for updating indexes if any.

Specified by:
close in interface IndexGenerator

deleteIndex

public void deleteIndex()
                 throws IndexException
Deletes the entire index with all it's inserted rowsets.

Warning: there is no undelete method.

Specified by:
deleteIndex in interface IndexGenerator
Throws:
IndexException - - an error deleting documents

deleteDocuments

public File deleteDocuments(String[] documentIDs)
                     throws IndexException
Deletes the listed documents both from the local storage and the main index

Specified by:
deleteDocuments in interface IndexGenerator
Parameters:
documentIDs - - an array of the IDs of the documents to delete
Returns:
a new deletionFile
Throws:
IndexException - - an error deleting documents

deleteDocumentsLocally

public int deleteDocumentsLocally(String[] documentIDs)
                           throws IndexException
Deletes the listed documents from the local storage

Specified by:
deleteDocumentsLocally in interface IndexGenerator
Parameters:
documentIDs - - an array of the IDs of the documents to delete
Returns:
the number of documents deleted
Throws:
IndexException - - an error deleting documents

insertRowSet

public int insertRowSet(String rowsetXML)
                 throws IndexException
Inserts rowset of supported a supported indexType.

Specified by:
insertRowSet in interface IndexGenerator
Parameters:
rowsetXML - xml that contain data to insert
Returns:
number of handled documents
Throws:
IndexException - - an error inserting the ROWSET


Copyright © 2013. All Rights Reserved.