diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 187b7393e6d9dfef9ef3abec9abafe83e208d55b..bb14b284991705045d54d57b8d88bd9d5d361913 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -104,15 +104,11 @@ typedef struct SParsedDataColInfo { } SParsedDataColInfo; typedef struct { - // for SDataRow - SSchema *pSchema; - int16_t sversion; - int32_t flen; - // for SKVRow - uint16_t nCols; - uint16_t size; - void * buf; - + SSchema * pSchema; + int16_t sversion; + int32_t flen; + uint16_t nCols; + void * buf; void * pDataBlock; SSubmitBlk *pSubmitBlk; } SMemRowBuilder; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 9d50c1c62be15c2cebe339a9d51927ae615dcdfb..3b21601cafdb804d62f244f05bb44431822c94e0 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -48,7 +48,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat static FORCE_INLINE int32_t getExtendedRowSize(STableComInfo *tinfo) { return tinfo->rowSize + PAYLOAD_HEADER_LEN + PAYLOAD_COL_HEAD_LEN * tinfo->numOfColumns; } -int initSMemRowHelper(SMemRowHelper *pHelper, SSchema *pSSchema, uint16_t nCols, uint16_t allNullColsLen) { +static int initSMemRowHelper(SMemRowHelper *pHelper, SSchema *pSSchema, uint16_t nCols, uint16_t allNullColsLen) { pHelper->allNullLen = allNullColsLen; // TODO: get allNullColsLen when creating or altering table meta if (pHelper->allNullLen == 0) { for (uint16_t i = 0; i < nCols; ++i) { @@ -406,7 +406,7 @@ static FORCE_INLINE TDRowLenT tsSetPayloadColValue(char *payloadStart, char *pay payloadColSetId(payload, columnId); payloadColSetType(payload, columnType); memcpy(POINTER_SHIFT(payloadStart,tOffset), value, valueLen); - payloadSetTLen(payloadStart, payloadTLen(payloadStart) + valueLen); + // payloadSetTLen(payloadStart, payloadTLen(payloadStart) + valueLen); return valueLen; } @@ -793,7 +793,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i payloadSetNCols(payload, spd->numOfBound); payloadValOffset = payloadValuesOffset(payload); // rely on payloadNCols - payloadSetTLen(payload, payloadValOffset); + // payloadSetTLen(payload, payloadValOffset); char *kvPrimaryKeyStart = payload + PAYLOAD_HEADER_LEN; // primaryKey in 1st column tuple char *kvStart = kvPrimaryKeyStart + PAYLOAD_COL_HEAD_LEN; // the column tuple behind the primaryKey @@ -1138,7 +1138,7 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk size_t nAlloc = nRows * sizeof(SBlockKeyTuple); if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) { size_t nRealAlloc = nAlloc + 10 * sizeof(SBlockKeyTuple); - char * tmp = realloc(pBlkKeyInfo->pKeyTuple, nRealAlloc); + char * tmp = trealloc(pBlkKeyInfo->pKeyTuple, nRealAlloc); if (tmp == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -1609,7 +1609,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat pColInfo->isOrdered = isOrdered; if (!isOrdered) { - pColInfo->colIdxInfo = calloc(pColInfo->numOfBound, sizeof(SBoundIdxInfo)); + pColInfo->colIdxInfo = tcalloc(pColInfo->numOfBound, sizeof(SBoundIdxInfo)); if (pColInfo->colIdxInfo == NULL) { code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto _clean; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ced48d35b2c9d3c539b15c71a3a39393d6c49d38..40f1b7b2fbaed332d5463d0bd1d998dab49ada8d 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1829,7 +1829,6 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo rowBuilder.pDataBlock = pDataBlock; rowBuilder.pSubmitBlk = pBlock; rowBuilder.buf = p; - rowBuilder.size = 0; for (int32_t i = 0; i < numOfRows; ++i) { rowBuilder.buf = (blkKeyTuple + i)->payloadAddr; diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 46d13d709409408553c9e99259dad9e7d84c882c..add2a656f52bf67f82135ec85b8e43901f4895d5 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -190,7 +190,7 @@ static FORCE_INLINE int tkeyComparFn(const void *tkey1, const void *tkey2) { // ----------------- Data row structure /* A data row, the format is like below: - * |<--------------------+--------------------------- len ---------------------------------->| + * |<------------------------------------------------ len ---------------------------------->| * |<-- Head -->|<--------- flen -------------->| | * +---------------------+---------------------------------+---------------------------------+ * | uint16_t | int16_t | | | @@ -224,11 +224,10 @@ SDataRow tdDataRowDup(SDataRow row); static FORCE_INLINE int tdAppendColVal(SDataRow row, const void *value, int8_t type, int32_t offset) { ASSERT(value != NULL); int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE; - char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row)); if (IS_VAR_DATA_TYPE(type)) { *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row); - memcpy(ptr, value, varDataTLen(value)); + memcpy(POINTER_SHIFT(row, dataRowLen(row)), value, varDataTLen(value)); dataRowLen(row) += varDataTLen(value); } else { if (offset == 0) { diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 30d79f7116cb311ad114dc28b34c71278332af6c..acebdaa30a9055f894d791101ab3f1ebeeda8c2e 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -196,9 +196,10 @@ do { \ #define TSDB_APPNAME_LEN TSDB_UNI_LEN /** - * Don't change to 65536. As in some scenarios uint16_t (0~65535) is used to store the row len. - * So, we use 65531(65535 - 4), as the SDataRow and SKVRow including 4 bits header. - * If all cols are VarType except primary key, we need 4 bits to store the offset. 65531-8-4095*4=49143 + * In some scenarios uint16_t (0~65535) is used to store the row len. + * - Firstly, we use 65531(65535 - 4), as the SDataRow and SKVRow including 4 bits header. + * - Secondly, if all cols are VarType except primary key, we need 4 bits to store the offset, thus + * the final value is 65531-8-4095*4 = 49143. */ #define TSDB_MAX_BYTES_PER_ROW 49143 #define TSDB_MAX_TAGS_LEN 16384