refactor: do some internal refactor.
This commit is contained in:
parent
ab624de7bd
commit
200a669542
|
@ -296,13 +296,13 @@ void tFreeSSubmitRsp(SSubmitRsp* pRsp);
|
||||||
#define COL_IDX_ON ((int8_t)0x2)
|
#define COL_IDX_ON ((int8_t)0x2)
|
||||||
#define COL_SET_NULL ((int8_t)0x10)
|
#define COL_SET_NULL ((int8_t)0x10)
|
||||||
#define COL_SET_VAL ((int8_t)0x20)
|
#define COL_SET_VAL ((int8_t)0x20)
|
||||||
typedef struct SSchema {
|
struct SSchema {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int8_t flags;
|
int8_t flags;
|
||||||
col_id_t colId;
|
col_id_t colId;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
char name[TSDB_COL_NAME_LEN];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
} SSchema;
|
};
|
||||||
|
|
||||||
#define COL_IS_SET(FLG) (((FLG) & (COL_SET_VAL | COL_SET_NULL)) != 0)
|
#define COL_IS_SET(FLG) (((FLG) & (COL_SET_VAL | COL_SET_NULL)) != 0)
|
||||||
#define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL)))
|
#define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL)))
|
||||||
|
@ -648,7 +648,7 @@ typedef struct {
|
||||||
};
|
};
|
||||||
bool output; // TODO remove it later
|
bool output; // TODO remove it later
|
||||||
|
|
||||||
int16_t type;
|
int8_t type;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
uint8_t scale;
|
uint8_t scale;
|
||||||
|
|
|
@ -1762,6 +1762,10 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
|
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
|
|
||||||
|
// version:
|
||||||
|
int32_t blockVersion = *(int32_t*)p;
|
||||||
|
p += sizeof(int32_t);
|
||||||
|
|
||||||
int32_t dataLen = *(int32_t*)p;
|
int32_t dataLen = *(int32_t*)p;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
|
||||||
|
@ -1782,7 +1786,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
// check fields
|
// check fields
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int16_t type = *(int16_t*)p;
|
int16_t type = *(int16_t*)p;
|
||||||
p += sizeof(int16_t);
|
p += sizeof(int8_t);
|
||||||
|
|
||||||
int32_t bytes = *(int32_t*)p;
|
int32_t bytes = *(int32_t*)p;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
|
|
@ -676,9 +676,9 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
size_t blockDataGetSerialMetaSize(uint32_t numOfCols) {
|
size_t blockDataGetSerialMetaSize(uint32_t numOfCols) {
|
||||||
// | total length | total rows | total columns | has column seg| block group id | column schema | each column length |
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
||||||
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) +
|
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) +
|
||||||
numOfCols * (sizeof(int16_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t);
|
numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||||
|
@ -1582,7 +1582,7 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
tlen += taosEncodeFixedI16(buf, pColData->info.colId);
|
tlen += taosEncodeFixedI16(buf, pColData->info.colId);
|
||||||
tlen += taosEncodeFixedI16(buf, pColData->info.type);
|
tlen += taosEncodeFixedI8(buf, pColData->info.type);
|
||||||
tlen += taosEncodeFixedI32(buf, pColData->info.bytes);
|
tlen += taosEncodeFixedI32(buf, pColData->info.bytes);
|
||||||
tlen += taosEncodeFixedBool(buf, pColData->hasNull);
|
tlen += taosEncodeFixedBool(buf, pColData->hasNull);
|
||||||
|
|
||||||
|
@ -1614,7 +1614,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) {
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SColumnInfoData data = {0};
|
SColumnInfoData data = {0};
|
||||||
buf = taosDecodeFixedI16(buf, &data.info.colId);
|
buf = taosDecodeFixedI16(buf, &data.info.colId);
|
||||||
buf = taosDecodeFixedI16(buf, &data.info.type);
|
buf = taosDecodeFixedI8(buf, &data.info.type);
|
||||||
buf = taosDecodeFixedI32(buf, &data.info.bytes);
|
buf = taosDecodeFixedI32(buf, &data.info.bytes);
|
||||||
buf = taosDecodeFixedBool(buf, &data.hasNull);
|
buf = taosDecodeFixedBool(buf, &data.hasNull);
|
||||||
|
|
||||||
|
@ -2074,6 +2074,10 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
||||||
|
|
||||||
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) {
|
void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress) {
|
||||||
// todo extract method
|
// todo extract method
|
||||||
|
int32_t* version = (int32_t*)data;
|
||||||
|
*version = 1;
|
||||||
|
data += sizeof(int32_t);
|
||||||
|
|
||||||
int32_t* actualLen = (int32_t*)data;
|
int32_t* actualLen = (int32_t*)data;
|
||||||
data += sizeof(int32_t);
|
data += sizeof(int32_t);
|
||||||
|
|
||||||
|
@ -2085,8 +2089,11 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
|
||||||
*cols = numOfCols;
|
*cols = numOfCols;
|
||||||
data += sizeof(int32_t);
|
data += sizeof(int32_t);
|
||||||
|
|
||||||
int32_t* hasColumnSegment = (int32_t*)data;
|
// flag segment.
|
||||||
*hasColumnSegment = 1;
|
// the inital bit is for column info
|
||||||
|
int32_t* flagSegment = (int32_t*)data;
|
||||||
|
*flagSegment = (1<<31);
|
||||||
|
|
||||||
data += sizeof(int32_t);
|
data += sizeof(int32_t);
|
||||||
|
|
||||||
uint64_t* groupId = (uint64_t*)data;
|
uint64_t* groupId = (uint64_t*)data;
|
||||||
|
@ -2095,8 +2102,8 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
*((int16_t*)data) = pColInfoData->info.type;
|
*((int8_t*)data) = pColInfoData->info.type;
|
||||||
data += sizeof(int16_t);
|
data += sizeof(int8_t);
|
||||||
|
|
||||||
*((int32_t*)data) = pColInfoData->info.bytes;
|
*((int32_t*)data) = pColInfoData->info.bytes;
|
||||||
data += sizeof(int32_t);
|
data += sizeof(int32_t);
|
||||||
|
@ -2145,6 +2152,10 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
|
||||||
const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
const char* pStart = pData;
|
const char* pStart = pData;
|
||||||
|
|
||||||
|
int32_t version = *(int32_t*) pStart;
|
||||||
|
pStart += sizeof(int32_t);
|
||||||
|
ASSERT(version == 1);
|
||||||
|
|
||||||
// total length sizeof(int32_t)
|
// total length sizeof(int32_t)
|
||||||
int32_t dataLen = *(int32_t*)pStart;
|
int32_t dataLen = *(int32_t*)pStart;
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
|
@ -2158,7 +2169,8 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
|
|
||||||
// has column info segment
|
// has column info segment
|
||||||
int32_t hasColumnInfo = *(int32_t*)pStart;
|
int32_t flagSeg = *(int32_t*)pStart;
|
||||||
|
int32_t hasColumnInfo = (flagSeg >> 31);
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
|
|
||||||
// group id sizeof(uint64_t)
|
// group id sizeof(uint64_t)
|
||||||
|
@ -2173,7 +2185,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
pColInfoData->info.type = *(int16_t*)pStart;
|
pColInfoData->info.type = *(int16_t*)pStart;
|
||||||
pStart += sizeof(int16_t);
|
pStart += sizeof(int8_t);
|
||||||
|
|
||||||
pColInfoData->info.bytes = *(int32_t*)pStart;
|
pColInfoData->info.bytes = *(int32_t*)pStart;
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
|
|
|
@ -4071,7 +4071,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
pOperator->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId;
|
|
||||||
|
if (pOperator != NULL) {
|
||||||
|
pOperator->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId;
|
||||||
|
}
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue