@Override protected void toThrift(TPlanNode msg) { msg.node_type = TPlanNodeType.AGGREGATION_NODE; msg.agg_node = new TAggregationNode( Expr.treesToThrift(aggInfo.getAggregateExprs()), aggInfo.getAggTupleId().asInt(), needsFinalize); List<Expr> groupingExprs = aggInfo.getGroupingExprs(); if (groupingExprs != null) { msg.agg_node.setGrouping_exprs(Expr.treesToThrift(groupingExprs)); } }
/** * Look up the partition corresponding to the plan node (identified by nodeId) and a file split. */ private THdfsPartition findPartition(int nodeId, THdfsFileSplit split) { TPlanNode node = planMap_.get(nodeId); Preconditions.checkNotNull(node); Preconditions.checkState(node.node_id == nodeId && node.isSetHdfs_scan_node()); THdfsScanNode scanNode = node.getHdfs_scan_node(); int tupleId = scanNode.getTuple_id(); TTupleDescriptor tupleDesc = tupleMap_.get(tupleId); Preconditions.checkNotNull(tupleDesc); Preconditions.checkState(tupleDesc.id == tupleId); TTableDescriptor tableDesc = tableMap_.get(tupleDesc.tableId); Preconditions.checkNotNull(tableDesc); Preconditions.checkState(tableDesc.id == tupleDesc.tableId && tableDesc.isSetHdfsTable()); THdfsTable hdfsTable = tableDesc.getHdfsTable(); THdfsPartition partition = hdfsTable.getPartitions().get(split.partition_id); Preconditions.checkNotNull(partition); Preconditions.checkState(partition.id == split.partition_id); return partition; }
@Override protected void toThrift(TPlanNode msg) { // TODO: retire this once the migration to the new plan is complete msg.hdfs_scan_node = new THdfsScanNode(desc.getId().asInt()); msg.node_type = TPlanNodeType.HDFS_SCAN_NODE; }
// Append a flattened version of this plan node, including all children, to 'container'. private void treeToThriftHelper(TPlan container) { TPlanNode msg = new TPlanNode(); msg.node_id = id_.asInt(); msg.limit = limit_; TExecStats estimatedStats = new TExecStats(); estimatedStats.setCardinality(cardinality_); estimatedStats.setMemory_used(perHostMemCost_); msg.setLabel(getDisplayLabel()); msg.setLabel_detail(getDisplayLabelDetail()); msg.setEstimated_stats(estimatedStats); msg.setRow_tuples(Lists.<Integer>newArrayListWithCapacity(tupleIds_.size())); msg.setNullable_tuples(Lists.<Boolean>newArrayListWithCapacity(tupleIds_.size())); for (TupleId tid : tupleIds_) { msg.addToRow_tuples(tid.asInt()); msg.addToNullable_tuples(nullableTupleIds_.contains(tid)); } for (Expr e : conjuncts_) { msg.addToConjuncts(e.treeToThrift()); } toThrift(msg); container.addToNodes(msg); // For the purpose of the BE consider ExchangeNodes to have no children. if (this instanceof ExchangeNode) { msg.num_children = 0; return; } else { msg.num_children = children_.size(); for (PlanNode child : children_) { child.treeToThriftHelper(container); } } }