diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index f72ad494162fa682456660c492c707ecbf2bedca..cc311228b7b66c65f3af52aaadd29d824a182441 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 a8c263dd7dbf9a00c640788f5020898b9b9e92d8..4dccdcb17ea85418b17ffbc9931776f684c48b8c 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; }