org.exist.storage
Class NativeValueIndex

java.lang.Object
  extended byorg.exist.storage.NativeValueIndex
All Implemented Interfaces:
ContentLoadingObserver
Direct Known Subclasses:
NativeValueIndexByQName

public class NativeValueIndex
extends java.lang.Object
implements ContentLoadingObserver

Maintains an index on typed node values. TODO: Check correct types during validation. In the BTree single BFile, the keys are : (collectionId, indexType, indexData) and the values are : gid1, gid2-gid1, ...

Algorithm:

When a node is stored, an entry is added or updated in the #pending map, with given String content and basic type as key. This way, the index entries are easily put in the persistent BFile storage by flush() .

Author:
wolf

Field Summary
static java.lang.String PROPERTY_INDEX_CASE_SENSITIVE
           
 
Constructor Summary
NativeValueIndex(DBBroker broker, BFile dbValues)
           
 
Method Summary
 boolean close()
           
 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 find(int relation, DocumentSet docs, NodeSet contextSet, Indexable value)
          find
 void flush()
          writes the pending items, for the current document's collection
 NodeSet match(DocumentSet docs, NodeSet contextSet, java.lang.String expr, int type)
           
 NodeSet match(DocumentSet docs, NodeSet contextSet, java.lang.String expr, int type, int flags, boolean caseSensitiveQuery)
          Regular expression search
 void printStatistics()
           
 void reindex(DocumentImpl oldDoc, 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.
 ValueOccurrences[] scanIndexKeys(DocumentSet docs, NodeSet contextSet, Indexable start)
           
 void setDocument(DocumentImpl document)
          set the current document; generally called before calling an operation
 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 storeAttribute(RangeIndexSpec spec, AttrImpl node)
          Store the given attribute's value in the value index.
 void storeElement(int xpathType, ElementImpl node, java.lang.String content)
          Store the given element's value in the value index.
 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_INDEX_CASE_SENSITIVE

public static java.lang.String PROPERTY_INDEX_CASE_SENSITIVE
Constructor Detail

NativeValueIndex

public NativeValueIndex(DBBroker broker,
                        BFile dbValues)
Method Detail

setDocument

public void setDocument(DocumentImpl document)
Description copied from interface: ContentLoadingObserver
set the current document; generally called before calling an operation

Specified by:
setDocument in interface ContentLoadingObserver

storeElement

public void storeElement(int xpathType,
                         ElementImpl node,
                         java.lang.String content)
Store the given element's value in the value index.

Parameters:
xpathType - The value type
node - The element
content - The string representation of the value

storeAttribute

public void storeAttribute(RangeIndexSpec spec,
                           AttrImpl node)
Store the given attribute's value in the value index.

Parameters:
spec - The index specification
node - The attribute

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

find

public NodeSet find(int relation,
                    DocumentSet docs,
                    NodeSet contextSet,
                    Indexable value)
             throws TerminatedException
find

Parameters:
relation - binary operator used for the comparison
value - right hand comparison value
Throws:
TerminatedException

match

public NodeSet match(DocumentSet docs,
                     NodeSet contextSet,
                     java.lang.String expr,
                     int type)
              throws TerminatedException,
                     EXistException
Throws:
TerminatedException
EXistException

match

public NodeSet match(DocumentSet docs,
                     NodeSet contextSet,
                     java.lang.String expr,
                     int type,
                     int flags,
                     boolean caseSensitiveQuery)
              throws TerminatedException,
                     EXistException
Regular expression search

Parameters:
type - like type argument for RegexMatcher constructor
flags - like flags argument for RegexMatcher constructor
Throws:
TerminatedException
EXistException

scanIndexKeys

public ValueOccurrences[] scanIndexKeys(DocumentSet docs,
                                        NodeSet contextSet,
                                        Indexable start)

close

public boolean close()
              throws DBException
Throws:
DBException

printStatistics

public void printStatistics()

toString

public java.lang.String toString()

reindex

public void reindex(DocumentImpl oldDoc,
                    StoredNode node)
Description copied from interface: ContentLoadingObserver
Reindexes all pending items for the specified document.

Specified by:
reindex in interface ContentLoadingObserver
Parameters:
oldDoc - 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.


Copyright (C) Wolfgang Meier. All rights reserved.