diff options
author | Anna Wawrzyniak <anna.wawrzyniak@mongodb.com> | 2022-01-12 18:42:57 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-12 20:21:07 +0000 |
commit | 5fd3e8b800b43c25d92530fc1b3e0b9bbec7bf6b (patch) | |
tree | 510cc071cf9355b65e0c29fe4d7215d37773ffba | |
parent | 4994aec2764996ebd8f4747abe75e3c0ef396987 (diff) | |
download | mongo-5fd3e8b800b43c25d92530fc1b3e0b9bbec7bf6b.tar.gz |
SERVER-59960 Make ContextCtx::root optional
-rw-r--r-- | src/mongo/db/exec/sbe/expressions/expression.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/expressions/expression.h | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/exec/sbe/expressions/expression.cpp b/src/mongo/db/exec/sbe/expressions/expression.cpp index 2072f793492..4f9ad6ce653 100644 --- a/src/mongo/db/exec/sbe/expressions/expression.cpp +++ b/src/mongo/db/exec/sbe/expressions/expression.cpp @@ -107,7 +107,9 @@ vm::CodeFragment EVariable::compileDirect(CompileCtx& ctx) const { int offset = -_var - 1; code.appendLocalVal(*_frameId, offset, _moveFrom); } else { - auto accessor = ctx.root->getAccessor(ctx, _var); + // ctx.root is optional. If root stage is not specified, then resolve the variable using + // default context rules. + auto accessor = ctx.root ? ctx.root->getAccessor(ctx, _var) : ctx.getAccessor(_var); if (_moveFrom) { code.appendMoveVal(accessor); } else { diff --git a/src/mongo/db/exec/sbe/expressions/expression.h b/src/mongo/db/exec/sbe/expressions/expression.h index 71ee0251d8a..29055c7bc96 100644 --- a/src/mongo/db/exec/sbe/expressions/expression.h +++ b/src/mongo/db/exec/sbe/expressions/expression.h @@ -237,7 +237,13 @@ struct CompileCtx { CompileCtx makeCopyForParallelUse(); CompileCtx makeCopy() const; + /** + * Root plan stage is used to resolve slot accessors introduced by PlanStage (optional). + * - if specified, the root plan stage will be used to resolve the slot accessor. + * - otherwise, if null, default context accessor resolution rules will be used. + */ PlanStage* root{nullptr}; + value::SlotAccessor* accumulator{nullptr}; std::vector<std::pair<value::SlotId, value::SlotAccessor*>> correlated; stdx::unordered_map<SpoolId, std::shared_ptr<SpoolBuffer>> spoolBuffers; |