Class Traverser
- java.lang.Object
-
- org.apache.iotdb.db.metadata.mtree.traverser.Traverser
-
- Direct Known Subclasses:
CollectorTraverser,CounterTraverser,MeasurementGroupByLevelCounter
public abstract class Traverser extends java.lang.ObjectThis class defines the main traversal framework and declares some methods for result process extension. This class could be extended to implement concrete tasks.
Currently, the tasks are classified into two type:- counter: to count the node num or measurement num that matches the path pattern
- collector: to collect customized results of the matched node or measurement
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisInTemplateprotected booleanisPrefixMatchprotected booleanisPrefixStartprotected java.lang.String[]nodesprotected booleanshouldTraverseTemplateprotected intstartIndexprotected intstartLevelprotected IMNodestartNodeprotected IMTreeStorestoreprotected java.util.Map<java.lang.Integer,Template>templateMapprotected java.util.Deque<IMNode>traverseContext
-
Constructor Summary
Constructors Constructor Description Traverser(IMNode startNode, org.apache.iotdb.commons.path.PartialPath path, IMTreeStore store)To traverse subtree under root.sg, e.g., init Traverser(root, "root.sg.**")
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.apache.iotdb.commons.path.PartialPathgetCurrentPartialPath(IMNode currentNode)protected java.lang.String[]getCurrentPathNodes(IMNode currentNode)protected IMNodegetStorageGroupNodeInTraversePath(IMNode currentNode)protected TemplategetUpperTemplate(IMNode node)protected abstract booleanprocessFullMatchedMNode(IMNode node, int idx, int level)full match: root.sg.d full match root.sg.**(pattern)protected abstract booleanprocessInternalMatchedMNode(IMNode node, int idx, int level)internal match: root.sg internal match root.sg.**(pattern)protected voidprocessMultiLevelWildcard(IMNode node, int idx, int level)protected voidprocessNameMatch(IMNode node, int idx, int level)protected voidprocessOneLevelWildcard(IMNode node, int idx, int level)voidsetPrefixMatch(boolean isPrefixMatch)voidsetTemplateMap(java.util.Map<java.lang.Integer,Template> templateMap)voidtraverse()The interface to start the traversal.protected voidtraverse(IMNode node, int idx, int level)The recursive method for MTree traversal.
-
-
-
Field Detail
-
store
protected IMTreeStore store
-
startNode
protected IMNode startNode
-
nodes
protected java.lang.String[] nodes
-
startIndex
protected int startIndex
-
startLevel
protected int startLevel
-
isPrefixStart
protected boolean isPrefixStart
-
traverseContext
protected java.util.Deque<IMNode> traverseContext
-
isInTemplate
protected boolean isInTemplate
-
shouldTraverseTemplate
protected boolean shouldTraverseTemplate
-
templateMap
protected java.util.Map<java.lang.Integer,Template> templateMap
-
isPrefixMatch
protected boolean isPrefixMatch
-
-
Constructor Detail
-
Traverser
public Traverser(IMNode startNode, org.apache.iotdb.commons.path.PartialPath path, IMTreeStore store) throws org.apache.iotdb.commons.exception.MetadataException
To traverse subtree under root.sg, e.g., init Traverser(root, "root.sg.**")- Parameters:
startNode- denote which tree to traverse by passing its rootpath- use wildcard to specify which part to traverse- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
-
Method Detail
-
traverse
public void traverse() throws org.apache.iotdb.commons.exception.MetadataExceptionThe interface to start the traversal. The node process should be defined before traversal by overriding or implement concerned methods.- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
traverse
protected void traverse(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
The recursive method for MTree traversal. If the node matches nodes[idx], then do some operation and traverse the children with nodes[idx+1].- Parameters:
node- current node that match the targetName in given pathidx- the index of targetName in given pathlevel- the level of current node in MTree- Throws:
org.apache.iotdb.commons.exception.MetadataException- some result process may throw MetadataException
-
processInternalMatchedMNode
protected abstract boolean processInternalMatchedMNode(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
internal match: root.sg internal match root.sg.**(pattern)- Returns:
- whether this branch of recursive traversal should stop; if true, stop
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
processFullMatchedMNode
protected abstract boolean processFullMatchedMNode(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
full match: root.sg.d full match root.sg.**(pattern)- Returns:
- whether this branch of recursive traversal should stop; if true, stop
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
processMultiLevelWildcard
protected void processMultiLevelWildcard(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
processOneLevelWildcard
protected void processOneLevelWildcard(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
processNameMatch
protected void processNameMatch(IMNode node, int idx, int level) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setTemplateMap
public void setTemplateMap(java.util.Map<java.lang.Integer,Template> templateMap)
-
setPrefixMatch
public void setPrefixMatch(boolean isPrefixMatch)
-
getCurrentPartialPath
protected org.apache.iotdb.commons.path.PartialPath getCurrentPartialPath(IMNode currentNode)
- Parameters:
currentNode- the node need to get the full path of- Returns:
- full path from traverse start node to the current node
-
getCurrentPathNodes
protected java.lang.String[] getCurrentPathNodes(IMNode currentNode)
-
-