From abfa8c1d87d148e460f4e514a07983d2c6205cee Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 3 Nov 2022 22:05:08 +0800 Subject: [PATCH] fix(query): add api to memset buffer for filtering data. --- include/common/tdatablock.h | 2 ++ source/client/CMakeLists.txt | 4 ++-- source/client/test/clientTests.cpp | 13 ++++++++----- source/common/src/tdatablock.c | 10 ++++++++++ source/libs/scalar/src/scalar.c | 1 + 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 24dfa5958d..c24a462ea7 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -217,6 +217,8 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows); int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows); +void colInfoDataMemset(SColumnInfoData* pColumn, uint32_t numOfRows); + void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows); void blockDataCleanup(SSDataBlock* pDataBlock); diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 0c445c7fbf..a14fc650d8 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -60,6 +60,6 @@ target_link_libraries( PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom ) -if(${BUILD_TEST}) +#if(${BUILD_TEST}) ADD_SUBDIRECTORY(test) -endif(${BUILD_TEST}) \ No newline at end of file +#endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 21a52a4b57..85814305bd 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -112,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) { } taos_free_result(pRes); - for(int32_t i = 0; i < 10000; i += 20) { + for(int32_t i = 0; i < 20; i += 20) { char sql[1024] = {0}; sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -692,6 +692,7 @@ TEST(testCase, insert_test) { taos_free_result(pRes); taos_close(pConn); } +#endif TEST(testCase, projection_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -703,7 +704,7 @@ TEST(testCase, projection_query_tables) { // } // taos_free_result(pRes); - TAOS_RES* pRes = taos_query(pConn, "use benchmarkcpu"); + TAOS_RES* pRes = taos_query(pConn, "use abc2"); taos_free_result(pRes); pRes = taos_query(pConn, "create stable st1 (ts timestamp, k int) tags(a int)"); @@ -725,7 +726,7 @@ TEST(testCase, projection_query_tables) { } taos_free_result(pRes); - for (int32_t i = 0; i < 2; ++i) { + for (int32_t i = 0; i < 200000; ++i) { printf("create table :%d\n", i); createNewTable(pConn, i); } @@ -750,7 +751,9 @@ TEST(testCase, projection_query_tables) { taos_free_result(pRes); taos_close(pConn); } -#endif + + +#if 0 TEST(testCase, tsbs_perf_test) { TdThread qid[20] = {0}; @@ -761,7 +764,7 @@ TEST(testCase, tsbs_perf_test) { getchar(); } -#if 0 + TEST(testCase, projection_query_stables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 322d9a1f75..69b270d46c 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1208,6 +1208,16 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows) return doEnsureCapacity(pColumn, &info, numOfRows); } +void colInfoDataMemset(SColumnInfoData* pColumn, uint32_t numOfRows) { + if (!IS_VAR_DATA_TYPE(pColumn->info.type)) { + memset(pColumn->pData, 0, pColumn->info.bytes * numOfRows); + } else { + if (pColumn->varmeta.length > 0) { + memset(pColumn->pData, 0, pColumn->varmeta.length); + } + } +} + int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) { int32_t code = 0; if (numOfRows == 0) { diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index ea1ce175e3..9d7c0f978f 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -56,6 +56,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara return terrno; } + colInfoDataMemset(pColumnData, numOfRows); pParam->columnData = pColumnData; pParam->colAlloced = true; return TSDB_CODE_SUCCESS;