net.esper.eql.join.assemble
Class BaseAssemblyNode

java.lang.Object
  extended by net.esper.eql.join.assemble.BaseAssemblyNode
All Implemented Interfaces:
ResultAssembler
Direct Known Subclasses:
BranchOptionalAssemblyNode, BranchRequiredAssemblyNode, CartesianProdAssemblyNode, LeafAssemblyNode, RootCartProdAssemblyNode, RootOptionalAssemblyNode, RootRequiredAssemblyNode

public abstract class BaseAssemblyNode
extends java.lang.Object
implements ResultAssembler

Represents a node in a tree responsible for assembling outer join query results.

The tree is double-linked, child nodes know each parent and parent know all child nodes.

Each specific subclass of this abstract assembly node is dedicated to assembling results for a certain event stream.


Field Summary
protected  java.util.List<BaseAssemblyNode> childNodes
          Child nodes.
protected  int numStreams
          Number of streams in statement.
protected  ResultAssembler parentNode
          Parent node.
protected  int streamNum
          Stream number.
 
Constructor Summary
protected BaseAssemblyNode(int streamNum, int numStreams)
          Ctor.
 
Method Summary
 void addChild(BaseAssemblyNode childNode)
          Add a child node.
protected  java.util.List<BaseAssemblyNode> getChildNodes()
          Returns child nodes.
static java.util.List<BaseAssemblyNode> getDescendentNodesBottomUp(BaseAssemblyNode topNode)
          Returns all descendent nodes to the top node in a list in which the utmost descendants are listed first and the top node itself is listed last.
protected  ResultAssembler getParentAssembler()
          Returns parent node.
protected  int getStreamNum()
          Returns the stream number.
protected  int[] getSubstreams()
          Returns an array of stream numbers that lists all child node's stream numbers.
abstract  void init(java.util.List<Node>[] result)
          Provides results to assembly nodes for initialization.
abstract  void print(IndentWriter indentWriter)
          Output this node using writer, not outputting child nodes.
 void printDescendends(IndentWriter indentWriter)
          Output this node and all descendent nodes using writer, outputting child nodes.
abstract  void process(java.util.List<Node>[] result)
          Process results.
 void setParentAssembler(ResultAssembler resultAssembler)
          Set parent node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.esper.eql.join.assemble.ResultAssembler
result
 

Field Detail

parentNode

protected ResultAssembler parentNode
Parent node.


childNodes

protected final java.util.List<BaseAssemblyNode> childNodes
Child nodes.


streamNum

protected final int streamNum
Stream number.


numStreams

protected final int numStreams
Number of streams in statement.

Constructor Detail

BaseAssemblyNode

protected BaseAssemblyNode(int streamNum,
                           int numStreams)
Ctor.

Parameters:
streamNum - - stream number of the event stream that this node assembles results for.
numStreams - - number of streams
Method Detail

init

public abstract void init(java.util.List<Node>[] result)
Provides results to assembly nodes for initialization.

Parameters:
result - is a list of result nodes per stream

process

public abstract void process(java.util.List<Node>[] result)
Process results.

Parameters:
result - is a list of result nodes per stream

print

public abstract void print(IndentWriter indentWriter)
Output this node using writer, not outputting child nodes.

Parameters:
indentWriter - to use for output

setParentAssembler

public void setParentAssembler(ResultAssembler resultAssembler)
Set parent node.

Parameters:
resultAssembler - is the parent node

addChild

public void addChild(BaseAssemblyNode childNode)
Add a child node.

Parameters:
childNode - to add

getStreamNum

protected int getStreamNum()
Returns the stream number.

Returns:
stream number

getChildNodes

protected java.util.List<BaseAssemblyNode> getChildNodes()
Returns child nodes.

Returns:
child nodes

getParentAssembler

protected ResultAssembler getParentAssembler()
Returns parent node.

Returns:
parent node

getSubstreams

protected int[] getSubstreams()
Returns an array of stream numbers that lists all child node's stream numbers.

Returns:
child node stream numbers

printDescendends

public void printDescendends(IndentWriter indentWriter)
Output this node and all descendent nodes using writer, outputting child nodes.

Parameters:
indentWriter - to output to

getDescendentNodesBottomUp

public static java.util.List<BaseAssemblyNode> getDescendentNodesBottomUp(BaseAssemblyNode topNode)
Returns all descendent nodes to the top node in a list in which the utmost descendants are listed first and the top node itself is listed last.

Parameters:
topNode - is the root node of a tree structure
Returns:
list of nodes with utmost descendants first ordered by level of depth in tree with top node last