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

Method indexInfoFromObj

src/MetadataManager.actor.cpp:65–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65Reference<IndexInfo> MetadataManager::indexInfoFromObj(const bson::BSONObj& indexObj,
66 Reference<UnboundCollectionContext> cx) {
67 IndexInfo::IndexStatus status = indexStatus(indexObj);
68 bson::BSONObj keyObj = indexObj.getObjectField(DocLayerConstants::KEY_FIELD);
69 std::vector<std::pair<std::string, int>> indexKeys;
70 indexKeys.reserve(keyObj.nFields());
71 for (auto i = keyObj.begin(); i.more();) {
72 auto e = i.next();
73 indexKeys.emplace_back(e.fieldName(), (int)e.Number());
74 }
75 if (verboseLogging) {
76 TraceEvent("BD_getAndAddIndexes").detail("AddingIndex", describeIndex(indexKeys));
77 }
78 if (verboseConsoleOutput) {
79 fprintf(stderr, "%s\n\n", describeIndex(indexKeys).c_str());
80 }
81 if (status == IndexInfo::IndexStatus::BUILDING) {
82 return Reference<IndexInfo>(
83 new IndexInfo(indexObj.getStringField(DocLayerConstants::NAME_FIELD), indexKeys, cx, status,
84 UID::fromString(indexObj.getStringField(DocLayerConstants::BUILD_ID_FIELD)),
85 indexObj.getBoolField(DocLayerConstants::UNIQUE_FIELD)));
86 } else {
87 return Reference<IndexInfo>(new IndexInfo(indexObj.getStringField(DocLayerConstants::NAME_FIELD), indexKeys, cx,
88 status, Optional<UID>(),
89 indexObj.getBoolField(DocLayerConstants::UNIQUE_FIELD)));
90 }
91}
92
93ACTOR static Future<Reference<UnboundCollectionContext>> constructContext(Namespace ns,
94 Reference<DocTransaction> tr,

Callers

nothing calls this directly

Calls 3

indexStatusFunction · 0.85
describeIndexFunction · 0.85
beginMethod · 0.80

Tested by

no test coverage detected