diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 728021543b026d767b520bbb89efdbc7db5135b6..e4b2c7b0a101ac34a93f1dbde1e6218354a9542e 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -115,9 +115,9 @@ typedef struct SParsedDataColInfo { int16_t numOfCols; int16_t numOfBound; uint16_t flen; // TODO: get from STSchema - uint16_t allNullLen; // TODO: get from STSchema + uint16_t allNullLen; // TODO: get from STSchema(base on SDataRow) uint16_t extendedVarLen; - uint16_t boundNullLen; // bound column len with all NULL value + uint16_t boundNullLen; // bound column len with all NULL value(without VarDataOffsetT/SColIdx part) int32_t * boundedColumns; // bound column idx according to schema SBoundColumn * cols; SBoundIdxInfo *colIdxInfo; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 59ad58d03c3e895699ab15b3879fc3c6de6ceb85..e7346b130efe7bff0f1fbdeef1597166cf2c4cfe 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -50,9 +50,9 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, SParsedDataColIn } } - uint32_t dataLen = pColInfo->allNullLen + TD_MEM_ROW_DATA_HEAD_SIZE; + uint32_t dataLen = TD_MEM_ROW_DATA_HEAD_SIZE + pColInfo->allNullLen; uint32_t kvLen = TD_MEM_ROW_KV_HEAD_SIZE + pColInfo->numOfBound * sizeof(SColIdx) + pColInfo->boundNullLen; - if (isConvertToKvRow(kvLen, dataLen)) { + if (isConvertToKVRow(kvLen, dataLen)) { pBuilder->memRowType = SMEM_ROW_KV; } else { pBuilder->memRowType = SMEM_ROW_DATA; @@ -1240,8 +1240,6 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->cols[t].valStat = VAL_STAT_HAS; pColInfo->boundedColumns[pColInfo->numOfBound] = t; ++pColInfo->numOfBound; - // N.B. make sure sizeof(VarDataOffsetT) == sizeof(SColIdx) - pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; switch (pSchema[t].type) { case TSDB_DATA_TYPE_BINARY: pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + CHAR_BYTES); @@ -1250,6 +1248,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); break; default: + pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; break; } findColumnIndex = true; @@ -1275,8 +1274,6 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->cols[t].valStat = VAL_STAT_HAS; pColInfo->boundedColumns[pColInfo->numOfBound] = t; ++pColInfo->numOfBound; - // N.B. make sure sizeof(VarDataOffsetT) == sizeof(SColIdx) - pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; switch (pSchema[t].type) { case TSDB_DATA_TYPE_BINARY: pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + CHAR_BYTES); @@ -1285,6 +1282,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->boundNullLen += (VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); break; default: + pColInfo->boundNullLen += TYPE_BYTES[pSchema[t].type]; break; } findColumnIndex = true; diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 7c2438c7378ccd00edd6e22841cc59465010b11f..664b6f2527a47e4bde0ee359f1d83f7300eb68fc 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -619,8 +619,7 @@ typedef void *SMemRow; #define isDataRow(r) (SMEM_ROW_DATA == memRowType(r)) #define isKvRowT(t) (SMEM_ROW_KV == (((uint8_t)(t)) & 0x01)) #define isKvRow(r) (SMEM_ROW_KV == memRowType(r)) -#define isConvertToKvRow(k, d) ((k) < ((d)*KVRatioConvert)) -#define isConvertToDataRow(k, d) ((k) > (d)) +#define isConvertToKVRow(k, d) ((k) < ((d)*KVRatioConvert)) #define memRowDataBody(r) POINTER_SHIFT(r, TD_MEM_ROW_TYPE_SIZE) // section after flag #define memRowKvBody(r) \