| 63 | } |
| 64 | |
| 65 | Reference<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 | |
| 93 | ACTOR static Future<Reference<UnboundCollectionContext>> constructContext(Namespace ns, |
| 94 | Reference<DocTransaction> tr, |
nothing calls this directly
no test coverage detected