github-actions[bot] commented on code in PR #25006: URL: https://github.com/apache/doris/pull/25006#discussion_r1358271238
########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); Review Comment: warning: 29 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(29, mrb.length()); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); Review Comment: warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(4, *((int8_t*)(buf + 8))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); Review Comment: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(7, *((int8_t*)(buf + 21))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); Review Comment: warning: 56.45 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp mrb.push_float(56.45); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); Review Comment: warning: 254 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(254, *((uint8_t*)(buf))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); Review Comment: warning: 10.12 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp mrb.push_double(10.12); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); + + EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); + EXPECT_EQ(0, strncmp(buf + 12, "1E0", 3)); + EXPECT_EQ(0, strncmp(buf + 15, "-1E0", 4)); + EXPECT_EQ(0, strncmp(buf + 19, "5.645E1", 7)); Review Comment: warning: 19 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 19, "5.645E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); Review Comment: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); + + EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); + EXPECT_EQ(0, strncmp(buf + 12, "1E0", 3)); + EXPECT_EQ(0, strncmp(buf + 15, "-1E0", 4)); Review Comment: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 15, "-1E0", 4)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); Review Comment: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); Review Comment: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(7, *((int8_t*)(buf + 13))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); Review Comment: warning: 13 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(7, *((int8_t*)(buf + 13))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); Review Comment: warning: 10.12 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp mrb.push_double(10.12); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { Review Comment: warning: all parameters should be named in a function [readability-named-parameter] ```suggestion TEST(MysqlRowBufferTest /*unused*/, faster_float_convert /*unused*/) { ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); Review Comment: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); Review Comment: warning: 14 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); Review Comment: warning: 21 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(7, *((int8_t*)(buf + 21))); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { Review Comment: warning: all parameters should be named in a function [readability-named-parameter] ```suggestion TEST(MysqlRowBufferTest /*unused*/, faster_float_convert_dynamic /*unused*/) { ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); Review Comment: warning: 22 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); Review Comment: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); Review Comment: warning: 56.45 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp mrb.push_float(56.45); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); Review Comment: warning: 33 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(33, mrb.length()); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); + + EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); Review Comment: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); + + EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); + EXPECT_EQ(0, strncmp(buf + 12, "1E0", 3)); + EXPECT_EQ(0, strncmp(buf + 15, "-1E0", 4)); + EXPECT_EQ(0, strncmp(buf + 19, "5.645E1", 7)); Review Comment: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 19, "5.645E1", 7)); ^ ``` ########## be/test/util/mysql_row_buffer_test.cpp: ########## @@ -118,4 +118,62 @@ TEST(MysqlRowBufferTest, dynamic_mode) { EXPECT_EQ(0, strncmp(buf + 43, "test", 4)); } +TEST(MysqlRowBufferTest, faster_float_convert) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + // mem: size-data-size-data + // 3-'0E0'-3-'1E0'-4-'-1E0'-7-'5.645E1'-7-'1.012E1' + // 1b-3b---1b-3b---1b-4b----1b-7b-------1b-7b------ + // 0 1 4 5 8 9 13 14 21 22 + + EXPECT_EQ(29, mrb.length()); + + EXPECT_EQ(3, *((int8_t*)(buf + 0))); + EXPECT_EQ(0, strncmp(buf + 1, "0E0", 3)); + + EXPECT_EQ(3, *((int8_t*)(buf + 4))); + EXPECT_EQ(0, strncmp(buf + 5, "1E0", 3)); + + EXPECT_EQ(4, *((int8_t*)(buf + 8))); + EXPECT_EQ(0, strncmp(buf + 9, "-1E0", 4)); + + EXPECT_EQ(7, *((int8_t*)(buf + 13))); + EXPECT_EQ(0, strncmp(buf + 14, "5.645E1", 7)); + + EXPECT_EQ(7, *((int8_t*)(buf + 21))); + EXPECT_EQ(0, strncmp(buf + 22, "1.012E1", 7)); +} + +TEST(MysqlRowBufferTest, faster_float_convert_dynamic) { + MysqlRowBuffer mrb; + mrb.set_faster_float_convert(true); + mrb.open_dynamic_mode(); + + mrb.push_float(0); + mrb.push_float(1.0); + mrb.push_float(-1.0); + mrb.push_float(56.45); + mrb.push_double(10.12); + + const char* buf = mrb.buf(); + + EXPECT_EQ(33, mrb.length()); + EXPECT_EQ(254, *((uint8_t*)(buf))); + + EXPECT_EQ(0, strncmp(buf + 9, "0E0", 3)); + EXPECT_EQ(0, strncmp(buf + 12, "1E0", 3)); Review Comment: warning: 12 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp EXPECT_EQ(0, strncmp(buf + 12, "1E0", 3)); ^ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org