feat:add new logic for new tag format

This commit is contained in:
wangmm0220 2022-05-31 23:38:21 +08:00
parent f6b700ff45
commit 51b5e35933
4 changed files with 26 additions and 15 deletions

View File

@ -120,6 +120,7 @@ struct SColVal {
uint8_t *pData; uint8_t *pData;
}; };
#pragma pack(push, 1)
struct STagVal { struct STagVal {
union { union {
int16_t cid; int16_t cid;
@ -135,7 +136,6 @@ struct STagVal {
}; };
}; };
#pragma pack(push, 1)
#define TD_TAG_JSON ((int8_t)0x40) // distinguish JSON string and JSON value with the highest bit #define TD_TAG_JSON ((int8_t)0x40) // distinguish JSON string and JSON value with the highest bit
#define TD_TAG_LARGE ((int8_t)0x20) #define TD_TAG_LARGE ((int8_t)0x20)
struct STag { struct STag {

View File

@ -567,14 +567,16 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *val) { const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *val) {
ASSERT(pEntry->type == TSDB_CHILD_TABLE); ASSERT(pEntry->type == TSDB_CHILD_TABLE);
STag *tag = (STag *)pEntry->ctbEntry.pTags; STag *tag = (STag *)pEntry->ctbEntry.pTags;
tTagGet(tag, val); if (type == TSDB_DATA_TYPE_JSON){
if(tag->nTag == 0){
return NULL;
}
return tag;
}
bool find = tTagGet(tag, val);
if(val->type == TSDB_DATA_TYPE_NULL){ if(!find){
return NULL; return NULL;
} }
if (type == TSDB_DATA_TYPE_JSON){ return val;
return tag;
}else{
return val;
}
} }

View File

@ -787,10 +787,16 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0]; pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
STagVal tagVal = {.cid = pTagColumn->colId}; if(pTagColumn->type != TSDB_DATA_TYPE_JSON){
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal); STagVal tagVal = {.cid = pTagColumn->colId};
pTagData = tagVal.pData; tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
nTagData = (int32_t)tagVal.nData; pTagData = tagVal.pData;
nTagData = (int32_t)tagVal.nData;
}else{
//pTagData = pCtbEntry->ctbEntry.pTags;
//nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len;
}
// update tag index // update tag index
#ifdef USE_INVERTED_INDEX #ifdef USE_INVERTED_INDEX

View File

@ -330,6 +330,9 @@ static bool isValidateTag(char* input) {
int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMsgBuf* pMsgBuf) { int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMsgBuf* pMsgBuf) {
int32_t retCode = TSDB_CODE_SUCCESS; int32_t retCode = TSDB_CODE_SUCCESS;
cJSON* root = NULL;
SHashObj* keyHash = NULL;
int32_t size = 0;
// set json NULL data // set json NULL data
if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) { if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) {
retCode = TSDB_CODE_SUCCESS; retCode = TSDB_CODE_SUCCESS;
@ -337,19 +340,19 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
} }
// set json real data // set json real data
cJSON* root = cJSON_Parse(json); root = cJSON_Parse(json);
if (root == NULL) { if (root == NULL) {
retCode = buildSyntaxErrMsg(pMsgBuf, "json parse error", json); retCode = buildSyntaxErrMsg(pMsgBuf, "json parse error", json);
goto end; goto end;
} }
int32_t size = cJSON_GetArraySize(root); size = cJSON_GetArraySize(root);
if (!cJSON_IsObject(root)) { if (!cJSON_IsObject(root)) {
retCode = buildSyntaxErrMsg(pMsgBuf, "json error invalide value", json); retCode = buildSyntaxErrMsg(pMsgBuf, "json error invalide value", json);
goto end; goto end;
} }
SHashObj* keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false);
for (int32_t i = 0; i < size; i++) { for (int32_t i = 0; i < size; i++) {
cJSON* item = cJSON_GetArrayItem(root, i); cJSON* item = cJSON_GetArrayItem(root, i);
if (!item) { if (!item) {