AbstractPlanNode subSelectRoot = subAssembler.nextPlan();
if (subSelectRoot == null)
return null;
// generate the delete node with the right target table
DeletePlanNode deleteNode = new DeletePlanNode(m_context, getNextPlanNodeId());
deleteNode.setTargetTableName(targetTable.getTypeName());
ProjectionPlanNode projectionNode = new ProjectionPlanNode(m_context, getNextPlanNodeId());
AbstractExpression addressExpr = new TupleAddressExpression();
PlanColumn colInfo = m_context.getPlanColumn(addressExpr, "tuple_address");
projectionNode.appendOutputColumn(colInfo);
if (m_singlePartition == true) {
assert(subSelectRoot instanceof AbstractScanPlanNode);
// if the scan below matches all nodes, we can throw away the scan
// nodes and use a truncate delete node
if ((subSelectRoot instanceof SeqScanPlanNode)
&& (((AbstractScanPlanNode) subSelectRoot).getPredicate() == null)) {
deleteNode.setTruncate(true);
return deleteNode;
}
// OPTIMIZATION: Projection Inline
// If the root node we got back from createSelectTree() is an
// AbstractScanNode, then
// we put the Projection node we just created inside of it
subSelectRoot.addInlinePlanNode(projectionNode);
// connect the nodes to build the graph
deleteNode.addAndLinkChild(subSelectRoot);
// XXX: PAVLO
if (INCLUDE_SEND_FOR_ALL) {
SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
sendNode.setFake(true);
sendNode.addAndLinkChild(deleteNode);
sendNode.setOutputColumns(deleteNode.getOutputColumnGUIDs());
return sendNode;
} else {
return deleteNode;
}
} else {
// make sure the thing we have is a receive node which
// indicates it's a multi-site plan
assert (subSelectRoot instanceof ReceivePlanNode);
//
// put the delete node in the right place
//
// get the recv node
ReceivePlanNode recvNode = (ReceivePlanNode) subSelectRoot;
// get the send node
assert (recvNode.getChildPlanNodeCount() == 1);
AbstractPlanNode sendNode = recvNode.getChild(0);
// get the scan node and unlink
assert (sendNode.getChildPlanNodeCount() == 1);
AbstractPlanNode scanNode = sendNode.getChild(0);
sendNode.unlinkChild(scanNode);
// link in the delete node
assert (scanNode instanceof AbstractScanPlanNode);
scanNode.addInlinePlanNode(projectionNode);
deleteNode.addAndLinkChild(scanNode);
AbstractPlanNode combineNode = insertCountInDMLPlan(deleteNode);
sendNode.addAndLinkChild(combineNode);
// fix the receive node's output columns