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

Function GenerateTerms

pg_documentdb/src/opclass/bson_gin_core.c:1173–1216  ·  view source on GitHub ↗

* This is the core logic that walks through a document and generates terms. * The generation happens in 2 phases: first to compute the total number of terms * and space to allocate, and the second to walk the structure and actually generate * the terms necessary. */

Source from the content-addressed store, hash-verified

1171 * the terms necessary.
1172 */
1173void
1174GenerateTerms(pgbson *bson, GenerateTermsContext *context, GinEntryPathData *pathData,
1175 bool addRootTerm)
1176{
1177 context->pathDataState = pathData;
1178 context->getPathDataFunc = GetPathDataDefault;
1179 context->isRecursivePathMatch = IsRecursivePathMatch;
1180 context->currentRecursivePathIndex = GetCurrentRecursivePaths;
1181 context->maxPaths = 1;
1182
1183 GenerateTermsForPath(bson, context);
1184 bool hasTerms = pathData->coreTermsCount > 0;
1185 if (addRootTerm)
1186 {
1187 /* GUC to preserve back-compat behavior. */
1188 if (!EnableGenerateNonExistsTerm)
1189 {
1190 AddTerm(&pathData->terms, GenerateRootTerm(
1191 &pathData->termMetadata));
1192 }
1193 else if (hasTerms)
1194 {
1195 AddTerm(&pathData->terms, GenerateRootExistsTerm(
1196 &pathData->termMetadata));
1197 }
1198 else
1199 {
1200 AddTerm(&pathData->terms, GenerateRootNonExistsTerm(
1201 &pathData->termMetadata));
1202 }
1203
1204 if (pathData->hasTruncatedTerms)
1205 {
1206 AddTerm(&pathData->terms, GenerateRootTruncatedTerm(
1207 &pathData->termMetadata));
1208 }
1209
1210 if (pathData->hasArrayAncestors)
1211 {
1212 AddTerm(&pathData->terms, GenerateRootMultiKeyTerm(
1213 &pathData->termMetadata));
1214 }
1215 }
1216}
1217
1218
1219static void

Calls 7

GenerateTermsForPathFunction · 0.85
AddTermFunction · 0.85
GenerateRootTermFunction · 0.85
GenerateRootExistsTermFunction · 0.85
GenerateRootMultiKeyTermFunction · 0.85

Tested by

no test coverage detected