summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/parsed_add_fields.h
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2016-12-13 10:15:08 -0500
committerCharlie Swanson <charlie.swanson@mongodb.com>2016-12-16 16:24:32 -0500
commit37e720678f6e468726c6cc775a5dc898d080f0f3 (patch)
tree4bd6b4932cc0ac436c0d7c949f7e37df613684d2 /src/mongo/db/pipeline/parsed_add_fields.h
parent0cd2bf29d5798a395a07e67ae79ede9a5cefd411 (diff)
downloadmongo-37e720678f6e468726c6cc775a5dc898d080f0f3.tar.gz
SERVER-25535 Remove injectExpressionContext().
These methods were formally used to propagate a new ExpressionContext to stages, accumulators, or expressions which potentially needed to comparisons. Originally, this was necessary since Pipeline parsing happened outside of the collection lock and thus could not determine if there was a default collation on the collection. This meant that the collation could change after parsing and any operators that might compare strings would need to know about it. We have since moved parsing within the lock, so the collation can be known at parse time and the ExpressionContext should not change. This patch requires an ExpressionContext at construction time, and disallows changing the collation on an ExpressionContext.
Diffstat (limited to 'src/mongo/db/pipeline/parsed_add_fields.h')
-rw-r--r--src/mongo/db/pipeline/parsed_add_fields.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mongo/db/pipeline/parsed_add_fields.h b/src/mongo/db/pipeline/parsed_add_fields.h
index 58b8445e727..982fe6a3017 100644
--- a/src/mongo/db/pipeline/parsed_add_fields.h
+++ b/src/mongo/db/pipeline/parsed_add_fields.h
@@ -58,7 +58,8 @@ public:
* Verifies that there are no conflicting paths in the specification.
* Overrides the ParsedAggregationProjection's create method.
*/
- static std::unique_ptr<ParsedAddFields> create(const BSONObj& spec);
+ static std::unique_ptr<ParsedAddFields> create(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx, const BSONObj& spec);
ProjectionType getType() const final {
return ProjectionType::kComputed;
@@ -67,10 +68,10 @@ public:
/**
* Parses the addFields specification given by 'spec', populating internal data structures.
*/
- void parse(const BSONObj& spec) final {
+ void parse(const boost::intrusive_ptr<ExpressionContext>& expCtx, const BSONObj& spec) final {
VariablesIdGenerator idGenerator;
VariablesParseState variablesParseState(&idGenerator);
- parse(spec, variablesParseState);
+ parse(expCtx, spec, variablesParseState);
_variables = stdx::make_unique<Variables>(idGenerator.getIdCount());
}
@@ -87,10 +88,6 @@ public:
_root->optimize();
}
- void injectExpressionContext(const boost::intrusive_ptr<ExpressionContext>& expCtx) final {
- _root->injectExpressionContext(expCtx);
- }
-
DocumentSource::GetDepsReturn addDependencies(DepsTracker* deps) const final {
_root->addDependencies(deps);
return DocumentSource::SEE_NEXT;
@@ -124,7 +121,9 @@ private:
/**
* Parses 'spec' to determine which fields to add.
*/
- void parse(const BSONObj& spec, const VariablesParseState& variablesParseState);
+ void parse(const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const BSONObj& spec,
+ const VariablesParseState& variablesParseState);
/**
* Attempts to parse 'objSpec' as an expression like {$add: [...]}. Adds a computed field to
@@ -134,7 +133,8 @@ private:
* Throws an error if it was determined to be an expression specification, but failed to parse
* as a valid expression.
*/
- bool parseObjectAsExpression(StringData pathToObject,
+ bool parseObjectAsExpression(const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ StringData pathToObject,
const BSONObj& objSpec,
const VariablesParseState& variablesParseState);
@@ -142,7 +142,8 @@ private:
* Traverses 'subObj' and parses each field. Adds any computed fields at this level
* to 'node'.
*/
- void parseSubObject(const BSONObj& subObj,
+ void parseSubObject(const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const BSONObj& subObj,
const VariablesParseState& variablesParseState,
InclusionNode* node);