| 51 | } |
| 52 | |
| 53 | Status Expr::CreateTree(const TExpr& texpr, ObjectPool* pool, Expr* root) { |
| 54 | DCHECK(!texpr.nodes.empty()); |
| 55 | DCHECK(root != nullptr); |
| 56 | // The root of the tree at nodes[0] is already created and stored in 'root'. |
| 57 | int child_node_idx = 0; |
| 58 | int num_children = texpr.nodes[0].num_children; |
| 59 | for (int i = 0; i < num_children; ++i) { |
| 60 | ++child_node_idx; |
| 61 | Status status = CreateTreeInternal(texpr.nodes, pool, root, &child_node_idx); |
| 62 | if (UNLIKELY(!status.ok())) { |
| 63 | LOG(ERROR) << "Could not construct expr tree.\n" << status.GetDetail() << "\n" |
| 64 | << apache::thrift::ThriftDebugString(texpr); |
| 65 | return status; |
| 66 | } |
| 67 | } |
| 68 | if (UNLIKELY(child_node_idx + 1 != texpr.nodes.size())) { |
| 69 | return Status("Expression tree only partially reconstructed. Not all thrift " \ |
| 70 | "nodes were used."); |
| 71 | } |
| 72 | return Status::OK(); |
| 73 | } |
| 74 | |
| 75 | Status Expr::CreateTreeInternal(const vector<TExprNode>& nodes, ObjectPool* pool, |
| 76 | Expr* root, int* child_node_idx) { |