org.compass.core.lucene.engine.store
Class DefaultLuceneSearchEngineStore

java.lang.Object
  extended by org.compass.core.lucene.engine.store.DefaultLuceneSearchEngineStore
All Implemented Interfaces:
LuceneSearchEngineStore

public class DefaultLuceneSearchEngineStore
extends Object
implements LuceneSearchEngineStore

Author:
kimchy

Constructor Summary
DefaultLuceneSearchEngineStore(LuceneSearchEngineFactory searchEngineFactory, CompassSettings settings, CompassMapping mapping)
           
 
Method Summary
 String[] calcSubIndexes(String[] subIndexes, String[] aliases)
          Returns the sub indexes that intersect with the given sub indexes and aliases provided.
 String[] calcSubIndexes(String[] subIndexes, String[] aliases, Class[] types)
          Returns the sub indexes the intersect with the given sub indexes and aliases provided.
 void cleanIndex(String subIndex)
          Cleans the sub index.
 void cleanIndex(String subContext, String subIndex)
           
 void close()
          Closes the store.
 void copyFrom(String subIndex, LuceneSearchEngineStore searchEngineStore)
          Copies the index from the given store into the current store.
 void copyFrom(String subContext, String subIndex, LuceneSearchEngineStore searchEngineStore)
          Copies the index from the given store into the current store.
 void createIndex()
          Creates the index (if it is already exists, delets it first).
 void createIndex(String subIndex)
           
 void createIndex(String subContext, String subIndex)
           
 void deleteIndex()
          Deletes the index.
 void deleteIndex(String subIndex)
          Deletes the index for the given sub index.
 void deleteIndex(String subContext, String subIndex)
          Deletes the index for the given sub context and sub index.
 String[] getAliasesBySubIndex(String subIndex)
          Returns the list of aliases that are mapped for a given sub index.
 String getDefaultSubContext()
          Returns the default sub context associated with this store.
 int getNumberOfAliasesBySubIndex(String subIndex)
          Returns the number of aliases that map to the given sub index.
 String[] getSubIndexes()
          Returns all the sub indexes defined within the store.
 boolean indexExists()
          Returns true if one of the sub indexes index does exists.
 boolean indexExists(String subIndex)
          Returns true if the sub index index does exists as a legal Lucene index.
 boolean indexExists(String subContext, String subIndex)
           
 String[] internalCalcSubIndexes(String[] subIndexes, String[] aliases, Class[] types, boolean poly)
           
 boolean isLocked()
          Returns true if any sub index is locked.
 boolean isLocked(String subIndex)
          Returns true if the sub index is locked (both Lucene write and commit locks).
 boolean isLocked(String subContext, String subIndex)
           
 boolean isUseCompoundFile()
          Should we use the compound file format or not.
 Directory openDirectory(String subIndex)
          Returns the directory that match the given sub index.
 Directory openDirectory(String subContext, String subIndex)
          Returns the directory that match the given sub index.
 void performScheduledTasks()
          Performs any scheduled tasks, managed by the index manager.
 String[] polyCalcSubIndexes(String[] subIndexes, String[] aliases, Class[] types)
          Returns the sub indexes that intersect with the given sub indexes, aliases and types.
 void registerEventListeners(SearchEngine searchEngine, SearchEngineEventManager eventManager)
          A callback to register event listeners when a SearchEngine is created.
 void releaseLock(String subIndex)
          Releases the lock for the given sub index.
 void releaseLock(String subContext, String subIndex)
           
 void releaseLocks()
          Releases all the locks on all the sub indexes.
 boolean requiresAsyncTransactionalContext()
          Returns true if a transaction needs to be started when performing operations with this store.
 boolean subIndexExists(String subIndex)
          Returns true if the sub index exists.
 String suggestedIndexDeletionPolicy()
          Returns the suggested index deletion policy for the given store.
 boolean supportsConcurrentCommits()
          Returns true if this store supprots concurrent commits.
 boolean supportsConcurrentOperations()
          Returns true if this store supports concurrent operations.
 String toString()
           
 boolean verifyIndex()
          Verify that the index exists.
 boolean verifyIndex(String subIndex)
           
 boolean verifyIndex(String subContext, String subIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultLuceneSearchEngineStore

public DefaultLuceneSearchEngineStore(LuceneSearchEngineFactory searchEngineFactory,
                                      CompassSettings settings,
                                      CompassMapping mapping)
Method Detail

close

public void close()
Description copied from interface: LuceneSearchEngineStore
Closes the store.

Specified by:
close in interface LuceneSearchEngineStore

performScheduledTasks

public void performScheduledTasks()
Description copied from interface: LuceneSearchEngineStore
Performs any scheduled tasks, managed by the index manager.

Specified by:
performScheduledTasks in interface LuceneSearchEngineStore

getAliasesBySubIndex

public String[] getAliasesBySubIndex(String subIndex)
Description copied from interface: LuceneSearchEngineStore
Returns the list of aliases that are mapped for a given sub index.

Specified by:
getAliasesBySubIndex in interface LuceneSearchEngineStore

getNumberOfAliasesBySubIndex

public int getNumberOfAliasesBySubIndex(String subIndex)
Description copied from interface: LuceneSearchEngineStore
Returns the number of aliases that map to the given sub index.

Specified by:
getNumberOfAliasesBySubIndex in interface LuceneSearchEngineStore

getSubIndexes

public String[] getSubIndexes()
Description copied from interface: LuceneSearchEngineStore
Returns all the sub indexes defined within the store.

Specified by:
getSubIndexes in interface LuceneSearchEngineStore

subIndexExists

public boolean subIndexExists(String subIndex)
Description copied from interface: LuceneSearchEngineStore
Returns true if the sub index exists.

Specified by:
subIndexExists in interface LuceneSearchEngineStore

calcSubIndexes

public String[] calcSubIndexes(String[] subIndexes,
                               String[] aliases,
                               Class[] types)
Description copied from interface: LuceneSearchEngineStore
Returns the sub indexes the intersect with the given sub indexes and aliases provided. The types are translated to aliases and retuned as well.

Specified by:
calcSubIndexes in interface LuceneSearchEngineStore

polyCalcSubIndexes

public String[] polyCalcSubIndexes(String[] subIndexes,
                                   String[] aliases,
                                   Class[] types)
Description copied from interface: LuceneSearchEngineStore
Returns the sub indexes that intersect with the given sub indexes, aliases and types. Types are translated to the matching aliases. Any extending aliases of the given aliases (or types) are added as well.

Specified by:
polyCalcSubIndexes in interface LuceneSearchEngineStore

internalCalcSubIndexes

public String[] internalCalcSubIndexes(String[] subIndexes,
                                       String[] aliases,
                                       Class[] types,
                                       boolean poly)

calcSubIndexes

public String[] calcSubIndexes(String[] subIndexes,
                               String[] aliases)
Description copied from interface: LuceneSearchEngineStore
Returns the sub indexes that intersect with the given sub indexes and aliases provided. If the sub indexes and aliases are null, return all the sub indexes.

Specified by:
calcSubIndexes in interface LuceneSearchEngineStore

openDirectory

public Directory openDirectory(String subIndex)
                        throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns the directory that match the given sub index.

Specified by:
openDirectory in interface LuceneSearchEngineStore
Throws:
SearchEngineException

openDirectory

public Directory openDirectory(String subContext,
                               String subIndex)
                        throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns the directory that match the given sub index.

Specified by:
openDirectory in interface LuceneSearchEngineStore
Throws:
SearchEngineException

indexExists

public boolean indexExists()
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if one of the sub indexes index does exists.

Specified by:
indexExists in interface LuceneSearchEngineStore
Throws:
SearchEngineException

indexExists

public boolean indexExists(String subIndex)
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if the sub index index does exists as a legal Lucene index.

Specified by:
indexExists in interface LuceneSearchEngineStore
Throws:
SearchEngineException

indexExists

public boolean indexExists(String subContext,
                           String subIndex)
                    throws SearchEngineException
Throws:
SearchEngineException

createIndex

public void createIndex()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Creates the index (if it is already exists, delets it first).

Specified by:
createIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

createIndex

public void createIndex(String subIndex)
                 throws SearchEngineException
Throws:
SearchEngineException

createIndex

public void createIndex(String subContext,
                        String subIndex)
                 throws SearchEngineException
Throws:
SearchEngineException

deleteIndex

public void deleteIndex()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Deletes the index.

Specified by:
deleteIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

deleteIndex

public void deleteIndex(String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Deletes the index for the given sub index.

Specified by:
deleteIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

deleteIndex

public void deleteIndex(String subContext,
                        String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Deletes the index for the given sub context and sub index.

Specified by:
deleteIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

verifyIndex

public boolean verifyIndex()
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Verify that the index exists. If the index exists, nothing happens, if it does not, the index is created.

Specified by:
verifyIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

verifyIndex

public boolean verifyIndex(String subIndex)
                    throws SearchEngineException
Throws:
SearchEngineException

verifyIndex

public boolean verifyIndex(String subContext,
                           String subIndex)
                    throws SearchEngineException
Throws:
SearchEngineException

cleanIndex

public void cleanIndex(String subIndex)
                throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Cleans the sub index.

Specified by:
cleanIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

cleanIndex

public void cleanIndex(String subContext,
                       String subIndex)
                throws SearchEngineException
Throws:
SearchEngineException

isLocked

public boolean isLocked()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if any sub index is locked.

Specified by:
isLocked in interface LuceneSearchEngineStore
Throws:
SearchEngineException

isLocked

public boolean isLocked(String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if the sub index is locked (both Lucene write and commit locks).

Specified by:
isLocked in interface LuceneSearchEngineStore
Throws:
SearchEngineException

isLocked

public boolean isLocked(String subContext,
                        String subIndex)
                 throws SearchEngineException
Throws:
SearchEngineException

releaseLocks

public void releaseLocks()
                  throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Releases all the locks on all the sub indexes.

Specified by:
releaseLocks in interface LuceneSearchEngineStore
Throws:
SearchEngineException

releaseLock

public void releaseLock(String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Releases the lock for the given sub index.

Specified by:
releaseLock in interface LuceneSearchEngineStore
Throws:
SearchEngineException

releaseLock

public void releaseLock(String subContext,
                        String subIndex)
                 throws SearchEngineException
Throws:
SearchEngineException

copyFrom

public void copyFrom(String subIndex,
                     LuceneSearchEngineStore searchEngineStore)
              throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Copies the index from the given store into the current store.

Specified by:
copyFrom in interface LuceneSearchEngineStore
Throws:
SearchEngineException

copyFrom

public void copyFrom(String subContext,
                     String subIndex,
                     LuceneSearchEngineStore searchEngineStore)
              throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Copies the index from the given store into the current store.

Specified by:
copyFrom in interface LuceneSearchEngineStore
Throws:
SearchEngineException

registerEventListeners

public void registerEventListeners(SearchEngine searchEngine,
                                   SearchEngineEventManager eventManager)
Description copied from interface: LuceneSearchEngineStore
A callback to register event listeners when a SearchEngine is created.

Specified by:
registerEventListeners in interface LuceneSearchEngineStore
Parameters:
searchEngine - The search engine created
eventManager - The event manager to register events with

requiresAsyncTransactionalContext

public boolean requiresAsyncTransactionalContext()
Description copied from interface: LuceneSearchEngineStore
Returns true if a transaction needs to be started when performing operations with this store.

Specified by:
requiresAsyncTransactionalContext in interface LuceneSearchEngineStore

supportsConcurrentOperations

public boolean supportsConcurrentOperations()
Description copied from interface: LuceneSearchEngineStore
Returns true if this store supports concurrent operations.

Specified by:
supportsConcurrentOperations in interface LuceneSearchEngineStore

supportsConcurrentCommits

public boolean supportsConcurrentCommits()
Description copied from interface: LuceneSearchEngineStore
Returns true if this store supprots concurrent commits.

Specified by:
supportsConcurrentCommits in interface LuceneSearchEngineStore

isUseCompoundFile

public boolean isUseCompoundFile()
Description copied from interface: LuceneSearchEngineStore
Should we use the compound file format or not.

Specified by:
isUseCompoundFile in interface LuceneSearchEngineStore

suggestedIndexDeletionPolicy

public String suggestedIndexDeletionPolicy()
Description copied from interface: LuceneSearchEngineStore
Returns the suggested index deletion policy for the given store. Will be applied if not explicitly configured. Can return null if globabl settings should be applied.

Specified by:
suggestedIndexDeletionPolicy in interface LuceneSearchEngineStore

getDefaultSubContext

public String getDefaultSubContext()
Description copied from interface: LuceneSearchEngineStore
Returns the default sub context associated with this store.

Specified by:
getDefaultSubContext in interface LuceneSearchEngineStore

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2004-2009 The Compass Project.