summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/optimizer/reference_tracker.h
diff options
context:
space:
mode:
authorWill Buerger <will.buerger@mongodb.com>2022-12-21 19:44:48 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-21 20:22:22 +0000
commita113e6c5bf58673f792ef53768a2072a9fac0ba9 (patch)
tree28c0a8c9f3bbd48c750fdbf15ba6cd0c5447fe78 /src/mongo/db/query/optimizer/reference_tracker.h
parentb9717b01dc7b893fd4cdb8e1dad974237eddf7f3 (diff)
downloadmongo-a113e6c5bf58673f792ef53768a2072a9fac0ba9.tar.gz
SERVER-71530: Add VariableTransporter for walking variables with callback
Diffstat (limited to 'src/mongo/db/query/optimizer/reference_tracker.h')
-rw-r--r--src/mongo/db/query/optimizer/reference_tracker.h25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/mongo/db/query/optimizer/reference_tracker.h b/src/mongo/db/query/optimizer/reference_tracker.h
index 1c0bc87705a..c11ddce41f4 100644
--- a/src/mongo/db/query/optimizer/reference_tracker.h
+++ b/src/mongo/db/query/optimizer/reference_tracker.h
@@ -55,16 +55,6 @@ struct Definition {
struct CollectedInfo;
using DefinitionsMap = ProjectionNameMap<Definition>;
-struct VariableCollectorResult {
- // The Variables referenced by the subtree.
- std::vector<std::reference_wrapper<const Variable>> _variables;
- // The names of locally-defined Variables. These aren't propagated up the tree during normal
- // variable resolution. Tracking these separately allows us to easily check, for example, which
- // variables are referenced in but not defined by the subtree (i.e. variables which should be
- // defined elsewhere in the ABT).
- ProjectionNameSet _definedVars;
-};
-
/**
* Helps enforce scoping and validity rules for definitions and Variable references.
*/
@@ -83,15 +73,14 @@ public:
void rebuild(const ABT& root);
/**
- * Get information about Variables in the subtree rooted at 'n', including Variables referenced
- * by the subtree and locally-defined Variables.
- */
- static VariableCollectorResult getVariables(const ABT& n);
-
- /**
- * Call 'func' on each Variable in the subtree.
+ * Calls 'variableCallback' on each Variable and `variableDefinitionCallback` on each
+ * variable name defined via a Let or Lambda in the ABT.
*/
- static void walkVariables(const ABT& n, std::function<void(const Variable&)> func);
+ static void walkVariables(
+ const ABT& n,
+ const std::function<void(const Variable&)>& variableCallback,
+ const std::function<void(const ProjectionName&)>& variableDefinitionCallback =
+ [](const ProjectionName&) {});
~VariableEnvironment();