提交 8d0798e2 编写于 作者: wmmhello's avatar wmmhello

optimize json length

上级 99347790
......@@ -91,13 +91,10 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY){
bytes -= VARSTR_HEADER_SIZE;
}
else if(pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
else if(pSchema[i].type == TSDB_DATA_TYPE_NCHAR || pSchema[i].type == TSDB_DATA_TYPE_JSON) {
bytes -= VARSTR_HEADER_SIZE;
bytes = bytes / TSDB_NCHAR_SIZE;
}
else if(pSchema[i].type == TSDB_DATA_TYPE_JSON) {
bytes = bytes / TSDB_NCHAR_SIZE;
}
pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 2);
*(int32_t *)(pRes->data + tscFieldInfoGetOffset(pQueryInfo, 2) * totalNumOfRows + pField->bytes * i) = bytes;
......
......@@ -5180,8 +5180,12 @@ void getJsonTagValueElment(STable* data, char* key, int32_t keyLen, char* dst, i
}
int32_t length = 0;
taosMbsToUcs4(varDataVal(out), varDataLen(out), varDataVal(dst), bytes - VARSTR_HEADER_SIZE, &length);
if(!taosMbsToUcs4(varDataVal(out), varDataLen(out), varDataVal(dst), bytes - VARSTR_HEADER_SIZE, &length)){
tscError("getJsonTagValueElment mbstoucs4 error! length:%d", length);
}
varDataSetLen(dst, length);
assert(varDataTLen(dst) <= bytes);
}
void getJsonTagValueAll(void* data, void* dst, int16_t bytes) {
......@@ -5192,9 +5196,11 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) {
}
int32_t length = 0;
taosMbsToUcs4(json, strlen(json), varDataVal(dst), bytes - VARSTR_HEADER_SIZE, &length);
if(!taosMbsToUcs4(json, strlen(json), varDataVal(dst), bytes - VARSTR_HEADER_SIZE, &length)){
tscError("getJsonTagValueAll mbstoucs4 error! length:%d", length);
}
varDataSetLen(dst, length);
assert(length <= bytes);
assert(varDataTLen(dst) <= bytes);
tfree(json);
}
......
......@@ -50,7 +50,7 @@ extern const int32_t TYPE_BYTES[16];
#define DOUBLE_BYTES sizeof(double)
#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
#define JSON_BYTES (TSDB_MAX_TAGS_LEN)
#define JSON_BYTES (TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE)
#define TSDB_KEYSIZE sizeof(TSKEY)
#if LINUX
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册