private static AbstractPlanNode addCoordinatorToDMLNode ( AbstractPlanNode dmlRoot , boolean isReplicated ) { dmlRoot = SubPlanAssembler . addSendReceivePair ( dmlRoot ) ; AbstractPlanNode sumOrLimitNode ; if ( isReplicated ) { // Replicated table DML result doesn't need to be summed. All partitions should // modify the same number of tuples in replicated table, so just pick the result from // any partition. LimitPlanNode limitNode = new LimitPlanNode ( ) ; sumOrLimitNode = limitNode ; limitNode . setLimit ( 1 ) ; } else { // create the nodes being pushed on top of dmlRoot. AggregatePlanNode countNode = new AggregatePlanNode ( ) ; sumOrLimitNode = countNode ; // configure the count aggregate (sum) node to produce a single // output column containing the result of the sum. // Create a TVE that should match the tuple count input column // This TVE is magic. // really really need to make this less hard-wired TupleValueExpression count_tve = new TupleValueExpression ( AbstractParsedStmt . TEMP_TABLE_NAME , AbstractParsedStmt . TEMP_TABLE_NAME , "modified_tuples" , "modified_tuples" , 0 ) ; count_tve . setValueType ( VoltType . BIGINT ) ; count_tve . setValueSize ( VoltType . BIGINT . getLengthInBytesForFixedTypes ( ) ) ; countNode . addAggregate ( ExpressionType . AGGREGATE_SUM , false , 0 , count_tve ) ; // The output column. Not really based on a TVE (it is really the // count expression represented by the count configured above). But // this is sufficient for now. This looks identical to the above // TVE but it's logically different so we'll create a fresh one. TupleValueExpression tve = new TupleValueExpression ( AbstractParsedStmt . TEMP_TABLE_NAME , AbstractParsedStmt . TEMP_TABLE_NAME , "modified_tuples" , "modified_tuples" , 0 ) ; tve . setValueType ( VoltType . BIGINT ) ; tve . setValueSize ( VoltType . BIGINT . getLengthInBytesForFixedTypes ( ) ) ; NodeSchema count_schema = new NodeSchema ( ) ; count_schema . addColumn ( AbstractParsedStmt . TEMP_TABLE_NAME , AbstractParsedStmt . TEMP_TABLE_NAME , "modified_tuples" , "modified_tuples" , tve ) ; countNode . setOutputSchema ( count_schema ) ; } // connect the nodes to build the graph sumOrLimitNode . addAndLinkChild ( dmlRoot ) ; SendPlanNode sendNode = new SendPlanNode ( ) ; sendNode . addAndLinkChild ( sumOrLimitNode ) ; return sendNode ; }
Add a receive node a sum or limit node and a send node to the given DML node . If the DML target is a replicated table it will add a limit node otherwise it adds a sum node .