提交 e24b03f8 编写于 作者: C Cary Xu

update

上级 6c1fde6d
......@@ -444,14 +444,12 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
return TSDB_CODE_SUCCESS;
}
int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, bool *isConverted, int32_t rowSize,
int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, int32_t *convertIndex, int32_t rowSize,
char *tmpTokenBuf, SInsertStatementParam *pInsertParam) {
int32_t index = 0;
SStrToken sToken = {0};
char *row = pDataBlocks->pData +
((*isConverted) ? (pDataBlocks->size - rowSize) : pDataBlocks->size); // skip the SSubmitBlk header
*isConverted = false;
char *row = pDataBlocks->pData + (pDataBlocks->size - (*convertIndex) * rowSize); // skip the SSubmitBlk header
SParsedDataColInfo *spd = &pDataBlocks->boundColumnInfo;
STableMeta * pTableMeta = pDataBlocks->pTableMeta;
......@@ -570,8 +568,11 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, b
// 4. perform the convert
if (isNeedConvertRow) {
// put converted row to next location to minimize the memcpy
convertSMemRow(row + rowSize, row, pDataBlocks);
*isConverted = true;
++(*convertIndex);
convertSMemRow(row + (*convertIndex) * rowSize, row, pDataBlocks);
pDataBlocks->ordered = false;
} else {
*convertIndex = 0;
}
}
......@@ -631,7 +632,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
pDataBlock->boundColumnInfo.allNullLen))) {
return code;
}
bool isConverted = false;
int32_t convertIndex = 0;
while (1) {
index = 0;
sToken = tStrGetToken(*str, &index, false);
......@@ -651,7 +652,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
maxRows = tSize;
}
code = tsParseOneRow(str, pDataBlock, precision, &isConverted, extendedRowSize, tmpTokenBuf, pInsertParam);
code = tsParseOneRow(str, pDataBlock, precision, &convertIndex, extendedRowSize, tmpTokenBuf, pInsertParam);
if (code != TSDB_CODE_SUCCESS) { // error message has been set in tsParseOneRow, return directly
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
......@@ -668,9 +669,9 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
(*numOfRows)++;
}
if (isConverted) {
void *convertedSMemRow = pDataBlock->pData + pDataBlock->size;
memcpy(POINTER_SHIFT(convertedSMemRow, -extendedRowSize), convertedSMemRow, (size_t)memRowTLen(convertedSMemRow));
if (convertIndex) {
char *convertedSMemRow = pDataBlock->pData + pDataBlock->size;
memcpy(convertedSMemRow - convertIndex * extendedRowSize, convertedSMemRow, (size_t)memRowTLen(convertedSMemRow));
}
if ((*numOfRows) <= 0) {
......@@ -870,7 +871,7 @@ int tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlk
++j;
}
pBlocks->numOfRows = i + 1;
}
}
}
dataBuf->size = sizeof(SSubmitBlk) + pBlocks->numOfRows * extendedRowSize;
......@@ -1779,7 +1780,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
--maxRows; // 1 more row needed to facilitate the SDataRow/SKVRow convert
ASSERT(maxRows > 0);
bool isConverted = false;
int32_t convertIndex = 0;
while ((readLen = tgetline(&line, &n, fp)) != -1) {
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
line[--readLen] = 0;
......@@ -1792,7 +1793,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
char *lineptr = line;
strtolower(line, line);
code = tsParseOneRow(&lineptr, pTableDataBlock, tinfo.precision, &isConverted, extendedRowSize, tokenBuf,
code = tsParseOneRow(&lineptr, pTableDataBlock, tinfo.precision, &convertIndex, extendedRowSize, tokenBuf,
pInsertParam);
if (code != TSDB_CODE_SUCCESS || pTableDataBlock->numOfParams > 0) {
pSql->res.code = code;
......@@ -1805,9 +1806,9 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
break;
}
}
if (isConverted) {
void *convertedSMemRow = pTableDataBlock->pData + pTableDataBlock->size;
memcpy(POINTER_SHIFT(convertedSMemRow, -extendedRowSize), convertedSMemRow, (size_t)memRowTLen(convertedSMemRow));
if (convertIndex) {
char *convertedSMemRow = pTableDataBlock->pData + pTableDataBlock->size;
memcpy(convertedSMemRow - convertIndex * extendedRowSize, convertedSMemRow, (size_t)memRowTLen(convertedSMemRow));
}
tfree(tokenBuf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册