|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectorg.exist.xquery.value.AbstractSequence
org.exist.dom.AbstractNodeSet
org.exist.dom.ExtArrayNodeSet
public class ExtArrayNodeSet
A fast node set implementation, based on arrays to store nodes and documents.
The class uses an array to store all nodes belonging to one document. Another sorted
array is used to keep track of the document ids. For each document, we maintain an inner
class, Part, which stores the array of nodes.
Nodes are just appended to the nodes array. No order is guaranteed and calls to
get/contains may fail although a node is present in the array (get/contains
do a binary search and thus assume that the set is sorted). Also, duplicates
are allowed. If you have to ensure that calls to get/contains return valid
results at any time and no duplicates occur, use class
AVLTreeNodeSet.
Use this class, if you can either ensure that items are added in order, or
no calls to contains/get are required during the creation phase. Only after
a call to one of the iterator methods, the set will get sorted and
duplicates removed.
| Field Summary |
|---|
| Fields inherited from interface org.exist.dom.DocumentSet |
|---|
EMPTY_DOCUMENT_SET |
| Fields inherited from interface org.exist.dom.NodeSet |
|---|
ANCESTOR, DESCENDANT, EMPTY_SET, FOLLOWING, PRECEDING |
| Fields inherited from interface org.exist.xquery.value.Sequence |
|---|
EMPTY_SEQUENCE |
| Constructor Summary | |
|---|---|
ExtArrayNodeSet()
Creates a new ExtArrayNodeSet instance. |
|
ExtArrayNodeSet(int initialArraySize)
Creates a new ExtArrayNodeSet instance. |
|
ExtArrayNodeSet(int initialDocsCount,
int initialArraySize)
Creates a new ExtArrayNodeSet instance. |
|
| Method Summary | |
|---|---|
void |
add(NodeProxy proxy)
The method add |
void |
add(NodeProxy proxy,
int sizeHint)
Add a new node to the set. |
void |
addAll(NodeSet other)
Add all nodes from the given node set. |
boolean |
contains(DocumentSet other)
|
boolean |
contains(int docId)
|
boolean |
contains(NodeProxy proxy)
Check if this node set contains a node matching the document and node-id of the given NodeProxy object. |
String |
debugParts()
The method debugParts |
NodeSet |
docsToNodeSet()
|
boolean |
equalDocs(DocumentSet other)
|
NodeSet |
filterDocuments(ExtArrayNodeSet otherSet)
The method filterDocuments |
NodeProxy |
get(DocumentImpl doc,
NodeId nodeId)
|
NodeProxy |
get(int pos)
Get the node at position pos within this node set. |
NodeProxy |
get(NodeProxy p)
Get a node from this node set matching the document and node id of the given NodeProxy. |
Iterator |
getCollectionIterator()
The method getCollectionIterator |
NodeSet |
getDescendantsInSet(NodeSet al,
boolean childOnly,
boolean includeSelf,
int mode,
int contextId,
boolean copyMatches)
The method getDescendantsInSet |
DocumentImpl |
getDoc(int docId)
|
DocumentImpl |
getDocumentAt(int pos)
|
int |
getDocumentCount()
|
Iterator |
getDocumentIterator()
|
DocumentSet |
getDocumentSet()
The method getDocumentSet |
int |
getIndexType()
If all nodes in this set have an index, returns the common supertype used to build the index, e.g. |
int |
getItemCount()
Returns the number of items contained in the sequence. |
int |
getItemType()
The method getItemType |
int |
getLength()
Return the number of nodes contained in this node set. |
XmldbURI[] |
getNames()
|
int |
getSizeHint(DocumentImpl doc)
The method getSizeHint |
int |
getState()
|
boolean |
hasChanged(int previousState)
|
NodeProxy |
hasDescendantsInSet(DocumentImpl doc,
NodeId ancestorId,
boolean includeSelf,
int contextId)
The method hasDescendantsInSet |
boolean |
hasOne()
The method hasOne |
DocumentSet |
intersection(DocumentSet other)
|
boolean |
isCacheable()
|
boolean |
isEmpty()
The method isEmpty |
Node |
item(int pos)
|
Item |
itemAt(int pos)
Returns the item located at the specified position within this sequence. |
SequenceIterator |
iterate()
Returns an iterator over all items in the sequence. |
ByDocumentIterator |
iterateByDocument()
|
NodeSetIterator |
iterator()
Return an iterator on the nodes in this list. |
void |
lock(DBBroker broker,
boolean exclusive,
boolean checkExisting)
|
void |
mergeDuplicates()
Remove all duplicate nodes, but merge their contexts. |
NodeProxy |
parentWithChild(DocumentImpl doc,
NodeId nodeId,
boolean directParent,
boolean includeSelf)
The method parentWithChild |
void |
reset()
The method reset |
NodeSet |
selectAncestorDescendant(NodeSet al,
int mode,
boolean includeSelf,
int contextId,
boolean copyMatches)
Check if any descendant nodes are found within this node set for a given set of potential ancestor nodes. |
NodeSet |
selectAncestors(NodeSet al,
boolean includeSelf,
int contextId)
For a given set of potential ancestor nodes, return all ancestors having descendants in this node set. |
NodeSet |
selectFollowingSiblings(NodeSet siblings,
int contextId)
The method selectFollowingSiblings |
NodeSet |
selectParentChild(NodeSet al,
int mode,
int contextId)
The method selectParentChild |
NodeSet |
selectPrecedingSiblings(NodeSet siblings,
int contextId)
Select all nodes from the passed node set, which are preceding or following siblings of the nodes in this set. |
void |
setDocumentSet(DocumentSet docs)
The method setDocumentSet |
void |
setSelfAsContext(int contextId)
|
void |
setSorted(DocumentImpl document,
boolean sorted)
The method setSorted |
void |
sort()
The method sort |
void |
sort(boolean mergeContexts)
The method sort |
void |
sortInDocumentOrder()
The method sortInDocumentOrder |
String |
toString()
The method toString |
void |
unlock(boolean exclusive)
|
SequenceIterator |
unorderedIterator()
Returns an iterator over all items in the sequence. |
| Methods inherited from class org.exist.dom.AbstractNodeSet |
|---|
add, addAll, clearContext, deepIntersection, directSelectAttribute, except, filterDocuments, getAncestors, getContextNodes, getParents, getProcessInReverseOrder, hasMixedContent, hasTextIndex, intersection, isCached, isPersistentSet, nodeMoved, parentWithChild, removeDuplicates, selectFollowing, selectFollowing, selectParentChild, selectPreceding, selectPreceding, setIsCached, setProcessInReverseOrder, toMemNodeSet, toNodeSet, union |
| Methods inherited from class org.exist.xquery.value.AbstractSequence |
|---|
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, toJavaObject |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.exist.xquery.value.Sequence |
|---|
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, toJavaObject |
| Constructor Detail |
|---|
public ExtArrayNodeSet()
ExtArrayNodeSet instance.
public ExtArrayNodeSet(int initialDocsCount,
int initialArraySize)
ExtArrayNodeSet instance.
initialDocsCount - an int valueinitialArraySize - an int valuepublic ExtArrayNodeSet(int initialArraySize)
ExtArrayNodeSet instance.
initialArraySize - an int value| Method Detail |
|---|
public void reset()
reset
public boolean isEmpty()
isEmpty
isEmpty in interface SequenceisEmpty in class AbstractSequenceboolean valuepublic boolean hasOne()
hasOne
hasOne in interface SequencehasOne in class AbstractSequenceboolean valuepublic void add(NodeProxy proxy)
add
add in interface NodeSetadd in class AbstractNodeSetproxy - a NodeProxy value
public void add(NodeProxy proxy,
int sizeHint)
add in interface NodeSetadd in class AbstractNodeSetpublic int getItemType()
getItemType
getItemType in interface SequencegetItemType in class AbstractNodeSetint valuepublic int getSizeHint(DocumentImpl doc)
getSizeHint
getSizeHint in interface NodeSetgetSizeHint in class AbstractNodeSetdoc - a DocumentImpl value
int valuepublic NodeSetIterator iterator()
AbstractNodeSet
iterator in interface NodeSetiterator in class AbstractNodeSet
public SequenceIterator iterate()
throws XPathException
Sequence
iterate in interface Sequenceiterate in class AbstractNodeSetXPathException - TODO
public SequenceIterator unorderedIterator()
throws XPathException
Sequence
unorderedIterator in interface SequenceunorderedIterator in class AbstractNodeSetXPathExceptionpublic ByDocumentIterator iterateByDocument()
public boolean contains(NodeProxy proxy)
AbstractNodeSet
contains in interface NodeSetcontains in class AbstractNodeSetpublic void addAll(NodeSet other)
AbstractNodeSet
addAll in interface NodeSetaddAll in class AbstractNodeSetpublic int getLength()
AbstractNodeSet
getLength in interface NodeListgetLength in class AbstractNodeSetpublic int getItemCount()
Sequence
getItemCount in interface SequencegetItemCount in class AbstractSequencepublic Node item(int pos)
item in interface NodeListitem in class AbstractNodeSetpublic NodeProxy get(int pos)
AbstractNodeSet
get in interface NodeSetget in class AbstractNodeSetpublic NodeProxy get(NodeProxy p)
AbstractNodeSet
get in interface NodeSetget in class AbstractNodeSet
public NodeProxy get(DocumentImpl doc,
NodeId nodeId)
get in interface NodeSetpublic Item itemAt(int pos)
Sequence
itemAt in interface SequenceitemAt in class AbstractSequence
public NodeSet getDescendantsInSet(NodeSet al,
boolean childOnly,
boolean includeSelf,
int mode,
int contextId,
boolean copyMatches)
getDescendantsInSet
al - a NodeSet valuechildOnly - a boolean valueincludeSelf - a boolean valuemode - an int valuecontextId - an int value
NodeSet value
public NodeProxy hasDescendantsInSet(DocumentImpl doc,
NodeId ancestorId,
boolean includeSelf,
int contextId)
hasDescendantsInSet
doc - a DocumentImpl valueancestorId - a NodeId valueincludeSelf - a boolean valuecontextId - an int value
NodeProxy value
public NodeSet selectParentChild(NodeSet al,
int mode,
int contextId)
selectParentChild
selectParentChild in interface NodeSetselectParentChild in class AbstractNodeSetal - a NodeSet valuemode - an int valuecontextId - an int value
NodeSet valuepublic NodeSet filterDocuments(ExtArrayNodeSet otherSet)
filterDocuments
otherSet - an ExtArrayNodeSet value
NodeSet value
public void setSorted(DocumentImpl document,
boolean sorted)
setSorted
document - a DocumentImpl valuesorted - a boolean valuepublic void mergeDuplicates()
public void sort()
sort
public void sort(boolean mergeContexts)
sort
mergeContexts - a boolean valuepublic final void sortInDocumentOrder()
sortInDocumentOrder
public void setSelfAsContext(int contextId)
throws XPathException
setSelfAsContext in interface SequencesetSelfAsContext in class AbstractSequenceXPathException
public NodeSet selectAncestorDescendant(NodeSet al,
int mode,
boolean includeSelf,
int contextId,
boolean copyMatches)
AbstractNodeSetNodeSet.DESCENDANT, the returned node set will contain
all descendant nodes found in this node set for each ancestor. If mode is
NodeSet.ANCESTOR, the returned set will contain those ancestor nodes,
for which descendants have been found.
selectAncestorDescendant in interface NodeSetselectAncestorDescendant in class AbstractNodeSetal - a node set containing potential parent nodesmode - selection modeincludeSelf - if true, check if the ancestor node itself is contained in
the set of descendant nodes (descendant-or-self axis)contextId - used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID, the current context
will be added to each result of the selection.
public NodeSet selectPrecedingSiblings(NodeSet siblings,
int contextId)
AbstractNodeSetNodeSet.FOLLOWING, only nodes following
the context node are selected. NodeSet.PRECEDING selects
preceding nodes.
selectPrecedingSiblings in interface NodeSetselectPrecedingSiblings in class AbstractNodeSetsiblings - a node set containing potential siblingscontextId - used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID, the current context
will be added to each result of the of the selection.
public NodeSet selectFollowingSiblings(NodeSet siblings,
int contextId)
selectFollowingSiblings
selectFollowingSiblings in interface NodeSetselectFollowingSiblings in class AbstractNodeSetsiblings - a NodeSet valuecontextId - an int value
NodeSet value
public NodeSet selectAncestors(NodeSet al,
boolean includeSelf,
int contextId)
AbstractNodeSet
selectAncestors in interface NodeSetselectAncestors in class AbstractNodeSetal - node set containing potential ancestorsincludeSelf - if true, check if the ancestor node itself is contained
in this node set (ancestor-or-self axis)contextId - used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID, the current context
will be added to each result of the of the selection.
public NodeProxy parentWithChild(DocumentImpl doc,
NodeId nodeId,
boolean directParent,
boolean includeSelf)
parentWithChild
parentWithChild in interface NodeSetparentWithChild in class AbstractNodeSetdoc - a DocumentImpl valuenodeId - a NodeId valuedirectParent - a boolean valueincludeSelf - a boolean value
NodeProxy valuepublic String debugParts()
debugParts
String valuepublic int getIndexType()
AbstractNodeSetType.ITEM.
getIndexType in interface NodeSetgetIndexType in class AbstractNodeSetGeneralComparison,
ValueComparisonpublic DocumentSet getDocumentSet()
getDocumentSet
getDocumentSet in interface NodeSetgetDocumentSet in interface SequencegetDocumentSet in class AbstractNodeSetDocumentSet valuepublic void setDocumentSet(DocumentSet docs)
setDocumentSet
docs - a DocumentSet valuepublic boolean equalDocs(DocumentSet other)
equalDocs in interface DocumentSetpublic Iterator getCollectionIterator()
getCollectionIterator
getCollectionIterator in interface DocumentSetgetCollectionIterator in interface NodeSetgetCollectionIterator in interface SequencegetCollectionIterator in class AbstractNodeSetIterator valuepublic Iterator getDocumentIterator()
getDocumentIterator in interface DocumentSetpublic int getDocumentCount()
getDocumentCount in interface DocumentSetpublic DocumentImpl getDocumentAt(int pos)
getDocumentAt in interface DocumentSetpublic DocumentImpl getDoc(int docId)
getDoc in interface DocumentSetpublic XmldbURI[] getNames()
getNames in interface DocumentSetpublic DocumentSet intersection(DocumentSet other)
intersection in interface DocumentSetpublic boolean contains(DocumentSet other)
contains in interface DocumentSetpublic boolean contains(int docId)
contains in interface DocumentSetpublic NodeSet docsToNodeSet()
docsToNodeSet in interface DocumentSet
public void lock(DBBroker broker,
boolean exclusive,
boolean checkExisting)
throws LockException
lock in interface DocumentSetLockExceptionpublic void unlock(boolean exclusive)
unlock in interface DocumentSetpublic boolean hasChanged(int previousState)
hasChanged in interface NodeSethasChanged in interface SequencehasChanged in class AbstractNodeSetpublic int getState()
getState in interface NodeSetgetState in interface SequencegetState in class AbstractNodeSetpublic boolean isCacheable()
isCacheable in interface SequenceisCacheable in class AbstractSequencepublic String toString()
toString
toString in class AbstractNodeSetString value
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||