This is an automated email from the ASF dual-hosted git repository.

yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 6805b17f4ebf3345a0b149c82d676e94dbdc06d1
Author: Junwang Zhao <[email protected]>
AuthorDate: Tue Aug 16 18:12:42 2022 -0700

    [AORO] change addition assignment to assigment
    
    In function `GetAllFileSegInfo_pg_aoseg_rel`, when handling each
    tuple, we `palloc0` a FileSegInfo, `oneseginfo` is just a pointer
    to the zero-allocated memory, using `+=` with the left operand 0
    is the same effect as `=`, and `+=` should burn more cpu cycles
    than `=`.
    
    I'm not sure the compiler will optimize this kind of `+=` to `=`,
    even if it does, using `=` is more accurate since here it is not
    a accumulate semantic.
    
    Signed-off-by: Junwang Zhao <[email protected]>
---
 src/backend/access/appendonly/aosegfiles.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/backend/access/appendonly/aosegfiles.c 
b/src/backend/access/appendonly/aosegfiles.c
index 0e4e32a516..1eb78db3f2 100644
--- a/src/backend/access/appendonly/aosegfiles.c
+++ b/src/backend/access/appendonly/aosegfiles.c
@@ -457,7 +457,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
                        ereport(ERROR,
                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
                                         errmsg("got invalid eof value: 
NULL")));
-               oneseginfo->eof += DatumGetInt64(eof);
+               oneseginfo->eof = DatumGetInt64(eof);
 
                /* get the tupcount */
                tupcount = fastgetattr(tuple, Anum_pg_aoseg_tupcount, 
pg_aoseg_dsc, &isNull);
@@ -465,7 +465,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
                        ereport(ERROR,
                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
                                         errmsg("got invalid tupcount value: 
NULL")));
-               oneseginfo->total_tupcount += DatumGetInt64(tupcount);
+               oneseginfo->total_tupcount = DatumGetInt64(tupcount);
 
                /* get the varblock count */
                varblockcount = fastgetattr(tuple, Anum_pg_aoseg_varblockcount, 
pg_aoseg_dsc, &isNull);
@@ -473,7 +473,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
                        ereport(ERROR,
                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
                                         errmsg("got invalid varblockcount 
value: NULL")));
-               oneseginfo->varblockcount += DatumGetInt64(varblockcount);
+               oneseginfo->varblockcount = DatumGetInt64(varblockcount);
 
                /* get the modcount */
                modcount = fastgetattr(tuple, Anum_pg_aoseg_modcount, 
pg_aoseg_dsc, &isNull);
@@ -481,7 +481,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
                        ereport(ERROR,
                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
                                         errmsg("got invalid modcount value: 
NULL")));
-               oneseginfo->modcount += DatumGetInt64(modcount);
+               oneseginfo->modcount = DatumGetInt64(modcount);
 
                /* get the file format version number */
                formatversion = fastgetattr(tuple, Anum_pg_aoseg_formatversion, 
pg_aoseg_dsc, &isNull);
@@ -515,7 +515,7 @@ GetAllFileSegInfo_pg_aoseg_rel(char *relationName,
                        oneseginfo->eof_uncompressed = InvalidUncompressedEof;
                }
                else
-                       oneseginfo->eof_uncompressed += 
DatumGetInt64(eof_uncompressed);
+                       oneseginfo->eof_uncompressed = 
DatumGetInt64(eof_uncompressed);
 
                elogif(Debug_appendonly_print_scan, LOG,
                           "Append-only found existing segno %d with eof " 
INT64_FORMAT " for table '%s'",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to