mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Perf ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description 1) InitializeBsonIndexTerm called BsonValueToPgbsonElement that was using the bson_iter_next a lot. This is a lot of overhead when we know it's a single element. Use an unsafe variant of it to generate a pgbsonelement 2) Introduce a MatchAndRecurse option for index paths that allows the term generation logic to know whether it's an exact match or if the child paths also match. This is currently unused, but will be used in a subsequent change. ---- #### AI description (iteration 1) #### PR Classification Code improvement for term generation in wildcard index. #### PR Summary This pull request enhances the term generation process for wildcard indexes by introducing an unsafe transformation method and refining index traversal options. - `pgbsonelement.c`: Added `FillPgbsonElementUnsafe` and `BsonValueToPgbsonElementUnsafe` functions for unsafe BSON element transformation. - `bson_gin_entrypoint.c`: Introduced `IndexTraverse_MatchAndRecurse` option to improve path matching and recursion. - `feature_flag_configs.c`: Added feature flag `indexTermUseUnsafeTransform` to enable unsafe transformation. - `gin_index_term.c`: Utilized the unsafe transformation method based on the new feature flag. - `bson_gin_core.c`: Updated term path generation to handle the new traversal option. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
44 lines
1.6 KiB
C
44 lines
1.6 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/bson/pgbsonelement.h
|
|
*
|
|
* The BSON element type declaration.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef PG_BSONELEMENT_H
|
|
#define PG_BSONELEMENT_H
|
|
|
|
/*
|
|
* Represents a single field value in a bson document
|
|
* contains the path, and the value at that path
|
|
* Note that this is a stack object so the backing document
|
|
* buffer has to be kept alive while using the pgbsonelement
|
|
*/
|
|
typedef struct pgbsonelement
|
|
{
|
|
const char *path;
|
|
uint32_t pathLength;
|
|
bson_value_t bsonValue;
|
|
} pgbsonelement;
|
|
|
|
void BsonIterToPgbsonElement(bson_iter_t *iterator, pgbsonelement *element);
|
|
void PgbsonToSinglePgbsonElement(const pgbson *bson, pgbsonelement *element);
|
|
const char * PgbsonToSinglePgbsonElementWithCollation(const pgbson *bson,
|
|
pgbsonelement *element);
|
|
void BsonIterToSinglePgbsonElement(bson_iter_t *iterator, pgbsonelement *element);
|
|
bool TryGetSinglePgbsonElementFromPgbson(pgbson *bson, pgbsonelement *element);
|
|
bool TryGetSinglePgbsonElementFromBsonIterator(bson_iter_t *iterator,
|
|
pgbsonelement *element);
|
|
void BsonValueToPgbsonElement(const bson_value_t *value, pgbsonelement *element);
|
|
bool TryGetBsonValueToPgbsonElement(const bson_value_t *value, pgbsonelement *element);
|
|
|
|
/* Unsafe version of the BsonValueToPgbsonElement that assumes value is a single field doc */
|
|
void BsonValueToPgbsonElementUnsafe(const bson_value_t *bsonValue,
|
|
pgbsonelement *element);
|
|
pgbson * PgbsonElementToPgbson(pgbsonelement *element);
|
|
|
|
#endif
|