Files
documentdb/scripts/install_setup_libbson.sh
Vinod Sridharan c3baecd540 Merged PR 1642833: [Wildcard Index] Improve term generation for wildcard index
### 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 -->
2025-04-17 18:40:16 +08:00

45 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# fail if trying to reference a variable that is not set.
set -u
# exit immediately if a command exits with a non-zero status
set -e
source="${BASH_SOURCE[0]}"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptDir="$( cd -P "$( dirname "$source" )" && pwd )"
echo "scriptDir: $scriptDir"
. $scriptDir/setup_versions.sh
MONGO_DRIVER_VERSION=$(GetLibbsonVersion)
if [ "${INSTALLDESTDIR:-""}" == "" ]; then
INSTALLDESTDIR="/usr";
fi
if [ "${MAKE_PROGRAM:-""}" == "" ]; then
MAKE_PROGRAM="cmake3"
fi
pushd $INSTALL_DEPENDENCIES_ROOT
curl -s -L https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_DRIVER_VERSION/mongo-c-driver-$MONGO_DRIVER_VERSION.tar.gz -o ./mongo-c-driver-$MONGO_DRIVER_VERSION.tar.gz
tar -xzvf ./mongo-c-driver-$MONGO_DRIVER_VERSION.tar.gz -C $INSTALL_DEPENDENCIES_ROOT --transform="s|mongo-c-driver-$MONGO_DRIVER_VERSION|mongo-c-driver|"
# remove the tar file
rm -rf ./mongo-c-driver-$MONGO_DRIVER_VERSION.tar.gz
cd $INSTALL_DEPENDENCIES_ROOT/mongo-c-driver/build
$MAKE_PROGRAM -DENABLE_MONGOC=ON -DMONGOC_ENABLE_ICU=OFF -DENABLE_ICU=OFF -DCMAKE_C_FLAGS="-fPIC -g" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALLDESTDIR ..
make clean && make -sj$(cat /proc/cpuinfo | grep -c "processor") install
popd
if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then
rm -rf $INSTALL_DEPENDENCIES_ROOT/mongo-c-driver
fi