summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/semantic_analysis.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/semantic_analysis.h')
-rw-r--r--src/mongo/db/pipeline/semantic_analysis.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/semantic_analysis.h b/src/mongo/db/pipeline/semantic_analysis.h
index 73739919e10..f7c0b3f56b5 100644
--- a/src/mongo/db/pipeline/semantic_analysis.h
+++ b/src/mongo/db/pipeline/semantic_analysis.h
@@ -72,7 +72,9 @@ boost::optional<StringMap<std::string>> renamedPaths(const std::set<std::string>
boost::optional<StringMap<std::string>> renamedPaths(
const Pipeline::SourceContainer::const_iterator start,
const Pipeline::SourceContainer::const_iterator end,
- const std::set<std::string>& pathsOfInterest);
+ const std::set<std::string>& pathsOfInterest,
+ boost::optional<std::function<bool(DocumentSource*)>> additionalStageValidatorCallback =
+ boost::none);
/**
* Tracks renames by walking a pipeline backwards. Takes two reverse iterators that represent two
@@ -87,7 +89,24 @@ boost::optional<StringMap<std::string>> renamedPaths(
boost::optional<StringMap<std::string>> renamedPaths(
const Pipeline::SourceContainer::const_reverse_iterator start,
const Pipeline::SourceContainer::const_reverse_iterator end,
- const std::set<std::string>& pathsOfInterest);
+ const std::set<std::string>& pathsOfInterest,
+ boost::optional<std::function<bool(DocumentSource*)>> additionalStageValidatorCallback =
+ boost::none);
+
+/**
+ * Attempts to find a maximal prefix of the pipeline given by 'start' and 'end' which will preserve
+ * all paths in 'pathsOfInterest' and also have each DocumentSource satisfy
+ * 'additionalStageValidatorCallback'.
+ *
+ * Returns an iterator to the first stage which modifies one of the paths in 'pathsOfInterest' or
+ * fails 'additionalStageValidatorCallback', or returns 'end' if no such stage exists.
+ */
+std::pair<Pipeline::SourceContainer::const_iterator, StringMap<std::string>>
+findLongestViablePrefixPreservingPaths(const Pipeline::SourceContainer::const_iterator start,
+ const Pipeline::SourceContainer::const_iterator end,
+ const std::set<std::string>& pathsOfInterest,
+ boost::optional<std::function<bool(DocumentSource*)>>
+ additionalStageValidatorCallback = boost::none);
/**
* Given a set of paths 'dependencies', determines which of those paths will be modified if all
@@ -99,4 +118,7 @@ boost::optional<StringMap<std::string>> renamedPaths(
std::set<std::string> extractModifiedDependencies(const std::set<std::string>& dependencies,
const std::set<std::string>& preservedPaths);
+bool pathSetContainsOverlappingPath(const std::set<std::string>& paths,
+ const std::string& targetPath);
+
} // namespace mongo::semantic_analysis