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

update

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