MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / sortBsonObj

Function sortBsonObj

src/ExtUtil.actor.cpp:725–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725bson::BSONObj sortBsonObj(bson::BSONObj obj) {
726 std::vector<bson::BSONElement> fields;
727 std::vector<bson::BSONObj> holder;
728
729 for (auto i = obj.begin(); i.more();) {
730 auto e = i.next();
731 if (e.type() != bson::BSONType::Object) {
732 fields.push_back(e);
733 } else {
734 bson::BSONObj newObj = BSON(e.fieldName() << sortBsonObj(e.Obj())).getOwned();
735 holder.push_back(newObj);
736 fields.push_back(newObj.firstElement());
737 }
738 }
739 std::sort(fields.begin(), fields.end(), [](bson::BSONElement left, bson::BSONElement right) {
740 return strcmp(left.fieldName(), right.fieldName()) < 0;
741 });
742 bson::BSONObjBuilder b(obj.objsize());
743 for (auto e : fields) {
744 b.append(e);
745 }
746 return b.obj();
747}
748
749Optional<IdInfo> extractEncodedIds(bson::BSONObj obj) {
750 bson::BSONElement el;

Callers 2

eq_predicateFunction · 0.85
extractEncodedIdsFunction · 0.85

Calls 3

beginMethod · 0.80
endMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected