Schema outSchema = (Schema) projNode.getAttr(PlanNode.OUTPUT_SCHEMA_ATTR);
newElem = new ProjectionElement(newContext, outSchema, projNode.getInputFields(),
projNode.getOutputFields());
} else if (node instanceof AggregateNode) {
AggregateNode aggNode = (AggregateNode) node;
newElem = new BucketedAggregationElement(newContext, aggNode);
} else if (node instanceof EvaluateExprsNode) {
EvaluateExprsNode evalNode = (EvaluateExprsNode) node;
Schema outSchema = (Schema) evalNode.getAttr(PlanNode.OUTPUT_SCHEMA_ATTR);
newElem = new EvaluationElement(newContext, evalNode.getExprs(),
evalNode.getPropagateFields(), outSchema);
} else if (node instanceof HashJoinNode) {
HashJoinNode joinNode = (HashJoinNode) node;
newElem = new HashJoinElement(newContext, joinNode);
} else {
throw new DAGOperatorException("Cannot create FlowElement for PlanNode of type: "
+ node.getClass().getName());
}
if (null != newElem) {
// Wrap the FlowElement in a DAGNode.
FlowElementNode elemHolder = new FlowElementNode(newElem);
mapChildren(node, elemHolder);
elemHolder.setId(node.getId());
// Bind the FlowElementNode to the PlanNode.
node.setAttr(LOCAL_FLOW_ELEM_KEY, elemHolder);
if (node.isRoot()) {
// Roots of the plan node => this is a root node in the flow.
mLocalFlow.addRoot(elemHolder);
}
// If we created a BucketedAggregationElement, create its timeout coprocessor.
if (newElem instanceof BucketedAggregationElement) {
BucketedAggregationElement bucketElem = (BucketedAggregationElement) newElem;
FlowElement downstream = getNodeElements(node.getChildren()).get(0).getFlowElement();
FlowElementContext timeoutContext = new DirectCoupledFlowElemContext(downstream);
BucketedAggregationElement.TimeoutEvictionElement timeoutElem =
bucketElem.getTimeoutElement(timeoutContext);
// The timeout element is now upstream to the primary downstream element of the
// BucketedAggregationElement.
downstream.registerUpstream();
timeoutElem.registerUpstream(); // BucketedAggEl't is upstream of the timeout elem.