diff --git a/src/gausskernel/storage/access/cbtree/cbtree.cpp b/src/gausskernel/storage/access/cbtree/cbtree.cpp index 08de204ab..95046681b 100644 --- a/src/gausskernel/storage/access/cbtree/cbtree.cpp +++ b/src/gausskernel/storage/access/cbtree/cbtree.cpp @@ -145,19 +145,34 @@ Datum cbtreecanreturn(PG_FUNCTION_ARGS) { PG_RETURN_BOOL(true); } - +/* +function name:cbtreeoptions +description:This function is part of handling the CBTree index. +Note: The main process is as follows: +STEP1:To get the default relationship options, if the `validate` parameter is true, then the `default_reloptions` function will validate the validity of the options. +STEP2:If filledOption is null,return Datum(0),else return Datum(filledOption) +date: 2023/9/17 +*/ Datum cbtreeoptions(PG_FUNCTION_ARGS) { Datum indexRelOptions = PG_GETARG_DATUM(0); bool validate = PG_GETARG_BOOL(1); - bytea *filledOption = default_reloptions(indexRelOptions, validate, RELOPT_KIND_CBTREE); + bytea *filledOption = default_reloptions(indexRelOptions, validate, RELOPT_KIND_CBTREE);//To get the default relationship options, if the `validate` parameter is true, then the `default_reloptions` function will validate the validity of the options. if (filledOption != NULL) PG_RETURN_BYTEA_P(filledOption); PG_RETURN_NULL(); } - +/* +function name:cbtreegettuple +description:This function is part of handling the CBTree index. +Note: The main process is as follows: +STEP1:The function first checks whether the scan parameter is NULL. If it is, it will report an error and exit. +STEP2:The function calls the _bt_gettuple_internal function to get the tuple.And returns a boolean value indicating whether the tuple was successfully obtained. +STEP3:The cbtreegettuple function returns the result of the _bt_gettuple_internal function +date: 2023/9/17 +*/ Datum cbtreegettuple(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc)PG_GETARG_POINTER(0); @@ -182,6 +197,17 @@ Datum cbtreegettuple(PG_FUNCTION_ARGS) * @IN param isnulls: the container to use temprarily * @IN param transferFuncs: the transfer functions array */ +/* +function name:InsertToBtree +description:This function is part of handling the CBTree index. +Note: The main process is as follows: +STEP1:It gets the number of rows in the batch and adds this to reltuples. +STEP2:For each row in the batch, it does the following:checking if the value is null. If it is, it sets the corresponding entry in isnulls to true. Otherwise, it sets it to false and converts the scalar value to a datum using the corresponding transfer function. +And it gets the item pointer (tid) for the row. +STEP3:It calls _bt_spool to add the tid and values to the B-tree spool. +STEP4:add buildstate.indtuples. +date: 2023/9/17 +*/ static void InsertToBtree(VectorBatch *vecScanBatch, BTBuildState &buildstate, IndexInfo *indexInfo, double &reltuples, Datum *values, bool *isnulls, ScalarToDatum *transferFuncs) {