org.exist.storage.statistics
Class IndexStatisticsWorker

java.lang.Object
  extended by org.exist.storage.statistics.IndexStatisticsWorker
All Implemented Interfaces:
IndexWorker

public class IndexStatisticsWorker
extends Object
implements IndexWorker


Field Summary
 
Fields inherited from interface org.exist.indexing.IndexWorker
VALUE_COUNT
 
Constructor Summary
IndexStatisticsWorker(IndexStatistics index)
           
 
Method Summary
 boolean checkIndex(DBBroker broker)
          Checking index could be delegated to a worker.
 Object configure(IndexController controller, NodeList configNodes, Map namespaces)
          Read an index configuration from an collection.xconf configuration document.
 void flush()
          Flush the index.
 DocumentImpl getDocument()
          Returns the document for the next operation.
 String getIndexId()
          Returns an ID which uniquely identifies this worker's index.
 String getIndexName()
          Returns a name which uniquely identifies this worker's index.
 StreamListener getListener()
          Return a stream listener to index the current document in the current mode.
 MatchListener getMatchListener(DBBroker broker, NodeProxy proxy)
          Returns a MatchListener, which can be used to filter (and manipulate) the XML output generated by the serializer when serializing query results.
 int getMode()
          Returns the mode for the next operation.
 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.
 void removeCollection(Collection collection, DBBroker broker)
          Remove all indexes for the given collection, its subcollections and all resources..
 Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet contextSet, Map hints)
          Return aggregated (on a document count basis) index entries for the specified document set.
 void setDocument(DocumentImpl doc)
          Notify this worker to operate on the specified document.
 void setDocument(DocumentImpl doc, int mode)
          Notify this worker to operate on the specified document, using the mode given.
 void setMode(int mode)
          Notify this worker to operate using the mode given.
 void updateIndex(DBBroker broker)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexStatisticsWorker

public IndexStatisticsWorker(IndexStatistics index)
Method Detail

getIndexId

public String getIndexId()
Description copied from interface: IndexWorker
Returns an ID which uniquely identifies this worker's index.

Specified by:
getIndexId in interface IndexWorker
Returns:
a unique name identifying this worker's index.

getIndexName

public String getIndexName()
Description copied from interface: IndexWorker
Returns a name which uniquely identifies this worker's index.

Specified by:
getIndexName in interface IndexWorker
Returns:
a unique name identifying this worker's index.

configure

public Object configure(IndexController controller,
                        NodeList configNodes,
                        Map namespaces)
                 throws DatabaseConfigurationException
Description copied from interface: IndexWorker
Read an index configuration from an collection.xconf configuration document. This method is called by the CollectionConfiguration while reading the collection.xconf configuration file for a given collection. The configNodes parameter lists all top-level child nodes below the <index> element in the collection.xconf. The IndexWorker should scan this list and handle those elements it understands. The returned Object will be stored in the collection configuration structure associated with each collection. It can later be retrieved from the collection configuration, e.g. to check if a given node should be indexed or not.

Specified by:
configure in interface IndexWorker
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

setDocument

public void setDocument(DocumentImpl doc)
Description copied from interface: IndexWorker
Notify this worker to operate on the specified document.

Specified by:
setDocument in interface IndexWorker
Parameters:
doc - the document which is processed

setDocument

public void setDocument(DocumentImpl doc,
                        int mode)
Description copied from interface: IndexWorker
Notify this worker to operate on the specified document, using the mode given. Mode will be one of StreamListener.UNKNOWN, StreamListener.STORE, StreamListener.REMOVE_SOME_NODES or StreamListener.REMOVE_ALL_NODES.

Specified by:
setDocument in interface IndexWorker
Parameters:
doc - the document which is processed
mode - the current operation mode

setMode

public void setMode(int mode)
Description copied from interface: IndexWorker
Notify this worker to operate using the mode given. Mode will be one of StreamListener.UNKNOWN, StreamListener.STORE, StreamListener.REMOVE_SOME_NODES or StreamListener.REMOVE_ALL_NODES.

Specified by:
setMode in interface IndexWorker
Parameters:
mode - the current operation mode

getDocument

public DocumentImpl getDocument()
Description copied from interface: IndexWorker
Returns the document for the next operation.

Specified by:
getDocument in interface IndexWorker
Returns:
the document

getMode

public int getMode()
Description copied from interface: IndexWorker
Returns the mode for the next operation.

Specified by:
getMode in interface IndexWorker
Returns:
the document

getReindexRoot

public StoredNode getReindexRoot(StoredNode node,
                                 NodePath path,
                                 boolean includeSelf)
Description copied from interface: IndexWorker
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.

Specified by:
getReindexRoot in interface IndexWorker
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

getListener

public StreamListener getListener()
Description copied from interface: IndexWorker
Return a stream listener to index the current document in the current mode. There will never be more than one StreamListener being used per thread, so it is safe for the implementation to reuse a single StreamListener. Parameter mode specifies the type of the current operation.

Specified by:
getListener in interface IndexWorker
Returns:
a StreamListener

getMatchListener

public MatchListener getMatchListener(DBBroker broker,
                                      NodeProxy proxy)
Description copied from interface: IndexWorker
Returns a MatchListener, which can be used to filter (and manipulate) the XML output generated by the serializer when serializing query results. The method should return null if the implementation is not interested in receiving serialization events.

Specified by:
getMatchListener in interface IndexWorker
proxy - the NodeProxy which is being serialized
Returns:
a MatchListener or null if the implementation does not want to receive serialization events

flush

public void flush()
Description copied from interface: IndexWorker
Flush the index. This method will be called when indexing a document. The implementation should immediately process all data it has buffered (if there is any), release as many memory resources as it can and prepare for being reused for a different job.

Specified by:
flush in interface IndexWorker

updateIndex

public void updateIndex(DBBroker broker)

removeCollection

public void removeCollection(Collection collection,
                             DBBroker broker)
Description copied from interface: IndexWorker
Remove all indexes for the given collection, its subcollections and all resources..

Specified by:
removeCollection in interface IndexWorker
Parameters:
collection - The collection to remove
broker - The broker that will perform the operation

checkIndex

public boolean checkIndex(DBBroker broker)
Description copied from interface: IndexWorker
Checking index could be delegated to a worker. Use this method to do so.

Specified by:
checkIndex in interface IndexWorker
Parameters:
broker - The broker that will perform the operation
Returns:
Whether or not the index if in a suitable state

scanIndex

public Occurrences[] scanIndex(XQueryContext context,
                               DocumentSet docs,
                               NodeSet contextSet,
                               Map hints)
Description copied from interface: IndexWorker
Return aggregated (on a document count basis) index entries for the specified document set. Aggregation can only occur if the index entries can be compared, i.e. if the index implements OrderedValuesIndex, otherwise each entry will be considered as a single occurence.

Specified by:
scanIndex in interface IndexWorker
docs - The documents to which the index entries belong
hints - Some "hints" for retrieving the index entries. See such hints in OrderedValuesIndex and QNamedKeysIndex.
Returns:
Occurrences objects that contain :
  1. a string representation of the index entry. This may change in the future.
  2. the number of occurrences for the index entry over all the documents
  3. the list of the documents in which the index entry is


Copyright (C) Wolfgang Meier. All rights reserved.