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

Function GenerateTermsForPath

pg_documentdb/src/opclass/bson_gin_core.c:1100–1164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1098
1099
1100void
1101GenerateTermsForPath(pgbson *bson, GenerateTermsContext *context)
1102{
1103 bson_iter_t bsonIterator;
1104 Assert(context->pathDataState != NULL);
1105 Assert(context->getPathDataFunc != NULL);
1106
1107 /* now walk the entries and insert the terms */
1108 PgbsonInitIterator(bson, &bsonIterator);
1109
1110 /* Initialize with minimum capacity */
1111 /* provision 1 root term + 1 value term/not-found term */
1112 for (int i = 0; i < context->maxPaths; i++)
1113 {
1114 GinEntryPathData *pathData = context->getPathDataFunc(context->pathDataState, i);
1115
1116 pathData->terms.entries = palloc0(sizeof(Datum) * 2);
1117 pathData->terms.entryCapacity = 2;
1118 pathData->terms.index = 0;
1119 pathData->coreTermsCount = 0;
1120 pathData->hasTruncatedTerms = false;
1121 pathData->hasArrayAncestors = false;
1122 pathData->hasArrayValues = false;
1123 }
1124
1125 bool inArrayContext = false;
1126 bool isArrayTerm = false;
1127 bool isCheckForArrayTermsWithNestedDocument = false;
1128 GenerateTermsCore(&bsonIterator, "", 0, inArrayContext,
1129 isArrayTerm, context,
1130 isCheckForArrayTermsWithNestedDocument);
1131
1132
1133 for (int i = 0; i < context->maxPaths; i++)
1134 {
1135 GinEntryPathData *pathData = context->getPathDataFunc(context->pathDataState, i);
1136 pathData->coreTermsCount = pathData->terms.index;
1137 bool hasNoTerms = pathData->coreTermsCount == 0;
1138
1139 /* Add the path not found term if necessary
1140 * we do this for back compat only when the index used the legacy not found term
1141 */
1142 if (hasNoTerms && context->generateNotFoundTerm)
1143 {
1144 AddTerm(&pathData->terms, GeneratePathUndefinedTerm(context->options));
1145 }
1146
1147 if (pathData->generatePathBasedUndefinedTerms)
1148 {
1149 if (hasNoTerms)
1150 {
1151 /* Add the path not exists value term */
1152 AddTerm(&pathData->terms, GenerateValueUndefinedTerm(
1153 &pathData->termMetadata));
1154 }
1155
1156 if (pathData->hasArrayPartialTermExistence)
1157 {

Callers 2

GenerateTermsFunction · 0.85

Calls 6

PgbsonInitIteratorFunction · 0.85
GenerateTermsCoreFunction · 0.85
AddTermFunction · 0.85

Tested by

no test coverage detected