summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/variables.h
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2017-07-25 08:59:47 -0400
committerJames Wahlin <james@mongodb.com>2017-08-09 16:29:49 -0400
commit2087f94e8c6d7226a4dd48155082034ae51c3cfd (patch)
tree6a6dac53fe93bc29a174e008c26f2d6daf474a05 /src/mongo/db/pipeline/variables.h
parentc1aee1915536be2d1928d1098e133acbfdc3a575 (diff)
downloadmongo-2087f94e8c6d7226a4dd48155082034ae51c3cfd.tar.gz
SERVER-30046 Support $expr constant expression in ComparisonMatchExpression
Diffstat (limited to 'src/mongo/db/pipeline/variables.h')
-rw-r--r--src/mongo/db/pipeline/variables.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/variables.h b/src/mongo/db/pipeline/variables.h
index efbf115269f..4e487e811f4 100644
--- a/src/mongo/db/pipeline/variables.h
+++ b/src/mongo/db/pipeline/variables.h
@@ -64,6 +64,10 @@ public:
static void uassertValidNameForUserWrite(StringData varName);
static void uassertValidNameForUserRead(StringData varName);
+ static bool isUserDefinedVariable(Variables::Id id) {
+ return id >= 0;
+ }
+
// Ids for builtin variables.
static constexpr Variables::Id kRootId = Id(-1);
static constexpr Variables::Id kRemoveId = Id(-2);
@@ -84,6 +88,20 @@ public:
Value getValue(Variables::Id id, const Document& root) const;
/**
+ * Gets the value of a user-defined variable. Should only be called when we know 'id' represents
+ * a user-defined variable.
+ */
+ Value getUserDefinedValue(Variables::Id id) const;
+
+ /**
+ * Returns whether a value for 'id' has been stored in this Variables instance.
+ */
+ bool hasUserDefinedValue(Variables::Id id) const {
+ invariant(isUserDefinedVariable(id));
+ return _valueList.size() > static_cast<size_t>(id);
+ }
+
+ /**
* Returns Document() for non-document values, but otherwise identical to getValue(). If the
* 'id' provided represents the special ROOT variable, then we return 'root'.
*/