summaryrefslogtreecommitdiff
path: root/src/mongo/bson
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@10gen.com>2020-02-18 18:25:00 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-27 02:18:39 +0000
commit74961aa50ded11df8612bed9e0bd40f6c9466560 (patch)
tree933de51e64dae1d5b66bfbfd1e5ddf9e978beb07 /src/mongo/bson
parent679d1e1028ddbdd1ac5778f3e0ab0cb3ffd5ee27 (diff)
downloadmongo-74961aa50ded11df8612bed9e0bd40f6c9466560.tar.gz
SERVER-46002 Attach core read mirroring functionality
Diffstat (limited to 'src/mongo/bson')
-rw-r--r--src/mongo/bson/bsonobj.cpp20
-rw-r--r--src/mongo/bson/bsonobj.h5
2 files changed, 18 insertions, 7 deletions
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp
index 74d3edf1588..284058feecf 100644
--- a/src/mongo/bson/bsonobj.cpp
+++ b/src/mongo/bson/bsonobj.cpp
@@ -346,8 +346,7 @@ bool BSONObj::isFieldNamePrefixOf(const BSONObj& otherObj) const {
return !a.more();
}
-BSONObj BSONObj::extractFieldsUnDotted(const BSONObj& pattern) const {
- BSONObjBuilder b;
+void BSONObj::extractFieldsUndotted(BSONObjBuilder* b, const BSONObj& pattern) const {
BSONObjIterator i(pattern);
while (i.moreWithEOO()) {
BSONElement e = i.next();
@@ -355,13 +354,17 @@ BSONObj BSONObj::extractFieldsUnDotted(const BSONObj& pattern) const {
break;
BSONElement x = getField(e.fieldName());
if (!x.eoo())
- b.appendAs(x, "");
+ b->appendAs(x, "");
}
- return b.obj();
}
-BSONObj BSONObj::filterFieldsUndotted(const BSONObj& filter, bool inFilter) const {
+BSONObj BSONObj::extractFieldsUndotted(const BSONObj& pattern) const {
BSONObjBuilder b;
+ extractFieldsUndotted(&b, pattern);
+ return b.obj();
+}
+
+void BSONObj::filterFieldsUndotted(BSONObjBuilder* b, const BSONObj& filter, bool inFilter) const {
BSONObjIterator i(*this);
while (i.moreWithEOO()) {
BSONElement e = i.next();
@@ -369,8 +372,13 @@ BSONObj BSONObj::filterFieldsUndotted(const BSONObj& filter, bool inFilter) cons
break;
BSONElement x = filter.getField(e.fieldName());
if ((x.eoo() && !inFilter) || (!x.eoo() && inFilter))
- b.append(e);
+ b->append(e);
}
+}
+
+BSONObj BSONObj::filterFieldsUndotted(const BSONObj& filter, bool inFilter) const {
+ BSONObjBuilder b;
+ filterFieldsUndotted(&b, filter, inFilter);
return b.obj();
}
diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h
index 215652bcd29..f22c9391bb6 100644
--- a/src/mongo/bson/bsonobj.h
+++ b/src/mongo/bson/bsonobj.h
@@ -52,6 +52,7 @@
namespace mongo {
+class BSONObjBuilder;
class BSONObjStlIterator;
class ExtendedCanonicalV200Generator;
class ExtendedRelaxedV200Generator;
@@ -393,9 +394,11 @@ public:
* this.extractFieldsUnDotted({b : "blah"}) -> {"" : 5}
*
*/
- BSONObj extractFieldsUnDotted(const BSONObj& pattern) const;
+ BSONObj extractFieldsUndotted(const BSONObj& pattern) const;
+ void extractFieldsUndotted(BSONObjBuilder* b, const BSONObj& pattern) const;
BSONObj filterFieldsUndotted(const BSONObj& filter, bool inFilter) const;
+ void filterFieldsUndotted(BSONObjBuilder* b, const BSONObj& filter, bool inFilter) const;
BSONElement getFieldUsingIndexNames(StringData fieldName, const BSONObj& indexKey) const;