|
|||||||
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
valueMethod Detail |
---|
public void reset()
reset
public boolean isEmpty()
isEmpty
isEmpty
in interface Sequence
isEmpty
in class AbstractSequence
boolean
valuepublic boolean hasOne()
hasOne
hasOne
in interface Sequence
hasOne
in class AbstractSequence
boolean
valuepublic void add(NodeProxy proxy)
add
add
in interface NodeSet
add
in class AbstractNodeSet
proxy
- a NodeProxy
valuepublic void add(NodeProxy proxy, int sizeHint)
add
in interface NodeSet
add
in class AbstractNodeSet
public int getItemType()
getItemType
getItemType
in interface Sequence
getItemType
in class AbstractNodeSet
int
valuepublic int getSizeHint(DocumentImpl doc)
getSizeHint
getSizeHint
in interface NodeSet
getSizeHint
in class AbstractNodeSet
doc
- a DocumentImpl
value
int
valuepublic NodeSetIterator iterator()
AbstractNodeSet
iterator
in interface NodeSet
iterator
in class AbstractNodeSet
public SequenceIterator iterate() throws XPathException
Sequence
iterate
in interface Sequence
iterate
in class AbstractNodeSet
XPathException
- TODOpublic SequenceIterator unorderedIterator() throws XPathException
Sequence
unorderedIterator
in interface Sequence
unorderedIterator
in class AbstractNodeSet
XPathException
public ByDocumentIterator iterateByDocument()
public boolean contains(NodeProxy proxy)
AbstractNodeSet
contains
in interface NodeSet
contains
in class AbstractNodeSet
public void addAll(NodeSet other)
AbstractNodeSet
addAll
in interface NodeSet
addAll
in class AbstractNodeSet
public int getLength()
AbstractNodeSet
getLength
in interface NodeList
getLength
in class AbstractNodeSet
public int getItemCount()
Sequence
getItemCount
in interface Sequence
getItemCount
in class AbstractSequence
public Node item(int pos)
item
in interface NodeList
item
in class AbstractNodeSet
public NodeProxy get(int pos)
AbstractNodeSet
get
in interface NodeSet
get
in class AbstractNodeSet
public NodeProxy get(NodeProxy p)
AbstractNodeSet
get
in interface NodeSet
get
in class AbstractNodeSet
public NodeProxy get(DocumentImpl doc, NodeId nodeId)
get
in interface NodeSet
public Item itemAt(int pos)
Sequence
itemAt
in interface Sequence
itemAt
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
valuepublic 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
valuepublic NodeSet selectParentChild(NodeSet al, int mode, int contextId)
selectParentChild
selectParentChild
in interface NodeSet
selectParentChild
in class AbstractNodeSet
al
- a NodeSet
valuemode
- an int
valuecontextId
- an int
value
NodeSet
valuepublic NodeSet filterDocuments(ExtArrayNodeSet otherSet)
filterDocuments
otherSet
- an ExtArrayNodeSet
value
NodeSet
valuepublic 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 Sequence
setSelfAsContext
in class AbstractSequence
XPathException
public NodeSet selectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, int contextId, boolean copyMatches)
AbstractNodeSet
NodeSet.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 NodeSet
selectAncestorDescendant
in class AbstractNodeSet
al
- 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)
AbstractNodeSet
NodeSet.FOLLOWING
, only nodes following
the context node are selected. NodeSet.PRECEDING
selects
preceding nodes.
selectPrecedingSiblings
in interface NodeSet
selectPrecedingSiblings
in class AbstractNodeSet
siblings
- 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 NodeSet
selectFollowingSiblings
in class AbstractNodeSet
siblings
- a NodeSet
valuecontextId
- an int
value
NodeSet
valuepublic NodeSet selectAncestors(NodeSet al, boolean includeSelf, int contextId)
AbstractNodeSet
selectAncestors
in interface NodeSet
selectAncestors
in class AbstractNodeSet
al
- 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 NodeSet
parentWithChild
in class AbstractNodeSet
doc
- a DocumentImpl
valuenodeId
- a NodeId
valuedirectParent
- a boolean
valueincludeSelf
- a boolean
value
NodeProxy
valuepublic String debugParts()
debugParts
String
valuepublic int getIndexType()
AbstractNodeSet
Type.ITEM
.
getIndexType
in interface NodeSet
getIndexType
in class AbstractNodeSet
GeneralComparison
,
ValueComparison
public DocumentSet getDocumentSet()
getDocumentSet
getDocumentSet
in interface NodeSet
getDocumentSet
in interface Sequence
getDocumentSet
in class AbstractNodeSet
DocumentSet
valuepublic void setDocumentSet(DocumentSet docs)
setDocumentSet
docs
- a DocumentSet
valuepublic boolean equalDocs(DocumentSet other)
equalDocs
in interface DocumentSet
public Iterator getCollectionIterator()
getCollectionIterator
getCollectionIterator
in interface DocumentSet
getCollectionIterator
in interface NodeSet
getCollectionIterator
in interface Sequence
getCollectionIterator
in class AbstractNodeSet
Iterator
valuepublic Iterator getDocumentIterator()
getDocumentIterator
in interface DocumentSet
public int getDocumentCount()
getDocumentCount
in interface DocumentSet
public DocumentImpl getDocumentAt(int pos)
getDocumentAt
in interface DocumentSet
public DocumentImpl getDoc(int docId)
getDoc
in interface DocumentSet
public XmldbURI[] getNames()
getNames
in interface DocumentSet
public DocumentSet intersection(DocumentSet other)
intersection
in interface DocumentSet
public boolean contains(DocumentSet other)
contains
in interface DocumentSet
public boolean contains(int docId)
contains
in interface DocumentSet
public NodeSet docsToNodeSet()
docsToNodeSet
in interface DocumentSet
public void lock(DBBroker broker, boolean exclusive, boolean checkExisting) throws LockException
lock
in interface DocumentSet
LockException
public void unlock(boolean exclusive)
unlock
in interface DocumentSet
public boolean hasChanged(int previousState)
hasChanged
in interface NodeSet
hasChanged
in interface Sequence
hasChanged
in class AbstractNodeSet
public int getState()
getState
in interface NodeSet
getState
in interface Sequence
getState
in class AbstractNodeSet
public boolean isCacheable()
isCacheable
in interface Sequence
isCacheable
in class AbstractSequence
public String toString()
toString
toString
in class AbstractNodeSet
String
value
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |