From 5273c2bad7df58c44afdd677609b8656f399a906 Mon Sep 17 00:00:00 2001 From: James Wahlin Date: Wed, 5 Apr 2017 09:59:54 -0400 Subject: SERVER-28651 Move agg var ownership to ExpressionContext --- src/mongo/db/pipeline/document_source_graph_lookup.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/mongo/db/pipeline/document_source_graph_lookup.cpp') diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp index 7cc78ba8e95..d0c338c0855 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp @@ -325,9 +325,10 @@ void DocumentSourceGraphLookUp::performSearch() { // Make sure _input is set before calling performSearch(). invariant(_input); - _variables->setRoot(*_input); - Value startingValue = _startWith->evaluateInternal(_variables.get()); - _variables->clearRoot(); + auto& variables = pExpCtx->variables; + variables.setRoot(*_input); + Value startingValue = _startWith->evaluateInternal(); + variables.clearRoot(); // If _startWith evaluates to an array, treat each value as a separate starting point. if (startingValue.isArray()) { @@ -494,7 +495,6 @@ intrusive_ptr DocumentSourceGraphLookUp::create( depthField, maxDepth, unwindSrc)); - source->_variables.reset(new Variables()); return source; } @@ -509,8 +509,7 @@ intrusive_ptr DocumentSourceGraphLookUp::createFromBson( boost::optional maxDepth; boost::optional additionalFilter; - VariablesIdGenerator idGenerator; - VariablesParseState vps(&idGenerator); + VariablesParseState vps = expCtx->variablesParseState; for (auto&& argument : elem.Obj()) { const auto argName = argument.fieldNameStringData(); @@ -607,8 +606,6 @@ intrusive_ptr DocumentSourceGraphLookUp::createFromBson( maxDepth, boost::none)); - newSource->_variables.reset(new Variables(idGenerator.getIdCount())); - return std::move(newSource); } } // namespace mongo -- cgit v1.2.1