other: code optimization and do more check
This commit is contained in:
parent
feed810a3a
commit
7fceb5a709
|
@ -97,6 +97,7 @@ extern char *qtypeStr[];
|
||||||
|
|
||||||
#undef TD_DEBUG_PRINT_ROW
|
#undef TD_DEBUG_PRINT_ROW
|
||||||
#undef TD_DEBUG_PRINT_TSDB_LOAD_DCOLS
|
#undef TD_DEBUG_PRINT_TSDB_LOAD_DCOLS
|
||||||
|
#undef TD_DEBUG_PRINT_TAG
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,8 @@ char* tTagValToData(const STagVal *pTagVal, bool isJson);
|
||||||
int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
|
int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
|
||||||
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag);
|
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag);
|
||||||
int32_t tTagToValArray(const STag *pTag, SArray **ppArray);
|
int32_t tTagToValArray(const STag *pTag, SArray **ppArray);
|
||||||
void debugPrintSTag(STag *pTag, const char *tag, int32_t ln);
|
void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove
|
||||||
|
void debugCheckTags(STag *pTag); // TODO: remove
|
||||||
|
|
||||||
// STRUCT =================
|
// STRUCT =================
|
||||||
struct STColumn {
|
struct STColumn {
|
||||||
|
|
|
@ -1008,6 +1008,21 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugCheckTags(STag *pTag) {
|
||||||
|
switch (pTag->flags) {
|
||||||
|
case 0x0:
|
||||||
|
case 0x20:
|
||||||
|
case 0x40:
|
||||||
|
case 0x60:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pTag->nTag <= 128 && pTag->nTag >= 0);
|
||||||
|
ASSERT(pTag->ver <= 512 && pTag->ver >= 0); // temp condition for pTag->ver
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tPutTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
|
static int32_t tPutTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
|
@ -1114,9 +1129,11 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) {
|
||||||
}
|
}
|
||||||
n += tPutTagVal(p + n, (STagVal *)taosArrayGet(pArray, iTag), isJson);
|
n += tPutTagVal(p + n, (STagVal *)taosArrayGet(pArray, iTag), isJson);
|
||||||
}
|
}
|
||||||
|
#ifdef TD_DEBUG_PRINT_TAG
|
||||||
debugPrintSTag(*ppTag, __func__, __LINE__);
|
debugPrintSTag(*ppTag, __func__, __LINE__);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
debugCheckTags(*ppTag); // TODO: remove this line after debug
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -1199,8 +1216,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) {
|
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) {
|
||||||
uint32_t len = 0;
|
return tDecodeBinary(pDecoder, (uint8_t **)ppTag, NULL);
|
||||||
return tDecodeBinary(pDecoder, (uint8_t **)ppTag, &len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||||
if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1;
|
||||||
if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1;
|
if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1;
|
||||||
|
debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug
|
||||||
if (tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags) < 0) return -1;
|
if (tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags) < 0) return -1;
|
||||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||||
if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1;
|
||||||
|
@ -62,6 +63,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||||
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
|
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1;
|
||||||
if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO)
|
if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO)
|
||||||
|
debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug
|
||||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||||
if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1;
|
if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1;
|
||||||
if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1;
|
if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1;
|
||||||
|
|
|
@ -327,8 +327,8 @@ void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
colDataAppend(pColInfoData, i, data, (data == NULL));
|
colDataAppend(pColInfoData, i, data, (data == NULL));
|
||||||
}
|
}
|
||||||
if(pColInfoData->info.type != TSDB_DATA_TYPE_JSON && p != NULL &&
|
if (data && (pColInfoData->info.type != TSDB_DATA_TYPE_JSON) && p != NULL &&
|
||||||
IS_VAR_DATA_TYPE(((const STagVal *)p)->type) && data){
|
IS_VAR_DATA_TYPE(((const STagVal*)p)->type)) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue