MCPcopy Create free account
hub / github.com/documentdb/documentdb / GetIndexTypeFromKeyDocument

Function GetIndexTypeFromKeyDocument

pg_documentdb/src/metadata/index.c:2325–2352  ·  view source on GitHub ↗

* Utility function that iterates on the index keyDocument pgbson and returns the index plugin * name upon finding the first match. If no match is found, return "regular". */

Source from the content-addressed store, hash-verified

2323 * name upon finding the first match. If no match is found, return "regular".
2324 */
2325const char *
2326GetIndexTypeFromKeyDocument(pgbson *keyDocument)
2327{
2328 const char *regularIndexType = "regular";
2329
2330 /* Assume document is of regular type if pgbson is NULL.*/
2331 if (keyDocument == NULL)
2332 {
2333 return regularIndexType;
2334 }
2335
2336 bson_iter_t iter;
2337 PgbsonInitIterator(keyDocument, &iter);
2338 while (bson_iter_next(&iter))
2339 {
2340 const bson_value_t *value = bson_iter_value(&iter);
2341 for (int i = 0; i < NumberOfMongoIndexTypes; i++)
2342 {
2343 MongoIndexSupport idxSupport = MongoIndexSupportedList[i];
2344 if (IsIndexOfType(value, idxSupport.mongoIndexName))
2345 {
2346 return idxSupport.mongoIndexName;
2347 }
2348 }
2349 }
2350
2351 return regularIndexType;
2352}
2353
2354
2355/*

Callers

nothing calls this directly

Calls 2

PgbsonInitIteratorFunction · 0.85
IsIndexOfTypeFunction · 0.85

Tested by

no test coverage detected