summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher/expression_array.cpp')
-rw-r--r--src/mongo/db/matcher/expression_array.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp
index 42d30aaf0f1..cbff0adf1ca 100644
--- a/src/mongo/db/matcher/expression_array.cpp
+++ b/src/mongo/db/matcher/expression_array.cpp
@@ -101,13 +101,10 @@ void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int inden
_sub->debugString(debug, indentationLevel + 1);
}
-void ElemMatchObjectMatchExpression::appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts,
- bool includePath) const {
- BSONObjBuilder elemMatchBob = bob->subobjStart("$elemMatch");
- SerializationOptions options = opts;
- _sub->serialize(&elemMatchBob, options, true);
- elemMatchBob.doneFast();
+BSONObj ElemMatchObjectMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder subBob;
+ _sub->serialize(&subBob, true);
+ return BSON("$elemMatch" << subBob.obj());
}
MatchExpression::ExpressionOptimizerFunc ElemMatchObjectMatchExpression::getOptimizer() const {
@@ -173,15 +170,14 @@ void ElemMatchValueMatchExpression::debugString(StringBuilder& debug, int indent
}
}
-void ElemMatchValueMatchExpression::appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts,
- bool includePath) const {
- BSONObjBuilder emBob = bob->subobjStart("$elemMatch");
- SerializationOptions options = opts;
+BSONObj ElemMatchValueMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder emBob;
+
for (auto&& child : _subs) {
- child->serialize(&emBob, options, false);
+ child->serialize(&emBob, false);
}
- emBob.doneFast();
+
+ return BSON("$elemMatch" << emBob.obj());
}
MatchExpression::ExpressionOptimizerFunc ElemMatchValueMatchExpression::getOptimizer() const {
@@ -219,10 +215,8 @@ void SizeMatchExpression::debugString(StringBuilder& debug, int indentationLevel
}
}
-void SizeMatchExpression::appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts,
- bool includePath) const {
- opts.appendLiteral(bob, "$size", _size);
+BSONObj SizeMatchExpression::getSerializedRightHandSide() const {
+ return BSON("$size" << _size);
}
bool SizeMatchExpression::equivalent(const MatchExpression* other) const {