From 7ad5e7429fc10e8aa0be59b4bee388a984cb1771 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 10 Mar 2022 15:34:15 +0800 Subject: [PATCH] ajust STSma definition --- include/common/tmsg.h | 116 ++++++++++++++++-------- include/util/tdef.h | 2 +- source/dnode/vnode/src/inc/tsdbFS.h | 24 ++++- source/dnode/vnode/src/inc/tsdbFile.h | 4 +- source/dnode/vnode/src/inc/tsdbSma.h | 2 +- source/dnode/vnode/src/tsdb/tsdbFile.c | 4 +- source/dnode/vnode/src/tsdb/tsdbMain.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 6 +- source/dnode/vnode/test/tsdbSmaTest.cpp | 102 +++++++++++++-------- 9 files changed, 171 insertions(+), 91 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 238753e5b7..bbb3f6e22d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1856,19 +1856,27 @@ typedef enum { TD_TIME_UNIT_MICROSEC = 9, TD_TIME_UNIT_NANOSEC = 10 } ETDTimeUnit; + +typedef struct { + uint16_t funcId; + uint16_t nColIds; + col_id_t* colIds; // sorted colIds +} SFuncColIds; + typedef struct { - uint8_t version; // for compatibility - uint8_t intervalUnit; - uint8_t slidingUnit; - char indexName[TSDB_INDEX_NAME_LEN + 1]; - col_id_t numOfColIds; - uint16_t numOfFuncIds; - uint64_t tableUid; // super/common table uid - int64_t interval; - int64_t sliding; - col_id_t* colIds; // sorted column ids - uint16_t* funcIds; // sorted sma function ids -} STSma; // Time-range-wise SMA + uint8_t version; // for compatibility + uint8_t intervalUnit; + uint8_t slidingUnit; + char indexName[TSDB_INDEX_NAME_LEN]; + char timezone[TD_TIMEZONE_LEN]; + uint16_t nFuncColIds; + uint16_t tagsFilterLen; + tb_uid_t tableUid; // super/common table uid + int64_t interval; + int64_t sliding; + SFuncColIds* funcColIds; // sorted funcIds + char* tagsFilter; +} STSma; // Time-range-wise SMA typedef struct { int64_t ver; // use a general definition @@ -1877,13 +1885,13 @@ typedef struct { typedef struct { int8_t type; // 0 status report, 1 update data - char indexName[TSDB_INDEX_NAME_LEN + 1]; // + char indexName[TSDB_INDEX_NAME_LEN]; // STimeWindow windows; } STSmaMsg; typedef struct { int64_t ver; // use a general definition - char indexName[TSDB_INDEX_NAME_LEN + 1]; + char indexName[TSDB_INDEX_NAME_LEN]; } SVDropTSmaReq; typedef struct { } SVCreateTSmaRsp, SVDropTSmaRsp; @@ -1934,8 +1942,14 @@ typedef struct { static FORCE_INLINE void tdDestroyTSma(STSma* pSma) { if (pSma) { - tfree(pSma->colIds); - tfree(pSma->funcIds); + if (pSma->funcColIds != NULL) { + for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) { + tfree((pSma->funcColIds + i)->colIds); + } + tfree(pSma->funcColIds); + } + + tfree(pSma->tagsFilter); } } @@ -1957,18 +1971,24 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedU8(buf, pSma->intervalUnit); tlen += taosEncodeFixedU8(buf, pSma->slidingUnit); tlen += taosEncodeString(buf, pSma->indexName); - tlen += taosEncodeFixedU16(buf, pSma->numOfColIds); - tlen += taosEncodeFixedU16(buf, pSma->numOfFuncIds); - tlen += taosEncodeFixedU64(buf, pSma->tableUid); + tlen += taosEncodeString(buf, pSma->timezone); + tlen += taosEncodeFixedU16(buf, pSma->nFuncColIds); + tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen); + tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); tlen += taosEncodeFixedI64(buf, pSma->sliding); - for (col_id_t i = 0; i < pSma->numOfColIds; ++i) { - tlen += taosEncodeFixedU16(buf, *(pSma->colIds + i)); + for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) { + SFuncColIds* funcColIds = pSma->funcColIds + i; + tlen += taosEncodeFixedU16(buf, funcColIds->funcId); + tlen += taosEncodeFixedU16(buf, funcColIds->nColIds); + for (uint16_t j = 0; j < funcColIds->nColIds; ++j) { + tlen += taosEncodeFixedU16(buf, *(funcColIds->colIds + j)); + } } - for (uint16_t i = 0; i < pSma->numOfFuncIds; ++i) { - tlen += taosEncodeFixedU16(buf, *(pSma->funcIds + i)); + if (pSma->tagsFilterLen > 0) { + tlen += taosEncodeString(buf, pSma->tagsFilter); } return tlen; @@ -1989,34 +2009,52 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedU8(buf, &pSma->intervalUnit); buf = taosDecodeFixedU8(buf, &pSma->slidingUnit); buf = taosDecodeStringTo(buf, pSma->indexName); - buf = taosDecodeFixedU16(buf, &pSma->numOfColIds); - buf = taosDecodeFixedU16(buf, &pSma->numOfFuncIds); - buf = taosDecodeFixedU64(buf, &pSma->tableUid); + buf = taosDecodeStringTo(buf, pSma->timezone); + buf = taosDecodeFixedU16(buf, &pSma->nFuncColIds); + buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen); + buf = taosDecodeFixedI64(buf, &pSma->tableUid); buf = taosDecodeFixedI64(buf, &pSma->interval); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->numOfColIds > 0) { - pSma->colIds = (col_id_t*)calloc(pSma->numOfColIds, sizeof(STSma)); - if (pSma->colIds == NULL) { + if (pSma->nFuncColIds > 0) { + pSma->funcColIds = (SFuncColIds*)calloc(pSma->nFuncColIds, sizeof(SFuncColIds)); + if (pSma->funcColIds == NULL) { + tdDestroyTSma(pSma); return NULL; } - for (uint16_t i = 0; i < pSma->numOfColIds; ++i) { - buf = taosDecodeFixedU16(buf, pSma->colIds + i); + for (uint16_t i = 0; i < pSma->nFuncColIds; ++i) { + SFuncColIds* funcColIds = pSma->funcColIds + i; + buf = taosDecodeFixedU16(buf, &funcColIds->funcId); + buf = taosDecodeFixedU16(buf, &funcColIds->nColIds); + if (funcColIds->nColIds > 0) { + funcColIds->colIds = (col_id_t*)calloc(funcColIds->nColIds, sizeof(col_id_t)); + if (funcColIds->colIds != NULL) { + for (uint16_t j = 0; j < funcColIds->nColIds; ++j) { + buf = taosDecodeFixedU16(buf, funcColIds->colIds + j); + } + } else { + tdDestroyTSma(pSma); + return NULL; + } + } else { + funcColIds->colIds = NULL; + } } } else { - pSma->colIds = NULL; + pSma->funcColIds = NULL; } - if (pSma->numOfFuncIds > 0) { - pSma->funcIds = (uint16_t*)calloc(pSma->numOfFuncIds, sizeof(STSma)); - if (pSma->funcIds == NULL) { + if (pSma->tagsFilterLen > 0) { + pSma->tagsFilter = (char*)calloc(pSma->tagsFilterLen, 1); + if (pSma->tagsFilter != NULL) { + buf = taosDecodeStringTo(buf, pSma->tagsFilter); + } else { + tdDestroyTSma(pSma); return NULL; } - for (uint16_t i = 0; i < pSma->numOfFuncIds; ++i) { - buf = taosDecodeFixedU16(buf, pSma->funcIds + i); - } + } else { - pSma->funcIds = NULL; + pSma->tagsFilter = NULL; } return buf; diff --git a/include/util/tdef.h b/include/util/tdef.h index 664588f68f..902ed871f0 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -207,7 +207,7 @@ typedef enum ELogicConditionType { #define TSDB_FUNC_TYPE_AGGREGATE 2 #define TSDB_FUNC_MAX_RETRIEVE 1024 -#define TSDB_INDEX_NAME_LEN 32 +#define TSDB_INDEX_NAME_LEN 33 // 32 + 1 '\0' #define TSDB_TYPE_STR_MAX_LEN 32 #define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN diff --git a/source/dnode/vnode/src/inc/tsdbFS.h b/source/dnode/vnode/src/inc/tsdbFS.h index 173e991631..a7275f57fd 100644 --- a/source/dnode/vnode/src/inc/tsdbFS.h +++ b/source/dnode/vnode/src/inc/tsdbFS.h @@ -43,12 +43,30 @@ typedef struct { STsdbFSMeta meta; // FS meta SArray * df; // data file array - // SArray * v2f100.tsma.index_name + // SArray * v2t100.index_name - SArray * smaf; // sma data file array v2f1900.tsma.index_name + SArray * smaf; // sma data file array v2t1900.index_name } SFSStatus; -typedef struct { +/** + * @brief Directory structure of .tsma data files. + * + * root@cary /vnode2/tsdb $ tree .tsma/ + * .tsma/ + * ├── v2t100.index_name_1 + * ├── v2t101.index_name_1 + * ├── v2t102.index_name_1 + * ├── v2t1900.index_name_3 + * ├── v2t1901.index_name_3 + * ├── v2t1902.index_name_3 + * ├── v2t200.index_name_2 + * ├── v2t201.index_name_2 + * └── v2t202.index_name_2 + * + * 0 directories, 9 files + */ + + typedef struct { pthread_rwlock_t lock; SFSStatus *cstatus; // current status diff --git a/source/dnode/vnode/src/inc/tsdbFile.h b/source/dnode/vnode/src/inc/tsdbFile.h index b58bfe77ab..d6ce33c389 100644 --- a/source/dnode/vnode/src/inc/tsdbFile.h +++ b/source/dnode/vnode/src/inc/tsdbFile.h @@ -56,8 +56,8 @@ typedef enum { TSDB_FILE_SMAL, // .smal(Block-wise SMA) TSDB_FILE_MAX, // TSDB_FILE_META, // meta - TSDB_FILE_TSMA, // .tsma.${sma_index_name}, Time-range-wise SMA - TSDB_FILE_RSMA, // .rsma.${sma_index_name}, Time-range-wise Rollup SMA + TSDB_FILE_TSMA, // v2t100.${sma_index_name}, Time-range-wise SMA + TSDB_FILE_RSMA, // v2r100.${sma_index_name}, Time-range-wise Rollup SMA } E_TSDB_FILE_T; typedef int32_t TSDB_FILE_T; diff --git a/source/dnode/vnode/src/inc/tsdbSma.h b/source/dnode/vnode/src/inc/tsdbSma.h index 6e4ad909ae..1a5ccbdc21 100644 --- a/source/dnode/vnode/src/inc/tsdbSma.h +++ b/source/dnode/vnode/src/inc/tsdbSma.h @@ -31,7 +31,7 @@ int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSma *param, STSmaData *pData, STimeW int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, char *msg); int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result); int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin); -int32_t tsdbFreeSmaState(SSmaStat *pSmaStat); +int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); // internal func diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 00e97c7b61..b756cc9862 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -23,8 +23,8 @@ static const char *TSDB_FNAME_SUFFIX[] = { "smal", // TSDB_FILE_SMAL "", // TSDB_FILE_MAX "meta", // TSDB_FILE_META - "tsma", // TSDB_FILE_TSMA - "rsma", // TSDB_FILE_RSMA + "sma", // TSDB_FILE_TSMA(directory name) + "sma", // TSDB_FILE_RSMA(directory name) }; static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname); diff --git a/source/dnode/vnode/src/tsdb/tsdbMain.c b/source/dnode/vnode/src/tsdb/tsdbMain.c index 1b3e00f090..0c82911226 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMain.c +++ b/source/dnode/vnode/src/tsdb/tsdbMain.c @@ -89,7 +89,7 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, static void tsdbFree(STsdb *pTsdb) { if (pTsdb) { tsdbFreeFS(pTsdb->fs); - tsdbFreeSmaState(pTsdb->pSmaStat); + tsdbDestroySmaState(pTsdb->pSmaStat); tfree(pTsdb->path); free(pTsdb); } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index aa9fb7c7ed..51abcbd9dd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -128,7 +128,7 @@ static SSmaStatItem *tsdbNewSmaStatItem(int8_t state) { return pItem; } -int32_t tsdbFreeSmaState(SSmaStat *pSmaStat) { +int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { if (pSmaStat) { // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. SSmaStatItem *item = taosHashIterate(pSmaStat->smaStatItems, NULL); @@ -404,7 +404,7 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaData *pData, i static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, STSma *param, STSmaData *pData) { pSmaH->pTsdb = pTsdb; pSmaH->interval = tsdbGetIntervalByPrecision(param->interval, param->intervalUnit, REPO_CFG(pTsdb)->precision); - pSmaH->blockSize = param->numOfFuncIds * sizeof(int64_t); + // pSmaH->blockSize = param->numOfFuncIds * sizeof(int64_t); } static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSma *param, STSmaData *pData, int32_t storageLevel, @@ -582,7 +582,7 @@ int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, SRSma *param, STSmaData *pData) { static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, STSma *param, STSmaData *pData) { pSmaH->pTsdb = pTsdb; pSmaH->interval = tsdbGetIntervalByPrecision(param->interval, param->intervalUnit, REPO_CFG(pTsdb)->precision); - pSmaH->blockSize = param->numOfFuncIds * sizeof(int64_t); + // pSmaH->blockSize = param->numOfFuncIds * sizeof(int64_t); } /** diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index bf3e67cdf5..5a5c5e1530 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -42,17 +42,20 @@ TEST(testCase, tSmaEncodeDecodeTest) { tSma.slidingUnit = TD_TIME_UNIT_HOUR; tSma.sliding = 0; tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN); + tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN); tSma.tableUid = 1234567890; - tSma.numOfColIds = 2; - tSma.numOfFuncIds = 5; // sum/min/max/avg/last - tSma.colIds = (col_id_t *)calloc(tSma.numOfColIds, sizeof(col_id_t)); - tSma.funcIds = (uint16_t *)calloc(tSma.numOfFuncIds, sizeof(uint16_t)); - - for (int32_t i = 0; i < tSma.numOfColIds; ++i) { - *(tSma.colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID); - } - for (int32_t i = 0; i < tSma.numOfFuncIds; ++i) { - *(tSma.funcIds + i) = (i + 2); + tSma.nFuncColIds = 5; + tSma.funcColIds = (SFuncColIds *)calloc(tSma.nFuncColIds, sizeof(SFuncColIds)); + ASSERT(tSma.funcColIds != NULL); + for (int32_t n = 0; n < tSma.nFuncColIds; ++n) { + SFuncColIds *funcColIds = tSma.funcColIds + n; + funcColIds->funcId = n; + funcColIds->nColIds = 10; + funcColIds->colIds = (col_id_t *)calloc(funcColIds->nColIds, sizeof(col_id_t)); + ASSERT(funcColIds->colIds != NULL); + for (int32_t i = 0; i < funcColIds->nColIds; ++i) { + *(funcColIds->colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID); + } } STSmaWrapper tSmaWrapper = {.number = 1, .tSma = &tSma}; @@ -81,16 +84,21 @@ TEST(testCase, tSmaEncodeDecodeTest) { EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit); EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit); EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName); - EXPECT_EQ(pSma->numOfColIds, qSma->numOfColIds); - EXPECT_EQ(pSma->numOfFuncIds, qSma->numOfFuncIds); + EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone); + EXPECT_EQ(pSma->nFuncColIds, qSma->nFuncColIds); EXPECT_EQ(pSma->tableUid, qSma->tableUid); EXPECT_EQ(pSma->interval, qSma->interval); EXPECT_EQ(pSma->sliding, qSma->sliding); - for (uint32_t j = 0; j < pSma->numOfColIds; ++j) { - EXPECT_EQ(*(col_id_t *)(pSma->colIds + j), *(col_id_t *)(qSma->colIds + j)); - } - for (uint32_t j = 0; j < pSma->numOfFuncIds; ++j) { - EXPECT_EQ(*(uint16_t *)(pSma->funcIds + j), *(uint16_t *)(qSma->funcIds + j)); + EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); + EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); + for (uint32_t j = 0; j < pSma->nFuncColIds; ++j) { + SFuncColIds *pFuncColIds = pSma->funcColIds + j; + SFuncColIds *qFuncColIds = qSma->funcColIds + j; + EXPECT_EQ(pFuncColIds->funcId, qFuncColIds->funcId); + EXPECT_EQ(pFuncColIds->nColIds, qFuncColIds->nColIds); + for (uint32_t k = 0; k < pFuncColIds->nColIds; ++k) { + EXPECT_EQ(*(pFuncColIds->colIds + k), *(qFuncColIds->colIds + k)); + } } } @@ -100,9 +108,11 @@ TEST(testCase, tSmaEncodeDecodeTest) { } TEST(testCase, tSma_DB_Put_Get_Del_Test) { - const char *smaIndexName1 = "sma_index_test_1"; - const char *smaIndexName2 = "sma_index_test_2"; - const char *smaTestDir = "./smaTest"; + const char * smaIndexName1 = "sma_index_test_1"; + const char * smaIndexName2 = "sma_index_test_2"; + const char * timeZone = "Asia/Shanghai"; + const char * tagsFilter = "I'm tags filter"; + const char * smaTestDir = "./smaTest"; const uint64_t tbUid = 1234567890; const uint32_t nCntTSma = 2; // encode @@ -113,21 +123,27 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { tSma.slidingUnit = TD_TIME_UNIT_HOUR; tSma.sliding = 0; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); + tstrncpy(tSma.timezone, timeZone, TD_TIMEZONE_LEN); tSma.tableUid = tbUid; - tSma.numOfColIds = 2; - tSma.numOfFuncIds = 5; // sum/min/max/avg/last - tSma.colIds = (col_id_t *)calloc(tSma.numOfColIds, sizeof(col_id_t)); - tSma.funcIds = (uint16_t *)calloc(tSma.numOfFuncIds, sizeof(uint16_t)); - - for (int32_t i = 0; i < tSma.numOfColIds; ++i) { - *(tSma.colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID); - } - for (int32_t i = 0; i < tSma.numOfFuncIds; ++i) { - *(tSma.funcIds + i) = (i + 2); + tSma.nFuncColIds = 5; + tSma.funcColIds = (SFuncColIds *)calloc(tSma.nFuncColIds, sizeof(SFuncColIds)); + ASSERT(tSma.funcColIds != NULL); + for (int32_t n = 0; n < tSma.nFuncColIds; ++n) { + SFuncColIds *funcColIds = tSma.funcColIds + n; + funcColIds->funcId = n; + funcColIds->nColIds = 10; + funcColIds->colIds = (col_id_t *)calloc(funcColIds->nColIds, sizeof(col_id_t)); + ASSERT(funcColIds->colIds != NULL); + for (int32_t i = 0; i < funcColIds->nColIds; ++i) { + *(funcColIds->colIds + i) = (i + PRIMARYKEY_TIMESTAMP_COL_ID); + } } + tSma.tagsFilterLen = strlen(tagsFilter); + tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; - STSma * pSmaCfg = &tSma; + STSma * pSmaCfg = &tSma; const SMetaCfg *pMetaCfg = &defaultMetaOptions; taosRemoveDir(smaTestDir); @@ -152,6 +168,8 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { qSmaCfg = metaGetSmaInfoByName(pMeta, smaIndexName1); assert(qSmaCfg != NULL); printf("name1 = %s\n", qSmaCfg->indexName); + printf("timezone1 = %s\n", qSmaCfg->timezone); + printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid); tdDestroyTSma(qSmaCfg); @@ -160,6 +178,8 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { qSmaCfg = metaGetSmaInfoByName(pMeta, smaIndexName2); assert(qSmaCfg != NULL); printf("name2 = %s\n", qSmaCfg->indexName); + printf("timezone2 = %s\n", qSmaCfg->timezone); + printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); EXPECT_EQ(qSmaCfg->interval, tSma.interval); tdDestroyTSma(qSmaCfg); @@ -170,7 +190,7 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { assert(pSmaCur != NULL); uint32_t indexCnt = 0; while (1) { - const char* indexName = metaSmaCursorNext(pSmaCur); + const char *indexName = metaSmaCursorNext(pSmaCur); if (indexName == NULL) { break; } @@ -185,10 +205,14 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { assert(pSW != NULL); EXPECT_EQ(pSW->number, nCntTSma); EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); + EXPECT_STRCASEEQ(pSW->tSma->timezone, timeZone); + EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); EXPECT_EQ(pSW->tSma->tableUid, tSma.tableUid); EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); + EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timeZone); + EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); EXPECT_EQ((pSW->tSma + 1)->tableUid, tSma.tableUid); - + tdDestroyTSmaWrapper(pSW); tfree(pSW); @@ -210,11 +234,11 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) { metaClose(pMeta); } -#if 1 +#if 0 TEST(testCase, tSmaInsertTest) { - STSma tSma = {0}; - STSmaData* pSmaData = NULL; - STsdb tsdb = {0}; + STSma tSma = {0}; + STSmaData *pSmaData = NULL; + STsdb tsdb = {0}; // init tSma.intervalUnit = TD_TIME_UNIT_DAY; @@ -227,7 +251,7 @@ TEST(testCase, tSmaInsertTest) { int32_t dataLen = numOfColIds * numOfBlocks * blockSize; - pSmaData = (STSmaData*)malloc(sizeof(STSmaData) + dataLen); + pSmaData = (STSmaData *)malloc(sizeof(STSmaData) + dataLen); ASSERT_EQ(pSmaData != NULL, true); pSmaData->tableUid = 3232329230; pSmaData->numOfColIds = numOfColIds; @@ -235,7 +259,7 @@ TEST(testCase, tSmaInsertTest) { pSmaData->dataLen = dataLen; pSmaData->tsWindow.skey = 1640000000; pSmaData->tsWindow.ekey = 1645788649; - pSmaData->colIds = (col_id_t*)malloc(sizeof(col_id_t) * numOfColIds); + pSmaData->colIds = (col_id_t *)malloc(sizeof(col_id_t) * numOfColIds); ASSERT_EQ(pSmaData->colIds != NULL, true); for (int32_t i = 0; i < numOfColIds; ++i) { -- GitLab