org.exist.storage
Class NativeElementIndex

java.lang.Object
  extended by java.util.Observable
      extended by org.exist.storage.ElementIndex
          extended by org.exist.storage.NativeElementIndex
All Implemented Interfaces:
ContentLoadingObserver

public class NativeElementIndex
extends ElementIndex
implements ContentLoadingObserver

The indexing occurs in this class. That is, during the loading of a document into the database, the process of associating a long gid with each element, and the subsequent storing of the NodeProxy on disk.


Field Summary
static double DEFAULT_STRUCTURAL_CACHE_GROWTH
           
static double DEFAULT_STRUCTURAL_KEY_THRESHOLD
           
static double DEFAULT_STRUCTURAL_VALUE_THRESHOLD
           
static String FILE_KEY_IN_CONFIG
           
static String FILE_NAME
           
static int OFFSET_COLLECTION_ID
           
static int OFFSET_NSSYMBOL
           
static int OFFSET_SYMBOL
           
static int OFFSET_TYPE
           
 
Constructor Summary
NativeElementIndex(DBBroker broker, byte id, String dataDir, Configuration config)
           
 
Method Summary
 void addNode(QName qname, NodeProxy proxy)
          Store the given node in the node index.
 boolean close()
           
 void closeAndRemove()
           
 void consistencyCheck(DocumentImpl document)
           
 void dropIndex(Collection collection)
          Drop all index entries for the given collection.
 void dropIndex(DocumentImpl document)
          Drop all index entries for the given document.
 NodeSet findDescendantsByTagName(byte type, QName qname, int axis, DocumentSet docs, ExtNodeSet contextSet, int contextId)
          Optimized lookup method which directly implements the ancestor-descendant join.
 NodeSet findElementsByTagName(byte type, DocumentSet docs, QName qname, NodeSelector selector)
          Lookup elements or attributes in the index matching a given QName and NodeSelector.
 void flush()
           
 String getConfigKeyForFile()
           
 String getFileName()
           
 NativeElementIndex getInstance()
           
 void printStatistics()
           
 void remove()
          remove all pending modifications, for the current document.
 void removeNode(StoredNode node, NodePath currentPath, String content)
          The given node is being removed from the database.
 Occurrences[] scanIndexedElements(Collection collection, boolean inclusive)
           
 void storeAttribute(AttrImpl node, NodePath currentPath, int indexingHint, RangeIndexSpec spec, boolean remove)
          store and index given attribute
 void storeText(TextImpl node, NodePath currentPath, int indexingHint)
          store and index given text node
 void sync()
          triggers a cache sync, i.e.
 String toString()
           
 
Methods inherited from class org.exist.storage.ElementIndex
setDocument, setInUpdateMode
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exist.storage.ContentLoadingObserver
setDocument
 

Field Detail

FILE_NAME

public static final String FILE_NAME
See Also:
Constant Field Values

FILE_KEY_IN_CONFIG

public static final String FILE_KEY_IN_CONFIG
See Also:
Constant Field Values

DEFAULT_STRUCTURAL_CACHE_GROWTH

public static final double DEFAULT_STRUCTURAL_CACHE_GROWTH
See Also:
Constant Field Values

DEFAULT_STRUCTURAL_KEY_THRESHOLD

public static final double DEFAULT_STRUCTURAL_KEY_THRESHOLD
See Also:
Constant Field Values

DEFAULT_STRUCTURAL_VALUE_THRESHOLD

public static final double DEFAULT_STRUCTURAL_VALUE_THRESHOLD
See Also:
Constant Field Values

OFFSET_COLLECTION_ID

public static int OFFSET_COLLECTION_ID

OFFSET_TYPE

public static int OFFSET_TYPE

OFFSET_SYMBOL

public static int OFFSET_SYMBOL

OFFSET_NSSYMBOL

public static int OFFSET_NSSYMBOL
Constructor Detail

NativeElementIndex

public NativeElementIndex(DBBroker broker,
                          byte id,
                          String dataDir,
                          Configuration config)
                   throws DBException
Throws:
DBException
Method Detail

getFileName

public String getFileName()

getConfigKeyForFile

public String getConfigKeyForFile()

getInstance

public NativeElementIndex getInstance()

addNode

public void addNode(QName qname,
                    NodeProxy proxy)
Store the given node in the node index.

Parameters:
qname - The node's identity
proxy - The node's proxy

storeAttribute

public void storeAttribute(AttrImpl node,
                           NodePath currentPath,
                           int indexingHint,
                           RangeIndexSpec spec,
                           boolean remove)
Description copied from interface: ContentLoadingObserver
store and index given attribute

Specified by:
storeAttribute in interface ContentLoadingObserver

storeText

public void storeText(TextImpl node,
                      NodePath currentPath,
                      int indexingHint)
Description copied from interface: ContentLoadingObserver
store and index given text node

Specified by:
storeText in interface ContentLoadingObserver

removeNode

public void removeNode(StoredNode node,
                       NodePath currentPath,
                       String content)
Description copied from interface: ContentLoadingObserver
The given node is being removed from the database.

Specified by:
removeNode in interface ContentLoadingObserver

sync

public void sync()
Description copied from interface: ContentLoadingObserver
triggers a cache sync, i.e. forces to write out all cached pages. sync() is called from time to time by the background sync daemon.

Specified by:
sync in interface ContentLoadingObserver

flush

public void flush()
Specified by:
flush in interface ContentLoadingObserver

remove

public void remove()
Description copied from interface: ContentLoadingObserver
remove all pending modifications, for the current document.

Specified by:
remove in interface ContentLoadingObserver

dropIndex

public void dropIndex(Collection collection)
Description copied from interface: ContentLoadingObserver
Drop all index entries for the given collection.

Specified by:
dropIndex in interface ContentLoadingObserver

dropIndex

public void dropIndex(DocumentImpl document)
               throws ReadOnlyException
Description copied from interface: ContentLoadingObserver
Drop all index entries for the given document.

Specified by:
dropIndex in interface ContentLoadingObserver
Throws:
ReadOnlyException

findElementsByTagName

public NodeSet findElementsByTagName(byte type,
                                     DocumentSet docs,
                                     QName qname,
                                     NodeSelector selector)
Lookup elements or attributes in the index matching a given QName and NodeSelector. The NodeSelector argument is optional. If selector is null, all elements or attributes matching qname will be returned.

Specified by:
findElementsByTagName in class ElementIndex
Parameters:
type - either ElementValue.ATTRIBUTE, ElementValue.ELEMENT.
docs - the set of documents to look up in the index
qname - the QName of the attribute or element
selector - an (optional) NodeSelector

findDescendantsByTagName

public NodeSet findDescendantsByTagName(byte type,
                                        QName qname,
                                        int axis,
                                        DocumentSet docs,
                                        ExtNodeSet contextSet,
                                        int contextId)
Optimized lookup method which directly implements the ancestor-descendant join. The algorithm does directly operate on the input stream containing the potential descendant nodes. It thus needs less comparisons than findElementsByTagName(byte, DocumentSet, QName, NodeSelector).

Specified by:
findDescendantsByTagName in class ElementIndex
Parameters:
type - either ElementValue.ATTRIBUTE or ElementValue.ELEMENT
docs - the set of documents to look up in the index
contextSet - the set of ancestor nodes for which the method will try to find descendants
contextId - id of the current context expression as passed by the query engine
qname - the QName to search for

scanIndexedElements

public Occurrences[] scanIndexedElements(Collection collection,
                                         boolean inclusive)
                                  throws PermissionDeniedException
Specified by:
scanIndexedElements in class ElementIndex
Throws:
PermissionDeniedException

consistencyCheck

public void consistencyCheck(DocumentImpl document)
                      throws EXistException
Throws:
EXistException

closeAndRemove

public void closeAndRemove()
Specified by:
closeAndRemove in interface ContentLoadingObserver

close

public boolean close()
              throws DBException
Specified by:
close in interface ContentLoadingObserver
Throws:
DBException

printStatistics

public void printStatistics()
Specified by:
printStatistics in interface ContentLoadingObserver

toString

public String toString()
Overrides:
toString in class Object


Copyright (C) Wolfgang Meier. All rights reserved.