diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 3f6ff863ba763d99435f4ded9be20cffb68ea4bc..974dfc2264f7e1ec9157912622367e4fde0d17a5 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -60,7 +60,7 @@ int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, u int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow); // STag -int32_t tTagNew(STagVal *pTagVals, int16_t nTag, int32_t version, int8_t isJson, STag **ppTag); +int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag); void tTagFree(STag *pTag); void tTagGet(STag *pTag, STagVal *pTagVal); int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 87b01623e844075bacb13230b9519e7a351174ed..cb92e68ea426c53687e04227a921cc2cc7efafa6 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -579,22 +579,23 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) { return n; } -int32_t tTagNew(STagVal *pTagVals, int16_t nTag, int32_t version, int8_t isJson, STag **ppTag) { +int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) { int32_t code = 0; uint8_t *p = NULL; int16_t n = 0; + int16_t nTag = taosArrayGetSize(pArray); int32_t szTag = sizeof(STag) + sizeof(int16_t) * nTag; // sort if (isJson) { - qsort(pTagVals, nTag, sizeof(STagVal), tTagValJsonCmprFn); + qsort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn); } else { - qsort(pTagVals, nTag, sizeof(STagVal), tTagValCmprFn); + qsort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn); } // get size for (int16_t iTag = 0; iTag < nTag; iTag++) { - szTag += tPutTagVal(NULL, &pTagVals[iTag], isJson); + szTag += tPutTagVal(NULL, (STagVal *)taosArrayGet(pArray, iTag), isJson); } // TODO @@ -618,7 +619,7 @@ int32_t tTagNew(STagVal *pTagVals, int16_t nTag, int32_t version, int8_t isJson, n = 0; for (int16_t iTag = 0; iTag < nTag; iTag++) { (*ppTag)->idx[iTag] = n; - n += tPutTagVal(p + n, &pTagVals[iTag], isJson); + n += tPutTagVal(p + n, (STagVal *)taosArrayGet(pArray, iTag), isJson); } return code;