Merge branch 'feat/tag_refact' of github.com:taosdata/TDengine into feat/tag_refact
This commit is contained in:
commit
59a6b247c4
|
@ -64,7 +64,7 @@ static FORCE_INLINE void tTagValSet(STagVal *pTagVal, void *key, int8_t type, ui
|
||||||
bool isJson);
|
bool isJson);
|
||||||
|
|
||||||
// STag
|
// 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 tTagFree(STag *pTag);
|
||||||
bool tTagGet(const STag *pTag, STagVal *pTagVal);
|
bool tTagGet(const STag *pTag, STagVal *pTagVal);
|
||||||
int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
|
int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
|
||||||
|
|
|
@ -643,22 +643,23 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
|
||||||
|
|
||||||
return n;
|
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;
|
int32_t code = 0;
|
||||||
uint8_t *p = NULL;
|
uint8_t *p = NULL;
|
||||||
int16_t n = 0;
|
int16_t n = 0;
|
||||||
|
int16_t nTag = taosArrayGetSize(pArray);
|
||||||
int32_t szTag = sizeof(STag) + sizeof(int16_t) * nTag;
|
int32_t szTag = sizeof(STag) + sizeof(int16_t) * nTag;
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
if (isJson) {
|
if (isJson) {
|
||||||
qsort(pTagVals, nTag, sizeof(STagVal), tTagValJsonCmprFn);
|
qsort(pArray->pData, nTag, sizeof(STagVal), tTagValJsonCmprFn);
|
||||||
} else {
|
} else {
|
||||||
qsort(pTagVals, nTag, sizeof(STagVal), tTagValCmprFn);
|
qsort(pArray->pData, nTag, sizeof(STagVal), tTagValCmprFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get size
|
// get size
|
||||||
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
||||||
szTag += tPutTagVal(NULL, &pTagVals[iTag], isJson);
|
szTag += tPutTagVal(NULL, (STagVal *)taosArrayGet(pArray, iTag), isJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -682,7 +683,7 @@ int32_t tTagNew(STagVal *pTagVals, int16_t nTag, int32_t version, int8_t isJson,
|
||||||
n = 0;
|
n = 0;
|
||||||
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
for (int16_t iTag = 0; iTag < nTag; iTag++) {
|
||||||
(*ppTag)->idx[iTag] = n;
|
(*ppTag)->idx[iTag] = n;
|
||||||
n += tPutTagVal(p + n, &pTagVals[iTag], isJson);
|
n += tPutTagVal(p + n, (STagVal *)taosArrayGet(pArray, iTag), isJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrintSTag(*ppTag, __func__, __LINE__);
|
debugPrintSTag(*ppTag, __func__, __LINE__);
|
||||||
|
@ -743,7 +744,7 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
|
||||||
uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag];
|
uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag];
|
||||||
STagVal tv;
|
STagVal tv;
|
||||||
|
|
||||||
(*ppArray) = taosArrayInit(pTag->nTag, sizeof(STagVal));
|
(*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal));
|
||||||
if (*ppArray == NULL) {
|
if (*ppArray == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
Loading…
Reference in New Issue