public class LocalIndexProvider extends IndexProvider
IndexProvider
implementation that maintains indexes on the local file system using MapDB.
This provider is instantiated with:
directory
attribute, orpath
attribute and an relativeTo
attributeIndexProvider.ManagedIndexOperation
Constructor and Description |
---|
LocalIndexProvider() |
Modifier and Type | Method and Description |
---|---|
protected ManagedIndex |
createIndex(IndexDefinition defn,
String workspaceName,
NodeTypes.Supplier nodeTypesSupplier,
ChangeSetAdapter.NodeTypePredicate matcher,
IndexFeedback feedback)
Method called when this provider needs to create a new index given the unique pair of workspace name and index definition.
|
protected void |
doInitialize()
Method that should do the provider-specific initialization work.
|
String |
getDirectory()
Get the absolute or relative path to the directory where this provider should store the indexes.
|
protected void |
planUseOfIndex(QueryContext context,
IndexCostCalculator calculator,
String workspaceName,
ManagedIndex index,
IndexDefinition defn)
The method that is called by the IndexProvider's
default IndexPlanner for each
managed index in the given workspace. |
protected void |
postShutdown()
Method called during #shutdown() after each of the managed indexes have been shutdown.
|
protected void |
removeIndex(IndexDefinition oldDefn,
ManagedIndex existingIndex,
String workspaceName)
Method called when this provider needs to remove an existing index given the unique pair of workspace name and index
definition.
|
protected ManagedIndex |
updateIndex(IndexDefinition oldDefn,
IndexDefinition updatedDefn,
ManagedIndex existingIndex,
String workspaceName,
NodeTypes.Supplier nodeTypesSupplier,
ChangeSetAdapter.NodeTypePredicate matcher,
IndexFeedback feedback)
Method called when this provider needs to update an existing index given the unique pair of workspace name and index
definition.
|
void |
validateProposedIndex(ExecutionContext context,
IndexDefinition defn,
NodeTypes.Supplier nodeTypeSupplier,
Problems problems)
Validate the proposed index definition, and use the supplied problems to report any issues that will prevent this provider
from creating and using an index with the given definition.
|
context, getIndex, getIndexes, getIndexPlanner, getIndexWriter, getName, getRepositoryName, initialize, logger, names, namespaces, notify, notify, notify, onEachIndex, onEachIndexInWorkspace, preShutdown, shutdown, valueFactories
public String getDirectory()
protected void doInitialize() throws RepositoryException
IndexProvider
By the time this method is called, ModeShape will hav already set the IndexProvider.context
, IndexProvider.logger
, IndexProvider.name
, and
IndexProvider.repositoryName
plus any fields that match configuration properties for the provider.
This is an excellent place for providers to validate the provider-specific fields set by ModeShape via reflection during instantiation.
doInitialize
in class IndexProvider
RepositoryException
- if there is a problem initializing the providerprotected void postShutdown()
IndexProvider
postShutdown
in class IndexProvider
public void validateProposedIndex(ExecutionContext context, IndexDefinition defn, NodeTypes.Supplier nodeTypeSupplier, Problems problems)
IndexProvider
validateProposedIndex
in class IndexProvider
context
- the execution context in which to perform the validation; never nulldefn
- the proposed index definition; never nullnodeTypeSupplier
- the supplier for the NodeTypes object that contains information about the currently-registered
node types; never nullproblems
- the problems that should be used to report any issues with the index definition; never nullprotected ManagedIndex createIndex(IndexDefinition defn, String workspaceName, NodeTypes.Supplier nodeTypesSupplier, ChangeSetAdapter.NodeTypePredicate matcher, IndexFeedback feedback)
IndexProvider
createIndex
in class IndexProvider
defn
- the definition of the index; never nullworkspaceName
- the name of the actual workspace to which the new index applies; never nullnodeTypesSupplier
- the supplier for the current node types cache; never nullmatcher
- the node type matcher used to determine which nodes should be included in the index, and which automatically
updates when node types are changed in the repository; may not be nullfeedback
- the feedback mechanism for this provider to signal to ModeShape that portions of the repository content
must be scanned to build/populate the new index; never nullManagedIndex
for the new index; may not be nullprotected ManagedIndex updateIndex(IndexDefinition oldDefn, IndexDefinition updatedDefn, ManagedIndex existingIndex, String workspaceName, NodeTypes.Supplier nodeTypesSupplier, ChangeSetAdapter.NodeTypePredicate matcher, IndexFeedback feedback)
IndexProvider
updateIndex
in class IndexProvider
oldDefn
- the previous definition of the index; never nullupdatedDefn
- the updated definition of the index; never nullexistingIndex
- the existing index prior to this update, as returned from IndexProvider.createIndex(org.modeshape.jcr.api.index.IndexDefinition, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)
or IndexProvider.updateIndex(org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.spi.index.provider.ManagedIndex, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)
; never nullworkspaceName
- the name of the actual workspace to which the new index applies; never nullnodeTypesSupplier
- the supplier for the current node types cache; never nullmatcher
- the node type matcher used to determine which nodes should be included in the index, and which automatically
updates when node types are changed in the repository; may not be nullfeedback
- the feedback mechanism for this provider to signal to ModeShape that portions of the repository content
must be scanned to rebuild/repopulate the updated index; never nullprotected void removeIndex(IndexDefinition oldDefn, ManagedIndex existingIndex, String workspaceName)
IndexProvider
removeIndex
in class IndexProvider
oldDefn
- the previous definition of the index; never nullexistingIndex
- the existing index prior to this update, as returned from IndexProvider.createIndex(org.modeshape.jcr.api.index.IndexDefinition, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)
or IndexProvider.updateIndex(org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.spi.index.provider.ManagedIndex, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)
; never nullworkspaceName
- the name of the actual workspace to which the new index applies; never nullprotected void planUseOfIndex(QueryContext context, IndexCostCalculator calculator, String workspaceName, ManagedIndex index, IndexDefinition defn)
IndexProvider
default IndexPlanner
for each
managed index in the given workspace.
Subclasses should implement this method to determine and record whether the supplied index can be used by the query against the named workspace.
The IndexUsage
class may be useful to determine for a given index definition whether criteria is applicable.
planUseOfIndex
in class IndexProvider
context
- the context of the original query; never nullcalculator
- the calculator that should be used to record plan information for the index; never nullworkspaceName
- the name of the workspace against which the query is operating; never nullindex
- the managed index in the given workspace; never nulldefn
- the definition for the index; never nullCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.