提交 61e21ebf 编写于 作者: H Hongze Cheng

feat: tag refact

上级 65bdd340
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "os.h" #include "os.h"
#include "talgo.h" #include "talgo.h"
#include "tarray.h"
#include "tencode.h" #include "tencode.h"
#include "ttypes.h" #include "ttypes.h"
#include "tutil.h" #include "tutil.h"
...@@ -64,7 +65,7 @@ void tTagFree(STag *pTag); ...@@ -64,7 +65,7 @@ void tTagFree(STag *pTag);
void tTagGet(STag *pTag, STagVal *pTagVal); void tTagGet(STag *pTag, STagVal *pTagVal);
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(STag *pTag, STagVal **ppTagVals, int16_t *nTag); int32_t tTagToValArray(STag *pTag, SArray **ppArray);
// STRUCT ================= // STRUCT =================
struct STColumn { struct STColumn {
......
...@@ -671,19 +671,20 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) { ...@@ -671,19 +671,20 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) {
int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDecoder, (uint8_t **)ppTag, NULL); } int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDecoder, (uint8_t **)ppTag, NULL); }
int32_t tTagToValArray(STag *pTag, STagVal **ppTagVals, int16_t *nTag) { int32_t tTagToValArray(STag *pTag, SArray **ppArray) {
int32_t code = 0; int32_t code = 0;
uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag]; uint8_t *p = (uint8_t *)&pTag->idx[pTag->nTag];
STagVal tv;
*nTag = pTag->nTag; (*ppArray) = taosArrayInit(pTag->nTag, sizeof(STagVal));
(*ppTagVals) = (STagVal *)taosMemoryMalloc(sizeof(STagVal) * pTag->nTag); if (*ppArray == NULL) {
if (*ppTagVals == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
for (int16_t iTag = 0; iTag < pTag->nTag; iTag++) { for (int16_t iTag = 0; iTag < pTag->nTag; iTag++) {
tGetTagVal(p + pTag->idx[iTag], &(*ppTagVals)[iTag], pTag->isJson); tGetTagVal(p + pTag->idx[iTag], &tv, pTag->isJson);
taosArrayPush(*ppArray, &tv);
} }
return code; return code;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册