org.exist.indexing
Class IndexController

java.lang.Object
  extended by org.exist.indexing.IndexController

public class IndexController
extends Object

Internally used to dispatch an operation to each of the registered indexes. An IndexController instance can be retrieved via DBBroker.getIndexController().


Constructor Summary
IndexController(DBBroker broker)
           
 
Method Summary
 Map configure(NodeList configNodes, Map namespaces)
          Configures all index modules registered with the db instance.
 void flush()
          Flushes all index modules.
 IndexWorker getIndexWorkerById(String indexId)
          Returns an IndexWorker instance corresponding to the specified type of index in indexId.
 IndexWorker getIndexWorkerByName(String indexName)
          Returns an IndexWorker instance corresponding to the specified index named by indexName.
 MatchListener getMatchListener(NodeProxy proxy)
           
 StoredNode getReindexRoot(StoredNode node, NodePath path)
          When adding or removing nodes to or from the document tree, it might become necessary to reindex some parts of the tree, in particular if indexes are defined on mixed content nodes.
 StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf)
          When adding or removing nodes to or from the document tree, it might become necessary to reindex some parts of the tree, in particular if indexes are defined on mixed content nodes.
 StreamListener getStreamListener(DocumentImpl document, int mode)
          Returns a chain of StreamListener, one for each index configured.
 void indexEndElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener)
          Helper method: dispatch a single endElement event to the specified listener.
 void indexNode(Txn transaction, StoredNode node, NodePath path, StreamListener listener)
          Helper method: index a single node which has been added during an XUpdate or XQuery update expression.
 void reindex(Txn transaction, StoredNode reindexRoot, int mode)
          Reindex all nodes below the specified root node, using the given mode.
 void removeCollection(Collection collection)
          Remove all indexes defined on the specified collection.
 void setDocument(DocumentImpl doc, int mode)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexController

public IndexController(DBBroker broker)
Method Detail

getIndexWorkerById

public IndexWorker getIndexWorkerById(String indexId)
Returns an IndexWorker instance corresponding to the specified type of index in indexId. The indexId should be the same one as returned by IndexWorker.getIndexId().

Parameters:
indexId -
Returns:
instance of index worker

getIndexWorkerByName

public IndexWorker getIndexWorkerByName(String indexName)
Returns an IndexWorker instance corresponding to the specified index named by indexName. The indexName should be the same one as returned by IndexWorker.getIndexName().

Parameters:
indexName -
Returns:
instance of index worker

getStreamListener

public StreamListener getStreamListener(DocumentImpl document,
                                        int mode)
Returns a chain of StreamListener, one for each index configured. Note that the chain is reinitialized when the operating mode changes. That allows workers to return different StreamListener for each mode.

Parameters:
document -
mode -
Returns:
chain of StreamListeners

getMatchListener

public MatchListener getMatchListener(NodeProxy proxy)

configure

public Map configure(NodeList configNodes,
                     Map namespaces)
              throws DatabaseConfigurationException
Configures all index modules registered with the db instance.

Parameters:
configNodes - lists the top-level child nodes below the <index> element in collection.xconf
namespaces - the active prefix/namespace map
Returns:
an arbitrary configuration object to be kept for this index in the collection configuration
Throws:
DatabaseConfigurationException - if a configuration error occurs

flush

public void flush()
Flushes all index modules.


getReindexRoot

public StoredNode getReindexRoot(StoredNode node,
                                 NodePath path)
When adding or removing nodes to or from the document tree, it might become necessary to reindex some parts of the tree, in particular if indexes are defined on mixed content nodes. This method will call IndexWorker.getReindexRoot(org.exist.dom.StoredNode, org.exist.storage.NodePath, boolean) on each configured index. It will then return the top-most root.

Parameters:
node - the node to be modified.
path - the NodePath of the node
Returns:
the top-most root node to be reindexed

getReindexRoot

public StoredNode getReindexRoot(StoredNode node,
                                 NodePath path,
                                 boolean includeSelf)
When adding or removing nodes to or from the document tree, it might become necessary to reindex some parts of the tree, in particular if indexes are defined on mixed content nodes. This method will call IndexWorker.getReindexRoot(org.exist.dom.StoredNode, org.exist.storage.NodePath, boolean) on each configured index. It will then return the top-most root.

Parameters:
node - the node to be modified.
path - path the NodePath of the node
includeSelf - if set to true, the current node itself will be included in the check
Returns:
the top-most root node to be reindexed

reindex

public void reindex(Txn transaction,
                    StoredNode reindexRoot,
                    int mode)
Reindex all nodes below the specified root node, using the given mode. mode should be one of StreamListener.STORE or StreamListener.REMOVE_NODES.

Parameters:
transaction - the current transaction
reindexRoot - the root node to reindex
mode - one of StreamListener.STORE or StreamListener.REMOVE_NODES.

indexNode

public void indexNode(Txn transaction,
                      StoredNode node,
                      NodePath path,
                      StreamListener listener)
Helper method: index a single node which has been added during an XUpdate or XQuery update expression.

Parameters:
transaction - the current transaction
node - the node to index
path - the node's NodePath
listener - the StreamListener which receives the index events

indexEndElement

public void indexEndElement(Txn transaction,
                            ElementImpl node,
                            NodePath path,
                            StreamListener listener)
Helper method: dispatch a single endElement event to the specified listener.

Parameters:
transaction - the current transaction
node - the node to index
path - the node's NodePath
listener - the StreamListener which receives index events

setDocument

public void setDocument(DocumentImpl doc,
                        int mode)

removeCollection

public void removeCollection(Collection collection)
Remove all indexes defined on the specified collection.

Parameters:
collection - the collection to remove


Copyright (C) Wolfgang Meier. All rights reserved.