org.exist.storage
Class NativeElementIndex

java.lang.Object
  extended byjava.util.Observable
      extended byorg.exist.storage.ElementIndex
          extended byorg.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
protected  BFile dbNodes
          The datastore for this node index
 
Fields inherited from class org.exist.storage.ElementIndex
broker, doc, pending
 
Constructor Summary
NativeElementIndex(DBBroker broker, BFile dbNodes)
           
 
Method Summary
 void addNode(QName qname, NodeProxy proxy)
          Store the given node in the node index.
 boolean close()
           
 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.
 void endElement(int xpathType, ElementImpl node, java.lang.String content)
          store and index given element (called storeElement before)
 NodeSet findElementsByTagName(byte type, DocumentSet docs, QName qname, NodeSelector selector)
          Find elements by their tag name.
 void flush()
          writes the pending items, for the current document's collection
 NodeSet getAttributesByName(DocumentSet docs, QName qname, NodeSelector selector)
           
 void printStatistics()
           
 void reindex(DocumentImpl document, StoredNode node)
          Reindexes all pending items for the specified document.
 void remove()
          remove all pending modifications, for the current document.
 void removeElement(ElementImpl node, NodePath currentPath, java.lang.String content)
          Mark given Element for removal; added entries are written to the list of pending entries.
 Occurrences[] scanIndexedElements(Collection collection, boolean inclusive)
           
 void startElement(ElementImpl impl, NodePath currentPath, boolean index)
          corresponds to SAX function of the same name
 void storeAttribute(AttrImpl node, NodePath currentPath, boolean fullTextIndexSwitch)
          store and index given attribute
 void storeText(TextImpl node, NodePath currentPath, boolean fullTextIndexSwitch)
          store and index given text node
 void sync()
          triggers a cache sync, i.e.
 java.lang.String toString()
           
 
Methods inherited from class org.exist.storage.ElementIndex
setDocument
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exist.storage.ContentLoadingObserver
setDocument
 

Field Detail

dbNodes

protected BFile dbNodes
The datastore for this node index

Constructor Detail

NativeElementIndex

public NativeElementIndex(DBBroker broker,
                          BFile dbNodes)
Method Detail

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,
                           boolean fullTextIndexSwitch)
Description copied from interface: ContentLoadingObserver
store and index given attribute

Specified by:
storeAttribute in interface ContentLoadingObserver

storeText

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

Specified by:
storeText in interface ContentLoadingObserver

startElement

public void startElement(ElementImpl impl,
                         NodePath currentPath,
                         boolean index)
Description copied from interface: ContentLoadingObserver
corresponds to SAX function of the same name

Specified by:
startElement in interface ContentLoadingObserver

endElement

public void endElement(int xpathType,
                       ElementImpl node,
                       java.lang.String content)
Description copied from interface: ContentLoadingObserver
store and index given element (called storeElement before)

Specified by:
endElement in interface ContentLoadingObserver

removeElement

public void removeElement(ElementImpl node,
                          NodePath currentPath,
                          java.lang.String content)
Description copied from interface: ContentLoadingObserver
Mark given Element for removal; added entries are written to the list of pending entries. ContentLoadingObserver.flush() is called later to flush all pending entries.
Notes: changed name from storeElement()

Specified by:
removeElement 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()
Description copied from interface: ContentLoadingObserver
writes the pending items, for the current document's collection

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
Parameters:
collection -

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
Parameters:
document -
Throws:
ReadOnlyException

reindex

public void reindex(DocumentImpl document,
                    StoredNode node)
Description copied from interface: ContentLoadingObserver
Reindexes all pending items for the specified document. Similar to the normal index process, items to be reindexed are added to the internal pending list via methods #addNode(QName, NodeProxy), #storeElement(int, ElementImpl, String), and {@link #storeAttribute(RangeIndexSpec, AttrImpl)}. Method reindex then scans this list and updates the items in the index to reflect the reindexed document.

Specified by:
reindex in interface ContentLoadingObserver
Parameters:
document - the document to be reindexed.
node - if != null, only nodes being descendants of the specified node will be reindexed. Other nodes are not touched. This is used for a partial reindex.

getAttributesByName

public NodeSet getAttributesByName(DocumentSet docs,
                                   QName qname,
                                   NodeSelector selector)
Specified by:
getAttributesByName in class ElementIndex

findElementsByTagName

public NodeSet findElementsByTagName(byte type,
                                     DocumentSet docs,
                                     QName qname,
                                     NodeSelector selector)
Find elements by their tag name. This method is comparable to the DOM's method call getElementsByTagName. All elements matching tagName and belonging to one of the documents in the DocumentSet docs are returned.

Specified by:
findElementsByTagName in class ElementIndex
Parameters:
docs - Description of the Parameter
Returns:

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

close

public boolean close()
              throws DBException
Throws:
DBException

printStatistics

public void printStatistics()

toString

public java.lang.String toString()


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.