diff options
author | David Storch <david.storch@mongodb.com> | 2022-11-28 21:39:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-28 22:33:20 +0000 |
commit | e2d6db6b489a9f4514c7d66462d6f3b0d1835bd4 (patch) | |
tree | 9398ce4f6c2ad44411caa8c5b329c67e5b1625fb /src/mongo/db/exec/sbe/expression_test_base.h | |
parent | 24d547dfe6adf659165ced87b135d7245d085c03 (diff) | |
download | mongo-e2d6db6b489a9f4514c7d66462d6f3b0d1835bd4.tar.gz |
SERVER-70395 Make stage builders generate partial agg combining exprs (part 1)
This patch handles $min, $max, $first, and $last. The
remaining accumulators will be implemented as follow-up
work.
Diffstat (limited to 'src/mongo/db/exec/sbe/expression_test_base.h')
-rw-r--r-- | src/mongo/db/exec/sbe/expression_test_base.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/exec/sbe/expression_test_base.h b/src/mongo/db/exec/sbe/expression_test_base.h index 2cc0f8ded6d..e3565016243 100644 --- a/src/mongo/db/exec/sbe/expression_test_base.h +++ b/src/mongo/db/exec/sbe/expression_test_base.h @@ -73,6 +73,24 @@ protected: } /** + * Compiles 'expr' to bytecode when 'expr' is computing an aggregate. The current aggregate + * value can be read out of the provided 'aggAccessor'. + * + * Note that when actually executing the resulting bytecode, the caller is responsible for + * setting the value of 'aggAccessor' to the new resulting aggregate value. + */ + std::unique_ptr<vm::CodeFragment> compileAggExpression(const EExpression& expr, + value::SlotAccessor* aggAccessor) { + ON_BLOCK_EXIT([this] { + _ctx.aggExpression = false; + _ctx.accumulator = nullptr; + }); + _ctx.aggExpression = true; + _ctx.accumulator = aggAccessor; + return expr.compile(_ctx); + } + + /** * The caller takes ownership of the Value returned by this function and must call * 'releaseValue()' on it. The preferred way to ensure the Value is properly released is to * immediately store it in a ValueGuard. |