summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r--src/mongo/db/matcher/expression.h6
-rw-r--r--src/mongo/db/matcher/expression_always_boolean.h6
-rw-r--r--src/mongo/db/matcher/expression_arity.h5
-rw-r--r--src/mongo/db/matcher/expression_array.h13
-rw-r--r--src/mongo/db/matcher/expression_expr.h5
-rw-r--r--src/mongo/db/matcher/expression_leaf.h5
-rw-r--r--src/mongo/db/matcher/expression_tree.h11
-rw-r--r--src/mongo/db/matcher/expression_where_base.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h5
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h5
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h5
17 files changed, 65 insertions, 43 deletions
diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h
index 4705c2cdf32..f870dbcbcda 100644
--- a/src/mongo/db/matcher/expression.h
+++ b/src/mongo/db/matcher/expression.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <functional>
#include <memory>
@@ -185,11 +186,12 @@ public:
/**
* For MatchExpression nodes that can participate in tree restructuring (like AND/OR), returns a
- * non-const vector of MatchExpression* child nodes.
+ * non-const vector of MatchExpression* child nodes. If the MatchExpression does not
+ * participated in tree restructuring, returns boost::none.
* Do not use to traverse the MatchExpression tree. Use numChildren() and getChild(), which
* provide access to all nodes.
*/
- virtual std::vector<MatchExpression*>* getChildVector() = 0;
+ virtual boost::optional<std::vector<MatchExpression*>&> getChildVector() = 0;
/**
* Get the path of the leaf. Returns StringData() if there is no path (node is logical).
diff --git a/src/mongo/db/matcher/expression_always_boolean.h b/src/mongo/db/matcher/expression_always_boolean.h
index 3e6030ae36e..ff12bcd1da0 100644
--- a/src/mongo/db/matcher/expression_always_boolean.h
+++ b/src/mongo/db/matcher/expression_always_boolean.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/db/matcher/expression.h"
namespace mongo {
@@ -78,8 +80,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() override {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
private:
diff --git a/src/mongo/db/matcher/expression_arity.h b/src/mongo/db/matcher/expression_arity.h
index 8ec77663ea7..0c1b57f3cf9 100644
--- a/src/mongo/db/matcher/expression_arity.h
+++ b/src/mongo/db/matcher/expression_arity.h
@@ -31,6 +31,7 @@
#include <algorithm>
#include <array>
+#include <boost/optional.hpp>
#include <memory>
#include "mongo/db/matcher/expression.h"
@@ -80,8 +81,8 @@ public:
[](const auto& expr1, const auto& expr2) { return expr1->equivalent(expr2.get()); });
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
size_t numChildren() const final {
diff --git a/src/mongo/db/matcher/expression_array.h b/src/mongo/db/matcher/expression_array.h
index 5f6933ad2d7..329d2aea707 100644
--- a/src/mongo/db/matcher/expression_array.h
+++ b/src/mongo/db/matcher/expression_array.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <vector>
#include "mongo/base/status.h"
@@ -88,8 +89,8 @@ public:
BSONObj getSerializedRightHandSide() const final;
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
virtual size_t numChildren() const {
@@ -143,8 +144,8 @@ public:
BSONObj getSerializedRightHandSide() const final;
- virtual std::vector<MatchExpression*>* getChildVector() {
- return &_subs;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return _subs;
}
virtual size_t numChildren() const {
@@ -184,8 +185,8 @@ public:
return nullptr;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
virtual bool matchesArray(const BSONObj& anArray, MatchDetails* details) const;
diff --git a/src/mongo/db/matcher/expression_expr.h b/src/mongo/db/matcher/expression_expr.h
index d3ebae6ec0b..fb9f7d6d628 100644
--- a/src/mongo/db/matcher/expression_expr.h
+++ b/src/mongo/db/matcher/expression_expr.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <vector>
#include "mongo/db/matcher/expression.h"
@@ -79,8 +80,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
boost::intrusive_ptr<ExpressionContext> getExpressionContext() {
diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h
index 27ecb29622f..ebc69b1230a 100644
--- a/src/mongo/db/matcher/expression_leaf.h
+++ b/src/mongo/db/matcher/expression_leaf.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <memory>
#include "mongo/bson/bsonelement_comparator.h"
@@ -71,8 +72,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() override {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
MatchCategory getCategory() const override {
diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h
index 5a33cb1e10d..ddd372db654 100644
--- a/src/mongo/db/matcher/expression_tree.h
+++ b/src/mongo/db/matcher/expression_tree.h
@@ -29,8 +29,9 @@
#pragma once
-#include "mongo/db/matcher/expression.h"
+#include <boost/optional.hpp>
+#include "mongo/db/matcher/expression.h"
/**
* this contains all Expessions that define the structure of the tree
@@ -82,8 +83,8 @@ public:
return child;
}
- virtual std::vector<MatchExpression*>* getChildVector() {
- return &_expressions;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return _expressions;
}
bool equivalent(const MatchExpression* other) const;
@@ -223,8 +224,8 @@ public:
return _exp.get();
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
MatchExpression* releaseChild(void) {
diff --git a/src/mongo/db/matcher/expression_where_base.h b/src/mongo/db/matcher/expression_where_base.h
index 78db059c218..dc839966fd0 100644
--- a/src/mongo/db/matcher/expression_where_base.h
+++ b/src/mongo/db/matcher/expression_where_base.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/db/matcher/expression.h"
namespace mongo {
@@ -53,8 +55,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
bool matchesSingleElement(const BSONElement& e, MatchDetails* details = nullptr) const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
index dab875cb80d..c7884c63c33 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
@@ -28,6 +28,8 @@
*/
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/base/string_data.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_array.h"
@@ -67,8 +69,8 @@ public:
bool equivalent(const MatchExpression* other) const final;
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
size_t numChildren() const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
index c2eaa46bbcc..739cee4db96 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <memory>
#include <pcrecpp.h>
#include <utility>
@@ -138,8 +139,8 @@ public:
std::unique_ptr<MatchExpression> shallowClone() const final;
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
size_t numChildren() const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
index c2495d991ba..69e18a4fc39 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/bson/unordered_fields_bsonelement_comparator.h"
#include "mongo/db/matcher/expression_leaf.h"
@@ -66,10 +68,6 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
- }
-
private:
ExpressionOptimizerFunc getOptimizer() const final {
return [](std::unique_ptr<MatchExpression> expression) { return expression; };
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
index 54682da09d4..a5e79e79e7f 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <memory>
#include "mongo/db/matcher/expression_array.h"
@@ -73,8 +74,8 @@ public:
std::unique_ptr<MatchExpression> shallowClone() const final;
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
size_t numChildren() const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
index 249de09c030..ecc269641a0 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/base/string_data.h"
#include "mongo/db/matcher/expression_array.h"
@@ -60,8 +62,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
protected:
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
index 463420f0dd7..bbc0baf0aa8 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/base/string_data.h"
#include "mongo/db/matcher/expression.h"
@@ -55,8 +57,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
void debugString(StringBuilder& debug, int indentationLevel) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
index 407c6680057..6dda56a1286 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/db/matcher/expression_path.h"
namespace mongo {
@@ -49,8 +51,8 @@ public:
bool equivalent(const MatchExpression* other) const final;
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
size_t numChildren() const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
index ebfdca1b136..a174eabafd2 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "mongo/bson/unordered_fields_bsonobj_comparator.h"
#include "mongo/db/matcher/expression.h"
@@ -79,8 +81,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
MatchCategory getCategory() const final {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
index 9b47e32682f..328bf24d6f0 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
@@ -29,6 +29,7 @@
#pragma once
+#include <boost/optional.hpp>
#include <utility>
#include "mongo/bson/unordered_fields_bsonelement_comparator.h"
@@ -57,8 +58,8 @@ public:
MONGO_UNREACHABLE;
}
- std::vector<MatchExpression*>* getChildVector() final {
- return nullptr;
+ boost::optional<std::vector<MatchExpression*>&> getChildVector() final {
+ return boost::none;
}
bool matchesArray(const BSONObj& array, MatchDetails*) const final {