| 78 | } |
| 79 | |
| 80 | Status ScalarExpr::Create(const TExpr& texpr, const RowDescriptor& row_desc, |
| 81 | FragmentState* state, ObjectPool* pool, ScalarExpr** scalar_expr) { |
| 82 | *scalar_expr = nullptr; |
| 83 | ScalarExpr* root; |
| 84 | RETURN_IF_ERROR(CreateNode(texpr.nodes[0], pool, &root)); |
| 85 | RETURN_IF_ERROR(Expr::CreateTree(texpr, pool, root)); |
| 86 | // Assume that the root is a potential entry point for interpreted callers. |
| 87 | // This is not always true but would require some work to determine for |
| 88 | // each of the callsites of Create(). |
| 89 | // TODO: fix this - reducing the number of entry points would reduce codegen overhead |
| 90 | // somewhat. |
| 91 | Status status = root->Init(row_desc, /*is_entry_point*/ true, state); |
| 92 | if (UNLIKELY(!status.ok())) { |
| 93 | root->Close(); |
| 94 | return status; |
| 95 | } |
| 96 | int fn_ctx_idx = 0; |
| 97 | root->AssignFnCtxIdx(&fn_ctx_idx); |
| 98 | *scalar_expr = root; |
| 99 | return Status::OK(); |
| 100 | } |
| 101 | |
| 102 | Status ScalarExpr::Create(const vector<TExpr>& texprs, const RowDescriptor& row_desc, |
| 103 | FragmentState* state, ObjectPool* pool, vector<ScalarExpr*>* exprs) { |