summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/pipeline.cpp
diff options
context:
space:
mode:
authorGeorge Wangensteen <george.wangensteen@10gen.com>2019-06-19 15:24:38 -0400
committerGeorge Wangensteen <george.wangensteen@10gen.com>2019-06-28 16:01:59 -0400
commitb651ed3dc6ae61332bb3193afef1cfa41bf5df53 (patch)
treed2fd427998d5ec995aeaa4faf8d13e597e745aa5 /src/mongo/db/pipeline/pipeline.cpp
parentabe43b7aaddd8254c51eb2c8bfce99b9e11f8fee (diff)
downloadmongo-b651ed3dc6ae61332bb3193afef1cfa41bf5df53.tar.gz
SERVER-41750 refactor renamed paths API.
Diffstat (limited to 'src/mongo/db/pipeline/pipeline.cpp')
-rw-r--r--src/mongo/db/pipeline/pipeline.cpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp
index 23484931890..73b14b80262 100644
--- a/src/mongo/db/pipeline/pipeline.cpp
+++ b/src/mongo/db/pipeline/pipeline.cpp
@@ -500,48 +500,6 @@ void Pipeline::addFinalSource(intrusive_ptr<DocumentSource> source) {
_sources.push_back(source);
}
-boost::optional<StringMap<std::string>> Pipeline::renamedPaths(
- SourceContainer::const_reverse_iterator rstart,
- SourceContainer::const_reverse_iterator rend,
- std::set<std::string> pathsOfInterest) {
- // Use a vector to give a path id to each input path. A path's id is its index in the vector.
- const std::vector<string> inputPaths(pathsOfInterest.begin(), pathsOfInterest.end());
- std::vector<string> currentPaths(pathsOfInterest.begin(), pathsOfInterest.end());
-
- // Loop backwards over the stages. We will re-use 'pathsOfInterest', modifying that set each
- // time to be the current set of field's we're interested in. At the same time, we will maintain
- // 'currentPaths'. 'pathsOfInterest' is used to compute the renames, while 'currentPaths' is
- // used to tie a path back to its id.
- //
- // Interestingly, 'currentPaths' may contain duplicates. For example, if a stage like
- // {$addFields: {a: "$b"}} duplicates the value of "a" and both paths are of interest, then
- // 'currentPaths' may begin as ["a", "b"] representing the paths after the $addFields stage, but
- // becomes ["a", "a"] via the rename.
- for (auto it = rstart; it != rend; ++it) {
- boost::optional<StringMap<string>> renamed = (*it)->renamedPaths(pathsOfInterest);
- if (!renamed) {
- return boost::none;
- }
- pathsOfInterest.clear();
- for (std::size_t pathId = 0; pathId < inputPaths.size(); ++pathId) {
- currentPaths[pathId] = (*renamed)[currentPaths[pathId]];
- pathsOfInterest.insert(currentPaths[pathId]);
- }
- }
-
- // We got all the way through the pipeline via renames! Construct the mapping from path at the
- // end of the pipeline to path at the beginning.
- StringMap<string> renameMap;
- for (std::size_t pathId = 0; pathId < currentPaths.size(); ++pathId) {
- renameMap[inputPaths[pathId]] = currentPaths[pathId];
- }
- return renameMap;
-}
-
-boost::optional<StringMap<string>> Pipeline::renamedPaths(std::set<string> pathsOfInterest) const {
- return renamedPaths(_sources.rbegin(), _sources.rend(), std::move(pathsOfInterest));
-}
-
DepsTracker Pipeline::getDependencies(DepsTracker::MetadataAvailable metadataAvailable) const {
DepsTracker deps(metadataAvailable);
const bool scopeHasVariables = pCtx->variablesParseState.hasDefinedVariables();