提交 4a365c0d 编写于 作者: C Cary Xu

compile err and bug fix

上级 c10d065e
...@@ -413,8 +413,8 @@ static FORCE_INLINE uint16_t tsSetColumnValue(char *payload, int16_t columnId, u ...@@ -413,8 +413,8 @@ static FORCE_INLINE uint16_t tsSetColumnValue(char *payload, int16_t columnId, u
return PAYLOAD_ID_TYPE_LEN + valueLen; return PAYLOAD_ID_TYPE_LEN + valueLen;
} }
static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *payload, char *msg, char **str, static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *primaryKeyStart, char *payload, char *msg,
bool primaryKey, int16_t timePrec, TDRowLenT *sizeAppend, bool *isColNull, char **str, bool primaryKey, int16_t timePrec, TDRowLenT *sizeAppend, bool *isColNull,
TDRowLenT *dataRowColDeltaLen, TDRowLenT *kvRowColLen) { TDRowLenT *dataRowColDeltaLen, TDRowLenT *kvRowColLen) {
int64_t iv; int64_t iv;
int32_t ret; int32_t ret;
...@@ -721,8 +721,9 @@ static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *pay ...@@ -721,8 +721,9 @@ static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *pay
// *((int64_t *)payload) = 0; // *((int64_t *)payload) = 0;
// When building SKVRow primaryKey, we should not skip even with NULL value. // When building SKVRow primaryKey, we should not skip even with NULL value.
int64_t tmpVal = 0; int64_t tmpVal = 0;
*sizeAppend =
tsSetColumnValue(payload, pSchema->colId, pSchema->type, &tmpVal, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]); *sizeAppend = tsSetColumnValue(primaryKeyStart, pSchema->colId, pSchema->type, &tmpVal,
TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]);
*kvRowColLen += (TDRowLenT)(sizeof(SColIdx) + TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]); *kvRowColLen += (TDRowLenT)(sizeof(SColIdx) + TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]);
} else { } else {
// *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL; // *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL;
...@@ -735,8 +736,9 @@ static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *pay ...@@ -735,8 +736,9 @@ static int32_t tsParseOneColumnKV(SSchema *pSchema, SStrToken *pToken, char *pay
} }
// *((int64_t *)payload) = tmpVal; // *((int64_t *)payload) = tmpVal;
*sizeAppend =
tsSetColumnValue(payload, pSchema->colId, pSchema->type, &tmpVal, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]); *sizeAppend = tsSetColumnValue(primaryKey ? primaryKeyStart : payload, pSchema->colId, pSchema->type, &tmpVal,
TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]);
*kvRowColLen += (TDRowLenT)(sizeof(SColIdx) + TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]); *kvRowColLen += (TDRowLenT)(sizeof(SColIdx) + TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP]);
} }
...@@ -801,7 +803,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i ...@@ -801,7 +803,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
TDRowLenT dataRowLen = pBuilder->allNullLen; TDRowLenT dataRowLen = pBuilder->allNullLen;
TDRowLenT kvRowLen = TD_MEM_ROW_KV_VER_SIZE; TDRowLenT kvRowLen = TD_MEM_ROW_KV_VER_SIZE;
char *kvStart = payload; char *kvPrimayKeyStart = payload + PAYLOAD_HEADER_LEN;
char *kvStart = kvPrimayKeyStart + PLAYLOAD_PRIMARY_COL_LEN; // make sure 1st column tuple is primaryKey
for (int i = 0; i < spd->numOfBound; ++i) { for (int i = 0; i < spd->numOfBound; ++i) {
// the start position in data block buffer of current value in sql // the start position in data block buffer of current value in sql
int32_t colIndex = spd->boundedColumns[i]; // ordered int32_t colIndex = spd->boundedColumns[i]; // ordered
...@@ -871,9 +875,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i ...@@ -871,9 +875,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
TDRowLenT dataRowDeltaColLen = 0; // When combine the data as SDataRow, the delta len between all NULL columns. TDRowLenT dataRowDeltaColLen = 0; // When combine the data as SDataRow, the delta len between all NULL columns.
TDRowLenT kvRowColLen = 0; TDRowLenT kvRowColLen = 0;
TDRowLenT colSizeAppended = 0; TDRowLenT colSizeAppended = 0;
int32_t ret = // make sure the Primarykey locates in the 1st column
tsParseOneColumnKV(pSchema, &sToken, kvStart + PAYLOAD_HEADER_LEN, pInsertParam->msg, str, isPrimaryKey, int32_t ret = tsParseOneColumnKV(pSchema, &sToken, kvPrimayKeyStart, kvStart, pInsertParam->msg, str, isPrimaryKey,
timePrec, &colSizeAppended, &isColNull, &dataRowDeltaColLen, &kvRowColLen); timePrec, &colSizeAppended, &isColNull, &dataRowDeltaColLen, &kvRowColLen);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return ret; return ret;
} }
...@@ -888,7 +892,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i ...@@ -888,7 +892,9 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
} }
kvRowLen += kvRowColLen; kvRowLen += kvRowColLen;
dataRowLen += dataRowDeltaColLen; dataRowLen += dataRowDeltaColLen;
kvStart += colSizeAppended; // move to next column if (!isPrimaryKey) {
kvStart += colSizeAppended; // move to next column
}
rowSizeAppended += colSizeAppended; // calculate rowLen rowSizeAppended += colSizeAppended; // calculate rowLen
} }
...@@ -1134,11 +1140,11 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk ...@@ -1134,11 +1140,11 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk
int32_t i = 0; int32_t i = 0;
int32_t j = 1; int32_t j = 1;
while (j < nRows) { while (j < nRows) {
TSKEY ti = *(TSKEY *)(pBlkKeyTuple + sizeof(SBlockKeyTuple) * i); TSKEY ti = (pBlkKeyTuple + i)->skey;
TSKEY tj = *(TSKEY *)(pBlkKeyTuple + sizeof(SBlockKeyTuple) * j); TSKEY tj = (pBlkKeyTuple + j)->skey;
if (ti == tj) { if (ti == tj) {
totolPayloadLen -= payloadTLen(pBlkKeyTuple + sizeof(SBlockKeyTuple) * j); totolPayloadLen -= payloadTLen(pBlkKeyTuple + j);
++j; ++j;
continue; continue;
} }
......
...@@ -1703,7 +1703,6 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) { ...@@ -1703,7 +1703,6 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) {
++i; ++i;
} }
pBuilder->buf = p;
} else if (memRowType == SMEM_ROW_KV) { } else if (memRowType == SMEM_ROW_KV) {
ASSERT(nColsNotNull <= pBuilder->nCols); ASSERT(nColsNotNull <= pBuilder->nCols);
SKVRow kvRow = (SKVRow)memRowKvBody(memRow); SKVRow kvRow = (SKVRow)memRowKvBody(memRow);
...@@ -1723,8 +1722,6 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) { ...@@ -1723,8 +1722,6 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) {
++i; ++i;
} }
pBuilder->buf = p;
} else { } else {
ASSERT(0); ASSERT(0);
} }
......
...@@ -620,6 +620,7 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o ...@@ -620,6 +620,7 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o
#define PAYLOAD_HEADER_LEN (PAYLOAD_NCOLS_OFFSET + PAYLOAD_NCOLS_LEN) #define PAYLOAD_HEADER_LEN (PAYLOAD_NCOLS_OFFSET + PAYLOAD_NCOLS_LEN)
#define PAYLOAD_ID_LEN sizeof(int16_t) #define PAYLOAD_ID_LEN sizeof(int16_t)
#define PAYLOAD_ID_TYPE_LEN (sizeof(int16_t) + sizeof(uint8_t)) #define PAYLOAD_ID_TYPE_LEN (sizeof(int16_t) + sizeof(uint8_t))
#define PLAYLOAD_PRIMARY_COL_LEN (PAYLOAD_ID_TYPE_LEN + sizeof(TSKEY))
#define payloadBody(r) POINTER_SHIFT(r, PAYLOAD_HEADER_LEN) #define payloadBody(r) POINTER_SHIFT(r, PAYLOAD_HEADER_LEN)
#define payloadType(r) (*(uint8_t *)(r)) #define payloadType(r) (*(uint8_t *)(r))
...@@ -643,9 +644,9 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o ...@@ -643,9 +644,9 @@ static FORCE_INLINE void *tdGetMemRowDataOfCol(void *row, int8_t type, int32_t o
static FORCE_INLINE char *skipToNextEles(char *p) { static FORCE_INLINE char *skipToNextEles(char *p) {
uint8_t colType = payloadColType(p); uint8_t colType = payloadColType(p);
if (IS_VAR_DATA_TYPE(colType)) { if (IS_VAR_DATA_TYPE(colType)) {
return POINTER_SHIFT(p, PAYLOAD_ID_TYPE_LEN + varDataTLen(payloadColValue(p))); return (char *)POINTER_SHIFT(p, PAYLOAD_ID_TYPE_LEN + varDataTLen(payloadColValue(p)));
} else { } else {
return POINTER_SHIFT(p, PAYLOAD_ID_TYPE_LEN + TYPE_BYTES[colType]); return (char *)POINTER_SHIFT(p, PAYLOAD_ID_TYPE_LEN + TYPE_BYTES[colType]);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册