| 629 | } // namespace |
| 630 | |
| 631 | std::vector<std::shared_ptr<Expr>> compileExpressions( |
| 632 | const std::vector<TypedExprPtr>& sources, |
| 633 | core::ExecCtx* execCtx, |
| 634 | ExprSet* exprSet, |
| 635 | bool enableConstantFolding) { |
| 636 | Scope scope({}, nullptr, exprSet); |
| 637 | std::vector<std::shared_ptr<Expr>> exprs; |
| 638 | exprs.reserve(sources.size()); |
| 639 | |
| 640 | // Precompute a set of function calls that support flattening. This allows to |
| 641 | // lock function registry once vs. locking for each function call. |
| 642 | auto flatteningCandidates = collectFlatteningCandidates(sources); |
| 643 | |
| 644 | for (auto& source : sources) { |
| 645 | #ifdef ENABLE_BOLT_EXPR_JIT |
| 646 | exprs.push_back(compileExpression( |
| 647 | source, |
| 648 | &scope, |
| 649 | execCtx->queryCtx()->queryConfig(), |
| 650 | execCtx->pool(), |
| 651 | flatteningCandidates, |
| 652 | enableConstantFolding, |
| 653 | true)); |
| 654 | #else |
| 655 | exprs.push_back(compileExpression( |
| 656 | source, |
| 657 | &scope, |
| 658 | execCtx->queryCtx()->queryConfig(), |
| 659 | execCtx->pool(), |
| 660 | flatteningCandidates, |
| 661 | enableConstantFolding)); |
| 662 | #endif |
| 663 | } |
| 664 | return exprs; |
| 665 | } |
| 666 | |
| 667 | } // namespace bytedance::bolt::exec |