summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/mr_common.cpp
diff options
context:
space:
mode:
authorKatherine Wu <katherine.wu@mongodb.com>2020-02-07 21:30:59 +0000
committerevergreen <evergreen@mongodb.com>2020-02-07 21:30:59 +0000
commit48e9e0edecd6a0359e809ba041c898244cb0cb01 (patch)
tree82be6f56852b34c34230d2897e42bd292e1cdb06 /src/mongo/db/commands/mr_common.cpp
parent1d0eac80c06f6fabdccaaa77d985f283192f94a9 (diff)
downloadmongo-48e9e0edecd6a0359e809ba041c898244cb0cb01.tar.gz
SERVER-45453 Change name and usage of '$_internalJs' to '$function'
Diffstat (limited to 'src/mongo/db/commands/mr_common.cpp')
-rw-r--r--src/mongo/db/commands/mr_common.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp
index fcdf998e125..098c702f408 100644
--- a/src/mongo/db/commands/mr_common.cpp
+++ b/src/mongo/db/commands/mr_common.cpp
@@ -52,7 +52,8 @@
#include "mongo/db/pipeline/document_source_single_document_transformation.h"
#include "mongo/db/pipeline/document_source_sort.h"
#include "mongo/db/pipeline/document_source_unwind.h"
-#include "mongo/db/pipeline/expression_javascript.h"
+#include "mongo/db/pipeline/expression_function.h"
+#include "mongo/db/pipeline/expression_js_emit.h"
#include "mongo/db/query/util/make_data_structure.h"
#include "mongo/util/intrusive_counter.h"
#include "mongo/util/log.h"
@@ -139,14 +140,15 @@ auto translateReduce(boost::intrusive_ptr<ExpressionContext> expCtx, std::string
auto translateFinalize(boost::intrusive_ptr<ExpressionContext> expCtx,
MapReduceJavascriptCodeOrNull codeObj) {
return codeObj.getCode().map([&](auto&& code) {
- auto jsExpression = ExpressionInternalJs::create(
+ auto jsExpression = ExpressionFunction::create(
expCtx,
ExpressionArray::create(
expCtx,
make_vector<boost::intrusive_ptr<Expression>>(
ExpressionFieldPath::parse(expCtx, "$_id", expCtx->variablesParseState),
ExpressionFieldPath::parse(expCtx, "$value", expCtx->variablesParseState))),
- code);
+ code,
+ ExpressionFunction::kJavaScript);
auto node = std::make_unique<projection_executor::InclusionNode>(
ProjectionPolicies{ProjectionPolicies::DefaultIdPolicy::kIncludeId});
node->addProjectionForPath(FieldPath{"_id"s});
@@ -187,23 +189,24 @@ auto translateOutReduce(boost::intrusive_ptr<ExpressionContext> expCtx,
// Because of communication for sharding, $merge must hold on to a serializable BSON object
// at the moment so we reparse here. Note that the reduce function signature expects 2
// arguments, the first being the key and the second being the array of values to reduce.
- auto reduceObj = BSON("args" << BSON_ARRAY("$_id" << BSON_ARRAY("$value"
- << "$$new.value"))
- << "eval" << reduceCode);
+ auto reduceObj =
+ BSON("args" << BSON_ARRAY("$_id" << BSON_ARRAY("$value"
+ << "$$new.value"))
+ << "body" << reduceCode << "lang" << ExpressionFunction::kJavaScript);
- auto reduceSpec =
- BSON(DocumentSourceProject::kStageName
- << BSON("value" << BSON(ExpressionInternalJs::kExpressionName << reduceObj)));
+ auto reduceSpec = BSON(DocumentSourceProject::kStageName << BSON(
+ "value" << BSON(ExpressionFunction::kExpressionName << reduceObj)));
auto pipelineSpec = boost::make_optional(std::vector<BSONObj>{reduceSpec});
// Build finalize $project stage if given.
if (finalizeCode && finalizeCode->hasCode()) {
auto finalizeObj = BSON("args" << BSON_ARRAY("$_id"
<< "$value")
- << "eval" << finalizeCode->getCode().get());
+ << "body" << finalizeCode->getCode().get() << "lang"
+ << ExpressionFunction::kJavaScript);
auto finalizeSpec =
BSON(DocumentSourceProject::kStageName
- << BSON("value" << BSON(ExpressionInternalJs::kExpressionName << finalizeObj)));
+ << BSON("value" << BSON(ExpressionFunction::kExpressionName << finalizeObj)));
pipelineSpec->emplace_back(std::move(finalizeSpec));
}