| 73 | } |
| 74 | |
| 75 | Status Expr::CreateTreeInternal(const vector<TExprNode>& nodes, ObjectPool* pool, |
| 76 | Expr* root, int* child_node_idx) { |
| 77 | // propagate error case |
| 78 | if (*child_node_idx >= nodes.size()) { |
| 79 | return Status("Failed to reconstruct expression tree from thrift."); |
| 80 | } |
| 81 | |
| 82 | const TExprNode& texpr_node = nodes[*child_node_idx]; |
| 83 | DCHECK_NE(texpr_node.node_type, TExprNodeType::AGGREGATE_EXPR); |
| 84 | ScalarExpr* child_expr; |
| 85 | RETURN_IF_ERROR(ScalarExpr::CreateNode(texpr_node, pool, &child_expr)); |
| 86 | root->children_.push_back(child_expr); |
| 87 | |
| 88 | int num_children = nodes[*child_node_idx].num_children; |
| 89 | for (int i = 0; i < num_children; ++i) { |
| 90 | *child_node_idx += 1; |
| 91 | RETURN_IF_ERROR(CreateTreeInternal(nodes, pool, child_expr, child_node_idx)); |
| 92 | DCHECK(child_expr->GetChild(i) != nullptr); |
| 93 | } |
| 94 | return Status::OK(); |
| 95 | } |
| 96 | |
| 97 | void Expr::Close() { |
| 98 | for (ScalarExpr* child : children_) child->Close(); |