|
||||||||||
| 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
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 | |
protected int |
initalSize
|
protected int |
lastDoc
|
protected org.exist.dom.ExtArrayNodeSet.Part |
lastPart
|
protected int |
size
|
| Fields inherited from class org.exist.dom.AbstractNodeSet |
hasMixedContent, hasTextIndex, indexType, LOG |
| 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()
|
|
ExtArrayNodeSet(int initialArraySize)
|
|
ExtArrayNodeSet(int initialDocsCount,
int initialArraySize)
|
|
| Method Summary | |
void |
add(NodeProxy proxy)
Add a new proxy object to the node set. |
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(DocumentImpl doc,
long nodeId)
|
boolean |
contains(NodeProxy proxy)
Check if this node set contains a node matching the document and node-id of the given NodeProxy object. |
boolean |
containsDoc(DocumentImpl doc)
Check if this node set contains nodes belonging to the given document. |
NodeProxy |
get(DocumentImpl doc,
long nodeId)
Get a node from this node set matching the document and node id. |
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. |
DocumentSet |
getDocumentSet()
Returns the set of documents from which the node items in this sequence have been selected. |
int |
getIndexType()
If all nodes in this set have an index, returns the common supertype used to build the index, e.g. |
int |
getItemType()
Return the primary type to which all items in this sequence belong. |
int |
getLength()
Return the number of nodes contained in this node set. |
protected org.exist.dom.ExtArrayNodeSet.Part |
getPart(DocumentImpl doc,
boolean create,
int sizeHint)
|
void |
getRange(NodeSet result,
DocumentImpl doc,
long lower,
long upper)
Return a sub-range of this node set containing the range of nodes greater than or including the lower node and smaller than or including the upper node. |
int |
getSizeHint(DocumentImpl doc)
Get a hint about how many nodes in this node set belong to the specified document. |
int |
getState()
|
boolean |
hasChanged(int previousState)
|
protected NodeSet |
hasChildrenInSet(NodeSet al,
int mode,
int contextId)
Get all children of the given parent node contained in this node set. |
org.w3c.dom.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. |
NodeSetIterator |
iterator()
Return an iterator on the nodes in this list. |
void |
mergeDuplicates()
Remove all duplicate nodes, but merge their contexts. |
NodeProxy |
parentWithChild(DocumentImpl doc,
long gid,
boolean directParent,
boolean includeSelf,
int level)
Check if the node identified by its node id has an ancestor contained in this node set and return the ancestor found. |
void |
remove(NodeProxy node)
Remove a node. |
NodeSet |
selectAncestorDescendant(NodeSet al,
int mode,
boolean includeSelf,
int contextId)
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)
Select all nodes from the passed node set, which are following siblings of the nodes in this set. |
NodeSet |
selectParentChild(NodeSet al,
int mode,
int contextId)
Check if any child nodes are found within this node set for a given set of potential ancestor nodes. |
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)
|
void |
setSelfAsContext(int contextId)
|
void |
sort()
|
void |
sort(boolean mergeContexts)
|
void |
sortInDocumentOrder()
|
java.lang.String |
toString()
|
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, getAncestors, getContextNodes, getParents, hasMixedContent, hasTextIndex, intersection, isCached, isPersistentSet, parentWithChild, parentWithChild, parentWithChild, removeDuplicates, selectFollowing, selectParentChild, selectPreceding, setIsCached, toNodeSet, union |
| Methods inherited from class org.exist.xquery.value.AbstractSequence |
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, toJavaObject |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.exist.xquery.value.Sequence |
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, toJavaObject |
| Field Detail |
protected int initalSize
protected int size
protected int lastDoc
protected org.exist.dom.ExtArrayNodeSet.Part lastPart
| Constructor Detail |
public ExtArrayNodeSet()
public ExtArrayNodeSet(int initialDocsCount,
int initialArraySize)
public ExtArrayNodeSet(int initialArraySize)
| Method Detail |
protected org.exist.dom.ExtArrayNodeSet.Part getPart(DocumentImpl doc,
boolean create,
int sizeHint)
public boolean containsDoc(DocumentImpl doc)
AbstractNodeSet
containsDoc in interface NodeSetcontainsDoc in class AbstractNodeSetdoc -
public void add(NodeProxy proxy)
AbstractNodeSet
add in interface NodeSetadd in class AbstractNodeSetproxy -
public void add(NodeProxy proxy,
int sizeHint)
add in interface NodeSetadd in class AbstractNodeSetproxy - sizeHint - public int getItemType()
SequenceType.NODE for node sets, Type.ITEM
for other sequences with mixed items.
getItemType in interface SequencegetItemType in class AbstractNodeSetpublic int getSizeHint(DocumentImpl doc)
AbstractNodeSet
getSizeHint in interface NodeSetgetSizeHint in class AbstractNodeSetdoc -
public NodeSetIterator iterator()
AbstractNodeSet
iterator in interface NodeSetiterator in class AbstractNodeSetpublic SequenceIterator iterate()
Sequence
iterate in interface Sequenceiterate in class AbstractNodeSetpublic SequenceIterator unorderedIterator()
Sequence
unorderedIterator in interface SequenceunorderedIterator in class AbstractNodeSet
public boolean contains(DocumentImpl doc,
long nodeId)
public boolean contains(NodeProxy proxy)
AbstractNodeSet
contains in interface NodeSetcontains in class AbstractNodeSetproxy -
public void addAll(NodeSet other)
AbstractNodeSet
addAll in interface NodeSetaddAll in class AbstractNodeSetother - public int getLength()
AbstractNodeSet
getLength in interface NodeSetgetLength in class AbstractNodeSetpublic org.w3c.dom.Node item(int pos)
item in interface org.w3c.dom.NodeListitem in class AbstractNodeSetpublic NodeProxy get(int pos)
AbstractNodeSet
get in interface NodeSetget in class AbstractNodeSetpos -
public NodeProxy get(NodeProxy p)
AbstractNodeSet
get in interface NodeSetget in class AbstractNodeSetp -
public NodeProxy get(DocumentImpl doc,
long nodeId)
AbstractNodeSet
get in interface NodeSetget in class AbstractNodeSetdoc - nodeId -
public Item itemAt(int pos)
Sequence
itemAt in interface SequenceitemAt in class AbstractSequencepublic void remove(NodeProxy node)
AbstractNodeSet
remove in class AbstractNodeSetnode -
public void getRange(NodeSet result,
DocumentImpl doc,
long lower,
long upper)
AbstractNodeSet
getRange in interface NodeSetgetRange in class AbstractNodeSetdoc - lower - upper -
protected NodeSet hasChildrenInSet(NodeSet al,
int mode,
int contextId)
AbstractNodeSetNodeSet.DESCENDANT, the returned node set will contain
all children found in this node set. If mode is NodeSet.ANCESTOR,
the parent itself will be returned if it has child nodes in this set.
hasChildrenInSet in class AbstractNodeSetmode -
public void mergeDuplicates()
public void sort()
public void sort(boolean mergeContexts)
public final void sortInDocumentOrder()
public void setSelfAsContext(int contextId)
setSelfAsContext in interface SequencesetSelfAsContext in class AbstractSequence
public NodeSet selectParentChild(NodeSet al,
int mode,
int contextId)
AbstractNodeSetNodeSet.DESCENDANT, the returned node set will contain
all child nodes found in this node set for each parent node. If mode is
NodeSet.ANCESTOR, the returned set will contain those parent nodes,
for which children have been found.
selectParentChild in interface NodeSetselectParentChild in class AbstractNodeSetal - a node set containing potential parent nodesmode - selection modecontextId - 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 selectAncestorDescendant(NodeSet al,
int mode,
boolean includeSelf,
int contextId)
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 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)
NodeSet
selectFollowingSiblings in interface NodeSetselectFollowingSiblings in class AbstractNodeSet
public NodeSet selectAncestors(NodeSet al,
boolean includeSelf,
int contextId)
AbstractNodeSet
selectAncestors in interface NodeSetselectAncestors in class AbstractNodeSetincludeSelf - if true, check if the ancestor node itself is contained
in this node set (ancestor-or-self axis)
public NodeProxy parentWithChild(DocumentImpl doc,
long gid,
boolean directParent,
boolean includeSelf,
int level)
AbstractNodeSet
parentWithChild in interface NodeSetparentWithChild in class AbstractNodeSetpublic int getIndexType()
AbstractNodeSetType.ITEM.
getIndexType in interface NodeSetgetIndexType in class AbstractNodeSetGeneralComparison,
ValueComparisonpublic DocumentSet getDocumentSet()
Sequence
getDocumentSet in interface NodeSetgetDocumentSet in class AbstractNodeSetpublic void setDocumentSet(DocumentSet docs)
public boolean hasChanged(int previousState)
hasChanged in interface NodeSethasChanged in class AbstractNodeSetpublic int getState()
getState in interface NodeSetgetState in class AbstractNodeSetpublic java.lang.String toString()
toString in class AbstractNodeSet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||