提交 53eb1bd0 编写于 作者: H hzcheng

TD-166

上级 9ee4a03e
...@@ -633,45 +633,39 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList, ...@@ -633,45 +633,39 @@ int32_t tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList,
static void trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) { static void trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
int32_t firstPartLen = 0; int32_t firstPartLen = 0;
STableMeta* pTableMeta = pTableDataBlock->pTableMeta; STableMeta* pTableMeta = pTableDataBlock->pTableMeta;
STableComInfo tinfo = tscGetTableInfo(pTableMeta); STableComInfo tinfo = tscGetTableInfo(pTableMeta);
SSchema* pSchema = tscGetTableSchema(pTableMeta); SSchema* pSchema = tscGetTableSchema(pTableMeta);
SSubmitBlk* pBlock = pDataBlock;
memcpy(pDataBlock, pTableDataBlock->pData, sizeof(SSubmitBlk)); memcpy(pDataBlock, pTableDataBlock->pData, sizeof(SSubmitBlk));
pDataBlock += sizeof(SSubmitBlk); pDataBlock += sizeof(SSubmitBlk);
int32_t total = sizeof(int32_t)*2; int32_t flen = 0;
for(int32_t i = 0; i < tinfo.numOfColumns; ++i) { for (int32_t i = 0; i < tinfo.numOfColumns; ++i) {
switch (pSchema[i].type) { flen += TYPE_BYTES[pSchema[i].type];
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_BINARY: {
assert(0); // not support binary yet
firstPartLen += sizeof(int32_t);break;
}
default:
firstPartLen += tDataTypeDesc[pSchema[i].type].nSize;
total += tDataTypeDesc[pSchema[i].type].nSize;
}
} }
char* p = pTableDataBlock->pData + sizeof(SSubmitBlk); char* p = pTableDataBlock->pData + sizeof(SSubmitBlk);
pBlock->len = 0;
SSubmitBlk* pBlock = (SSubmitBlk*) pTableDataBlock->pData; for (int32_t i = 0; i < htons(pBlock->numOfRows); ++i) {
int32_t rows = htons(pBlock->numOfRows); SDataRow trow = (SDataRow)pDataBlock;
dataRowSetLen(trow, TD_DATA_ROW_HEAD_SIZE + flen);
for(int32_t i = 0; i < rows; ++i) {
*(int32_t*) pDataBlock = total; int toffset = 0;
pDataBlock += sizeof(int32_t); for (int32_t j = 0; j < tinfo.numOfColumns; j++) {
tdAppendColVal(trow, p, pSchema[j].type, pSchema[j].bytes, toffset);
// *(int32_t*) pDataBlock = firstPartLen; toffset += TYPE_BYTES[pSchema[j].type];
// pDataBlock += sizeof(int32_t); p += pSchema[j].bytes;
}
memcpy(pDataBlock, p, pTableDataBlock->rowSize);
// p += pTableDataBlock->rowSize;
p += pTableDataBlock->rowSize; pDataBlock += dataRowLen(trow);
pDataBlock += pTableDataBlock->rowSize; pBlock->len += dataRowLen(trow);
} }
pBlock->len = htonl(pBlock->len);
} }
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockList) { int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pTableDataBlockList) {
......
...@@ -174,7 +174,7 @@ int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_ ...@@ -174,7 +174,7 @@ int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_
if (value == NULL) { if (value == NULL) {
*(int32_t *)dataRowAt(row, toffset) = -1; *(int32_t *)dataRowAt(row, toffset) = -1;
} else { } else {
int16_t slen = (type) ? strlen((char *)value) : wcslen((wchar_t *)value) * TSDB_NCHAR_SIZE; int16_t slen = (type) ? strnlen((char *)value, bytes) : wcsnlen((wchar_t *)value, bytes/TSDB_NCHAR_SIZE) * TSDB_NCHAR_SIZE;
if (slen > bytes) return -1; if (slen > bytes) return -1;
*(int32_t *)dataRowAt(row, toffset) = dataRowLen(row); *(int32_t *)dataRowAt(row, toffset) = dataRowLen(row);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册