feat:add new logic for new tag format
This commit is contained in:
parent
f6b700ff45
commit
51b5e35933
|
@ -120,6 +120,7 @@ struct SColVal {
|
|||
uint8_t *pData;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct STagVal {
|
||||
union {
|
||||
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_LARGE ((int8_t)0x20)
|
||||
struct STag {
|
||||
|
|
|
@ -567,14 +567,16 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
|
|||
const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *val) {
|
||||
ASSERT(pEntry->type == TSDB_CHILD_TABLE);
|
||||
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;
|
||||
}
|
||||
if (type == TSDB_DATA_TYPE_JSON){
|
||||
return tag;
|
||||
}else{
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
}
|
|
@ -787,10 +787,16 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
|||
|
||||
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
||||
|
||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
|
||||
pTagData = tagVal.pData;
|
||||
nTagData = (int32_t)tagVal.nData;
|
||||
if(pTagColumn->type != TSDB_DATA_TYPE_JSON){
|
||||
STagVal tagVal = {.cid = pTagColumn->colId};
|
||||
tTagGet((const STag *)pCtbEntry->ctbEntry.pTags, &tagVal);
|
||||
pTagData = tagVal.pData;
|
||||
nTagData = (int32_t)tagVal.nData;
|
||||
}else{
|
||||
//pTagData = pCtbEntry->ctbEntry.pTags;
|
||||
//nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len;
|
||||
}
|
||||
|
||||
|
||||
// update tag index
|
||||
#ifdef USE_INVERTED_INDEX
|
||||
|
|
|
@ -330,6 +330,9 @@ static bool isValidateTag(char* input) {
|
|||
|
||||
int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMsgBuf* pMsgBuf) {
|
||||
int32_t retCode = TSDB_CODE_SUCCESS;
|
||||
cJSON* root = NULL;
|
||||
SHashObj* keyHash = NULL;
|
||||
int32_t size = 0;
|
||||
// set json NULL data
|
||||
if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) {
|
||||
retCode = TSDB_CODE_SUCCESS;
|
||||
|
@ -337,19 +340,19 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
|
|||
}
|
||||
|
||||
// set json real data
|
||||
cJSON* root = cJSON_Parse(json);
|
||||
root = cJSON_Parse(json);
|
||||
if (root == NULL) {
|
||||
retCode = buildSyntaxErrMsg(pMsgBuf, "json parse error", json);
|
||||
goto end;
|
||||
}
|
||||
|
||||
int32_t size = cJSON_GetArraySize(root);
|
||||
size = cJSON_GetArraySize(root);
|
||||
if (!cJSON_IsObject(root)) {
|
||||
retCode = buildSyntaxErrMsg(pMsgBuf, "json error invalide value", json);
|
||||
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++) {
|
||||
cJSON* item = cJSON_GetArrayItem(root, i);
|
||||
if (!item) {
|
||||
|
|
Loading…
Reference in New Issue