From c2d95cbc0d1e47dbdaceedeecbbc29bad6c085aa Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 1 Jun 2022 07:28:57 +0000 Subject: [PATCH] more --- include/common/tdataformat.h | 5 ++++- source/common/src/tdataformat.c | 12 +++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index f72ad49416..cc311228b7 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -42,7 +42,10 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema * void tTSchemaDestroy(STSchema *pTSchema); // STSRow2 -int32_t tTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow2 **ppRow); +#define COL_VAL_NONE(CID) ((SColVal){.cid = (CID), .isNone = 1}) +#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1}) +#define COL_VAL_VALUE(CID, V) ((SColVal){.cid = (CID), .value = (V)}) + int32_t tTSRowClone(const STSRow2 *pRow, STSRow2 **ppRow); void tTSRowFree(STSRow2 *pRow); void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index a8c263dd7d..4dccdcb17e 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -389,11 +389,9 @@ void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal } if (flags == TSROW_HAS_NONE) { - *pColVal = (SColVal){.isNone = 1, .cid = pTColumn->colId}; - return; + goto _return_none; } else if (flags == TSROW_HAS_NONE) { - *pColVal = (SColVal){.isNull = 1, .cid = pTColumn->colId}; - return; + goto _return_null; } ASSERT(pRow->nData && pRow->pData); @@ -510,15 +508,15 @@ void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal } _return_none: - *pColVal = (SColVal){.cid = pTColumn->colId, .isNone = 1}; + *pColVal = COL_VAL_NONE(pTColumn->colId); return; _return_null: - *pColVal = (SColVal){.cid = pTColumn->colId, .isNull = 1}; + *pColVal = COL_VAL_NULL(pTColumn->colId); return; _return_value: - *pColVal = (SColVal){.cid = pTColumn->colId, .value = value}; + *pColVal = COL_VAL_VALUE(pTColumn->colId, value); return; } -- GitLab