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
 void addIndexWorker(IndexWorker worker)
          TODO: temporary method to plug in fulltext index.
 void attribute(Txn transaction, AttrImpl node, NodePath path, StreamListener listener)
          Helper method: index a single attribute node which has been added during an XUpdate or XQuery update expression.
 void characters(Txn transaction, TextImpl node, NodePath path, StreamListener listener)
          Helper method: index a single text node which has been added during an XUpdate or XQuery update expression.
 Map configure(NodeList configNodes, Map namespaces)
          Configures all index workers registered with the db instance.
 void endElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener)
          Helper method: dispatch a single endElement event to the specified listener.
 void flush()
          Flushes all index workers.
 DocumentImpl getDocument()
          Returns the document for the next operation.
 MatchListener getMatchListener(NodeProxy proxy)
          Returns the match listener for this node.
 int getMode()
          Returns the mode for the next operation.
 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()
          Returns a chain of StreamListener, one for each index configured on the current document for the current mode.
 IndexWorker getWorkerByIndexId(String indexId)
          Returns an IndexWorker instance corresponding to the specified type of index in indexId.
 IndexWorker getWorkerByIndexName(String indexName)
          Returns an IndexWorker instance corresponding to the specified index named by indexName.
 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, DBBroker broker)
          Remove all indexes defined on the specified collection.
 void setDocument(DocumentImpl doc)
          Sets the document for the next operation.
 void setDocument(DocumentImpl doc, int mode)
          Sets the document and the mode for the next operation.
 void setMode(int mode)
          Sets the the mode for the next operation.
 void startElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener)
          Helper method: index a single element node which has been added during an XUpdate or XQuery update expression.
 
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

addIndexWorker

public void addIndexWorker(IndexWorker worker)
TODO: temporary method to plug in fulltext index. Remove once new fulltext index module is ready.

Parameters:
worker -

configure

public Map configure(NodeList configNodes,
                     Map namespaces)
              throws DatabaseConfigurationException
Configures all index workers 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

getWorkerByIndexId

public IndexWorker getWorkerByIndexId(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

getWorkerByIndexName

public IndexWorker getWorkerByIndexName(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

setDocument

public void setDocument(DocumentImpl doc)
Sets the document for the next operation.

Parameters:
doc - the document

setMode

public void setMode(int mode)
Sets the the mode for the next operation.

Parameters:
mode - the mode, one of StreamListener.UNKNOWN, StreamListener.STORE, StreamListener.REMOVE_SOME_NODES or StreamListener.REMOVE_ALL_NODES.

getDocument

public DocumentImpl getDocument()
Returns the document for the next operation.

Returns:
the document

getMode

public int getMode()
Returns the mode for the next operation.

Returns:
the document

setDocument

public void setDocument(DocumentImpl doc,
                        int mode)
Sets the document and the mode for the next operation.

Parameters:
doc - the document
mode - the mode, one of StreamListener.UNKNOWN, StreamListener.STORE, StreamListener.REMOVE_SOME_NODES or StreamListener.REMOVE_ALL_NODES.

flush

public void flush()
Flushes all index workers.


removeCollection

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

Parameters:
collection - the collection to remove
broker - the broker that will perform the operation

reindex

public void reindex(Txn transaction,
                    StoredNode reindexRoot,
                    int mode)
Reindex all nodes below the specified root node, using the given mode.

Parameters:
transaction - the current transaction
reindexRoot - the node from which reindexing should occur
mode - the mode, one of StreamListener.UNKNOWN, StreamListener.STORE, StreamListener.REMOVE_SOME_NODES or StreamListener.REMOVE_ALL_NODES.

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

getStreamListener

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

Returns:
the first listener in the chain of StreamListeners

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

startElement

public void startElement(Txn transaction,
                         ElementImpl node,
                         NodePath path,
                         StreamListener listener)
Helper method: index a single element 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

endElement

public void endElement(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

attribute

public void attribute(Txn transaction,
                      AttrImpl node,
                      NodePath path,
                      StreamListener listener)
Helper method: index a single attribute 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

characters

public void characters(Txn transaction,
                       TextImpl node,
                       NodePath path,
                       StreamListener listener)
Helper method: index a single text 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

getMatchListener

public MatchListener getMatchListener(NodeProxy proxy)
Returns the match listener for this node.

Parameters:
proxy - a proxy to the node.
Returns:
the MatchListener


Copyright (C) Wolfgang Meier. All rights reserved.