From e65340519e8fe0f1c1d96d3f5c24ebc2321b6ed1 Mon Sep 17 00:00:00 2001 From: kailixu Date: Tue, 13 Jul 2021 03:00:33 +0000 Subject: [PATCH] refactor --- src/client/inc/tsclient.h | 2 ++ src/client/src/tscParseInsert.c | 4 ++-- src/client/src/tscPrepare.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 072db868d0..c23ca2bc98 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -111,6 +111,8 @@ typedef struct SParsedDataColInfo { int8_t orderStatus; // bounded columns: } SParsedDataColInfo; +#define IS_DATA_COL_ORDERED(s) (((s)->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) + typedef struct { SSchema * pSchema; int16_t sversion; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index edf2421746..5d3f41acd3 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -867,7 +867,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i TDRowLenT kvRowColLen = 0; TDRowLenT colValAppended = 0; - if (spd->orderStatus == ORDER_STATUS_DISORDERED) { + if (!IS_DATA_COL_ORDERED(spd)) { ASSERT(spd->colIdxInfo != NULL); if(!isPrimaryKey) { kvStart = POINTER_SHIFT(kvPrimaryKeyStart, spd->colIdxInfo[i].finalIdx * PAYLOAD_COL_HEAD_LEN); @@ -1020,7 +1020,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32_t numOfCols) { pColInfo->numOfCols = numOfCols; pColInfo->numOfBound = numOfCols; - pColInfo->orderStatus = ORDER_STATUS_UNKNOWN; + pColInfo->orderStatus = ORDER_STATUS_ORDERED; pColInfo->boundedColumns = calloc(pColInfo->numOfCols, sizeof(int32_t)); pColInfo->cols = calloc(pColInfo->numOfCols, sizeof(SBoundColumn)); pColInfo->colIdxInfo = NULL; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 68fa2454d1..3739fbaca5 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -370,7 +370,7 @@ static int refactorPayload(STableDataBlocks* pBlock, int32_t rowNum) { bool isPrimaryKey = (colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX); // the primary key locates in 1st column - if (spd->orderStatus == ORDER_STATUS_DISORDERED) { + if (!IS_DATA_COL_ORDERED(spd)) { ASSERT(spd->colIdxInfo != NULL); if (!isPrimaryKey) { kvStart = POINTER_SHIFT(kvPrimaryKeyStart, spd->colIdxInfo[i].finalIdx * PAYLOAD_COL_HEAD_LEN); @@ -406,7 +406,7 @@ static int refactorPayload(STableDataBlocks* pBlock, int32_t rowNum) { kvRowLen += TYPE_BYTES[pSchema->type]; } - if (spd->orderStatus == ORDER_STATUS_ORDERED) { + if (IS_DATA_COL_ORDERED(spd)) { kvStart += PAYLOAD_COL_HEAD_LEN; // move to next column } } -- GitLab