TD-166
This commit is contained in:
parent
7fafd24ef6
commit
01780f4add
|
@ -664,8 +664,8 @@ static void trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
|
|||
*(int32_t*) pDataBlock = total;
|
||||
pDataBlock += sizeof(int32_t);
|
||||
|
||||
*(int32_t*) pDataBlock = firstPartLen;
|
||||
pDataBlock += sizeof(int32_t);
|
||||
// *(int32_t*) pDataBlock = firstPartLen;
|
||||
// pDataBlock += sizeof(int32_t);
|
||||
|
||||
memcpy(pDataBlock, p, pTableDataBlock->rowSize);
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ typedef void *SDataRow;
|
|||
SDataRow tdNewDataRowFromSchema(STSchema *pSchema);
|
||||
void tdFreeDataRow(SDataRow row);
|
||||
void tdInitDataRow(SDataRow row, STSchema *pSchema);
|
||||
int tdAppendColVal(SDataRow row, void *value, STSchema *pSchema, int col);
|
||||
int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset);
|
||||
void tdDataRowReset(SDataRow row, STSchema *pSchema);
|
||||
SDataRow tdDataRowDup(SDataRow row);
|
||||
|
||||
|
|
|
@ -160,22 +160,22 @@ void tdFreeDataRow(SDataRow row) {
|
|||
|
||||
/**
|
||||
* Append a column value to the data row
|
||||
* @param type: column type
|
||||
* @param bytes: column bytes
|
||||
* @param offset: offset in the data row tuple, not including the data row header
|
||||
*/
|
||||
int tdAppendColVal(SDataRow row, void *value, STSchema *pSchema, int col) {
|
||||
ASSERT(schemaNCols(pSchema) > col);
|
||||
STColumn *pCol = schemaColAt(pSchema, col);
|
||||
int32_t toffset = pCol->offset + TD_DATA_ROW_HEAD_SIZE;
|
||||
char * ptr = dataRowAt(row, dataRowLen(row));
|
||||
int tdAppendColVal(SDataRow row, void *value, int8_t type, int32_t bytes, int32_t offset) {
|
||||
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
|
||||
char * ptr = dataRowAt(row, dataRowLen(row));
|
||||
|
||||
switch (colType(pCol)) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
if (value == NULL) {
|
||||
*(int32_t *)dataRowAt(row, toffset) = -1;
|
||||
} else {
|
||||
int16_t slen = (colType(pCol) == TSDB_DATA_TYPE_BINARY) ? strlen((char *)value)
|
||||
: wcslen((wchar_t *)value) * TSDB_NCHAR_SIZE;
|
||||
if (slen > colBytes(pCol)) return -1;
|
||||
int16_t slen = (type) ? strlen((char *)value) : wcslen((wchar_t *)value) * TSDB_NCHAR_SIZE;
|
||||
if (slen > bytes) return -1;
|
||||
|
||||
*(int32_t *)dataRowAt(row, toffset) = dataRowLen(row);
|
||||
*(int16_t *)ptr = slen;
|
||||
|
@ -186,9 +186,9 @@ int tdAppendColVal(SDataRow row, void *value, STSchema *pSchema, int col) {
|
|||
break;
|
||||
default:
|
||||
if (value == NULL) {
|
||||
setNull(dataRowAt(row, toffset), colType(pCol), colBytes(pCol));
|
||||
setNull(dataRowAt(row, toffset), type, bytes);
|
||||
} else {
|
||||
memcpy(dataRowAt(row, toffset), value, TYPE_BYTES[colType(pCol)]);
|
||||
memcpy(dataRowAt(row, toffset), value, TYPE_BYTES[type]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -52,11 +52,12 @@ static int insertData(SInsertInfo *pInfo) {
|
|||
tdInitDataRow(row, pInfo->pSchema);
|
||||
|
||||
for (int j = 0; j < schemaNCols(pInfo->pSchema); j++) {
|
||||
STColumn *pTCol = schemaColAt(pInfo->pSchema, j);
|
||||
if (j == 0) { // Just for timestamp
|
||||
tdAppendColVal(row, (void *)(&start_time), pInfo->pSchema, j);
|
||||
tdAppendColVal(row, (void *)(&start_time), pTCol->type, pTCol->bytes, pTCol->offset);
|
||||
} else { // For int
|
||||
int val = 10;
|
||||
tdAppendColVal(row, (void *)(&val), pInfo->pSchema, j);
|
||||
tdAppendColVal(row, (void *)(&val), pTCol->type, pTCol->bytes, pTCol->offset);
|
||||
}
|
||||
}
|
||||
pBlock->len += dataRowLen(row);
|
||||
|
|
|
@ -141,7 +141,8 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
|
|||
SDataRow dataRow = tdNewDataRowFromSchema(pDestTagSchema);
|
||||
|
||||
for (int i = 0; i < numOfTags; i++) {
|
||||
tdAppendColVal(dataRow, pTagData + accumBytes, pDestTagSchema, i);
|
||||
STColumn *pTCol = schemaColAt(pDestSchema, i);
|
||||
tdAppendColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->offset);
|
||||
accumBytes += htons(pSchema[i + numOfColumns].bytes);
|
||||
}
|
||||
tsdbTableSetTagValue(&tCfg, dataRow, false);
|
||||
|
@ -204,7 +205,8 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
|
|||
SDataRow dataRow = tdNewDataRowFromSchema(pDestTagSchema);
|
||||
|
||||
for (int i = 0; i < numOfTags; i++) {
|
||||
tdAppendColVal(dataRow, pTagData + accumBytes, pDestTagSchema, i);
|
||||
STColumn *pTCol = schemaColAt(pDestTagSchema, i);
|
||||
tdAppendColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->offset);
|
||||
accumBytes += htons(pSchema[i + numOfColumns].bytes);
|
||||
}
|
||||
tsdbTableSetTagValue(&tCfg, dataRow, false);
|
||||
|
|
Loading…
Reference in New Issue