Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
72e12675
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
72e12675
编写于
12月 08, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify complie parameters
上级
7ba8ef92
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
166 addition
and
171 deletion
+166
-171
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+0
-1
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+0
-7
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+0
-158
src/common/CMakeLists.txt
src/common/CMakeLists.txt
+0
-2
src/inc/tsdb.h
src/inc/tsdb.h
+5
-0
src/tsdb/CMakeLists.txt
src/tsdb/CMakeLists.txt
+0
-1
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+1
-0
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+14
-0
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+146
-2
未找到文件。
src/client/CMakeLists.txt
浏览文件 @
72e12675
...
...
@@ -3,7 +3,6 @@ PROJECT(TDengine)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
jni
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/tsdb/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/zlib-1.2.11/inc
)
...
...
src/client/inc/tscUtil.h
浏览文件 @
72e12675
...
...
@@ -28,8 +28,6 @@ extern "C" {
#include "tscGlobalmerge.h"
#include "tsched.h"
#include "tsclient.h"
#include "tglobal.h"
#include "tsdbMeta.h"
#define UTIL_TABLE_IS_SUPER_TABLE(metaInfo) \
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))
...
...
@@ -397,12 +395,7 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id);
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
);
int
parseJsontoTagData
(
char
*
json
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
);
char
*
parseTagDatatoJson
(
void
*
p
);
void
*
getJsonTagValueElment
(
STable
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
out
,
int16_t
bytes
);
void
getJsonTagValueAll
(
void
*
data
,
void
*
dst
,
int16_t
bytes
);
int8_t
jsonType2DbType
(
double
data
,
int
jsonType
);
void
*
getJsonTagValue
(
STable
*
pTable
,
char
*
key
,
int32_t
keyLen
,
int16_t
*
colId
);
void
getJsonKey
(
SStrToken
*
t0
);
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
);
...
...
src/client/src/tscUtil.c
浏览文件 @
72e12675
...
...
@@ -5418,151 +5418,6 @@ char* cloneCurrentDBName(SSqlObj* pSql) {
return
p
;
}
void
*
getJsonTagValueElment
(
STable
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
dst
,
int16_t
bytes
){
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
jsonKeyMd5
(
key
,
keyLen
,
keyMd5
);
void
*
result
=
getJsonTagValue
(
data
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
,
NULL
);
if
(
result
==
NULL
){
// json key no result
if
(
!
dst
)
return
NULL
;
*
(
char
*
)
dst
=
TSDB_DATA_TYPE_JSON
;
setNull
(
dst
+
CHAR_BYTES
,
TSDB_DATA_TYPE_JSON
,
0
);
return
dst
;
}
char
*
realData
=
POINTER_SHIFT
(
result
,
CHAR_BYTES
);
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_NCHAR
||
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BINARY
)
{
assert
(
varDataTLen
(
realData
)
<
bytes
);
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
varDataTLen
(
realData
));
return
dst
;
}
else
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_DOUBLE
||
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BIGINT
)
{
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
LONG_BYTES
);
return
dst
;
}
else
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
CHAR_BYTES
);
return
dst
;
}
else
{
assert
(
0
);
}
return
result
;
}
void
getJsonTagValueAll
(
void
*
data
,
void
*
dst
,
int16_t
bytes
)
{
char
*
json
=
parseTagDatatoJson
(
data
);
char
*
tagData
=
dst
+
CHAR_BYTES
;
*
(
char
*
)
dst
=
TSDB_DATA_TYPE_JSON
;
if
(
json
==
NULL
){
setNull
(
tagData
,
TSDB_DATA_TYPE_JSON
,
0
);
return
;
}
int32_t
length
=
0
;
if
(
!
taosMbsToUcs4
(
json
,
strlen
(
json
),
varDataVal
(
tagData
),
bytes
-
VARSTR_HEADER_SIZE
-
CHAR_BYTES
,
&
length
)){
tscError
(
"getJsonTagValueAll mbstoucs4 error! length:%d"
,
length
);
}
varDataSetLen
(
tagData
,
length
);
assert
(
varDataTLen
(
tagData
)
<=
bytes
);
tfree
(
json
);
}
char
*
parseTagDatatoJson
(
void
*
p
){
char
*
string
=
NULL
;
cJSON
*
json
=
cJSON_CreateObject
();
if
(
json
==
NULL
)
{
goto
end
;
}
int16_t
nCols
=
kvRowNCols
(
p
);
ASSERT
(
nCols
%
2
==
1
);
char
tagJsonKey
[
TSDB_MAX_JSON_KEY_LEN
+
1
]
=
{
0
};
for
(
int
j
=
0
;
j
<
nCols
;
++
j
)
{
SColIdx
*
pColIdx
=
kvRowColIdxAt
(
p
,
j
);
void
*
val
=
(
kvRowColVal
(
p
,
pColIdx
));
if
(
j
==
0
){
int8_t
jsonPlaceHolder
=
*
(
int8_t
*
)
val
;
ASSERT
(
jsonPlaceHolder
==
TSDB_DATA_JSON_PLACEHOLDER
);
continue
;
}
if
(
j
==
1
){
uint32_t
jsonNULL
=
*
(
uint32_t
*
)(
varDataVal
(
val
));
ASSERT
(
jsonNULL
==
TSDB_DATA_JSON_NULL
);
continue
;
}
if
(
j
==
2
){
if
(
*
(
uint32_t
*
)(
varDataVal
(
val
+
CHAR_BYTES
))
==
TSDB_DATA_JSON_NULL
)
goto
end
;
continue
;
}
if
(
j
%
2
==
1
)
{
// json key encode by binary
ASSERT
(
varDataLen
(
val
)
<=
TSDB_MAX_JSON_KEY_LEN
);
memset
(
tagJsonKey
,
0
,
sizeof
(
tagJsonKey
));
memcpy
(
tagJsonKey
,
varDataVal
(
val
),
varDataLen
(
val
));
}
else
{
// json value
char
tagJsonValue
[
TSDB_MAX_JSON_TAGS_LEN
]
=
{
0
};
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
char
type
=
*
(
char
*
)
val
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
assert
(
*
(
uint32_t
*
)
varDataVal
(
realData
)
==
TSDB_DATA_JSON_null
);
// json null value
assert
(
varDataLen
(
realData
)
==
INT_BYTES
);
cJSON
*
value
=
cJSON_CreateNull
();
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
tagJsonValue
);
if
(
length
<
0
)
{
tscError
(
"charset:%s to %s. val:%s convert json value failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
val
);
goto
end
;
}
cJSON
*
value
=
cJSON_CreateString
(
tagJsonValue
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
){
double
jsonVd
=
*
(
double
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
){
int64_t
jsonVd
=
*
(
int64_t
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BOOL
)
{
char
jsonVd
=
*
(
char
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateBool
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
{
tscError
(
"unsupportted json value"
);
}
}
}
string
=
cJSON_PrintUnformatted
(
json
);
end:
cJSON_Delete
(
json
);
return
string
;
}
int
parseJsontoTagData
(
char
*
json
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
){
// set json NULL data
uint8_t
nullTypeVal
[
CHAR_BYTES
+
VARSTR_HEADER_SIZE
+
INT_BYTES
]
=
{
0
};
...
...
@@ -5699,19 +5554,6 @@ int8_t jsonType2DbType(double data, int jsonType){
return
TSDB_DATA_TYPE_NULL
;
}
void
*
getJsonTagValue
(
STable
*
pTable
,
char
*
key
,
int32_t
keyLen
,
int16_t
*
retColId
){
assert
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
);
STable
*
superTable
=
pTable
->
pSuper
;
SArray
**
data
=
(
SArray
**
)
taosHashGet
(
superTable
->
jsonKeyMap
,
key
,
keyLen
);
if
(
data
==
NULL
)
return
NULL
;
JsonMapValue
jmvalue
=
{
pTable
,
0
};
JsonMapValue
*
p
=
taosArraySearch
(
*
data
,
&
jmvalue
,
tsdbCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
return
NULL
;
int16_t
colId
=
p
->
colId
+
1
;
if
(
retColId
)
*
retColId
=
p
->
colId
;
return
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
colId
);
}
// get key from json->'key'
void
getJsonKey
(
SStrToken
*
t0
){
while
(
true
){
...
...
src/common/CMakeLists.txt
浏览文件 @
72e12675
...
...
@@ -2,8 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
common
${
SRC
}
)
...
...
src/inc/tsdb.h
浏览文件 @
72e12675
...
...
@@ -421,6 +421,11 @@ bool tsdbNoProblem(STsdbRepo* pRepo);
// unit of walSize: MB
int
tsdbCheckWal
(
STsdbRepo
*
pRepo
,
uint32_t
walSize
);
// for json tag
void
*
getJsonTagValueElment
(
void
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
out
,
int16_t
bytes
);
void
getJsonTagValueAll
(
void
*
data
,
void
*
dst
,
int16_t
bytes
);
char
*
parseTagDatatoJson
(
void
*
p
);
#ifdef __cplusplus
}
#endif
...
...
src/tsdb/CMakeLists.txt
浏览文件 @
72e12675
...
...
@@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
tsdb
${
SRC
}
)
...
...
src/tsdb/inc/tsdbMeta.h
浏览文件 @
72e12675
...
...
@@ -99,6 +99,7 @@ int tsdbUpdateLastColSchema(STable *pTable, STSchema *pNewSchema);
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
);
void
tsdbFreeLastColumns
(
STable
*
pTable
);
int
tsdbCompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
);
void
*
tsdbGetJsonTagValue
(
STable
*
pTable
,
char
*
key
,
int32_t
keyLen
,
int16_t
*
colId
);
static
FORCE_INLINE
int
tsdbCompareSchemaVersion
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
int16_t
*
)
key1
<
schemaVersion
(
*
(
STSchema
**
)
key2
))
{
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
72e12675
...
...
@@ -1071,6 +1071,19 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
tsdbUnRefTable
(
pTable
);
}
void
*
tsdbGetJsonTagValue
(
STable
*
pTable
,
char
*
key
,
int32_t
keyLen
,
int16_t
*
retColId
){
assert
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
);
STable
*
superTable
=
pTable
->
pSuper
;
SArray
**
data
=
(
SArray
**
)
taosHashGet
(
superTable
->
jsonKeyMap
,
key
,
keyLen
);
if
(
data
==
NULL
)
return
NULL
;
JsonMapValue
jmvalue
=
{
pTable
,
0
};
JsonMapValue
*
p
=
taosArraySearch
(
*
data
,
&
jmvalue
,
tsdbCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
return
NULL
;
int16_t
colId
=
p
->
colId
+
1
;
if
(
retColId
)
*
retColId
=
p
->
colId
;
return
tdGetKVRowValOfCol
(
pTable
->
tagVal
,
colId
);
}
int
tsdbCompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
)
{
const
JsonMapValue
*
x
=
(
const
JsonMapValue
*
)
a
;
const
JsonMapValue
*
y
=
(
const
JsonMapValue
*
)
b
;
...
...
@@ -1670,3 +1683,4 @@ static void tsdbFreeTableSchema(STable *pTable) {
taosArrayDestroy
(
pTable
->
schema
);
}
}
src/tsdb/src/tsdbRead.c
浏览文件 @
72e12675
...
...
@@ -26,7 +26,7 @@
#include "tsdbint.h"
#include "texpr.h"
#include "qFilter.h"
#include "
tscUtil
.h"
#include "
cJSON
.h"
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
...
@@ -4047,7 +4047,7 @@ static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, ch
if
(
id
==
TSDB_TBNAME_COLUMN_INDEX
)
{
*
data
=
TABLE_NAME
(
pTable
);
}
else
{
void
*
jsonData
=
g
etJsonTagValue
(
pTable
,
name
,
TSDB_MAX_JSON_KEY_MD5_LEN
,
NULL
);
void
*
jsonData
=
tsdbG
etJsonTagValue
(
pTable
,
name
,
TSDB_MAX_JSON_KEY_MD5_LEN
,
NULL
);
// jsonData == NULL for ? operation
// if(jsonData != NULL) jsonData += CHAR_BYTES; // jump type
*
data
=
jsonData
;
...
...
@@ -4148,5 +4148,149 @@ static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo
return
TSDB_CODE_SUCCESS
;
}
void
*
getJsonTagValueElment
(
void
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
dst
,
int16_t
bytes
){
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
jsonKeyMd5
(
key
,
keyLen
,
keyMd5
);
void
*
result
=
tsdbGetJsonTagValue
(
data
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
,
NULL
);
if
(
result
==
NULL
){
// json key no result
if
(
!
dst
)
return
NULL
;
*
(
char
*
)
dst
=
TSDB_DATA_TYPE_JSON
;
setNull
(
dst
+
CHAR_BYTES
,
TSDB_DATA_TYPE_JSON
,
0
);
return
dst
;
}
char
*
realData
=
POINTER_SHIFT
(
result
,
CHAR_BYTES
);
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_NCHAR
||
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BINARY
)
{
assert
(
varDataTLen
(
realData
)
<
bytes
);
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
varDataTLen
(
realData
));
return
dst
;
}
else
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_DOUBLE
||
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BIGINT
)
{
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
LONG_BYTES
);
return
dst
;
}
else
if
(
*
(
char
*
)
result
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
!
dst
)
return
result
;
memcpy
(
dst
,
result
,
CHAR_BYTES
+
CHAR_BYTES
);
return
dst
;
}
else
{
assert
(
0
);
}
return
result
;
}
void
getJsonTagValueAll
(
void
*
data
,
void
*
dst
,
int16_t
bytes
)
{
char
*
json
=
parseTagDatatoJson
(
data
);
char
*
tagData
=
dst
+
CHAR_BYTES
;
*
(
char
*
)
dst
=
TSDB_DATA_TYPE_JSON
;
if
(
json
==
NULL
){
setNull
(
tagData
,
TSDB_DATA_TYPE_JSON
,
0
);
return
;
}
int32_t
length
=
0
;
if
(
!
taosMbsToUcs4
(
json
,
strlen
(
json
),
varDataVal
(
tagData
),
bytes
-
VARSTR_HEADER_SIZE
-
CHAR_BYTES
,
&
length
)){
tsdbError
(
"getJsonTagValueAll mbstoucs4 error! length:%d"
,
length
);
}
varDataSetLen
(
tagData
,
length
);
assert
(
varDataTLen
(
tagData
)
<=
bytes
);
tfree
(
json
);
}
char
*
parseTagDatatoJson
(
void
*
p
){
char
*
string
=
NULL
;
cJSON
*
json
=
cJSON_CreateObject
();
if
(
json
==
NULL
)
{
goto
end
;
}
int16_t
nCols
=
kvRowNCols
(
p
);
ASSERT
(
nCols
%
2
==
1
);
char
tagJsonKey
[
TSDB_MAX_JSON_KEY_LEN
+
1
]
=
{
0
};
for
(
int
j
=
0
;
j
<
nCols
;
++
j
)
{
SColIdx
*
pColIdx
=
kvRowColIdxAt
(
p
,
j
);
void
*
val
=
(
kvRowColVal
(
p
,
pColIdx
));
if
(
j
==
0
){
int8_t
jsonPlaceHolder
=
*
(
int8_t
*
)
val
;
ASSERT
(
jsonPlaceHolder
==
TSDB_DATA_JSON_PLACEHOLDER
);
continue
;
}
if
(
j
==
1
){
uint32_t
jsonNULL
=
*
(
uint32_t
*
)(
varDataVal
(
val
));
ASSERT
(
jsonNULL
==
TSDB_DATA_JSON_NULL
);
continue
;
}
if
(
j
==
2
){
if
(
*
(
uint32_t
*
)(
varDataVal
(
val
+
CHAR_BYTES
))
==
TSDB_DATA_JSON_NULL
)
goto
end
;
continue
;
}
if
(
j
%
2
==
1
)
{
// json key encode by binary
ASSERT
(
varDataLen
(
val
)
<=
TSDB_MAX_JSON_KEY_LEN
);
memset
(
tagJsonKey
,
0
,
sizeof
(
tagJsonKey
));
memcpy
(
tagJsonKey
,
varDataVal
(
val
),
varDataLen
(
val
));
}
else
{
// json value
char
tagJsonValue
[
TSDB_MAX_JSON_TAGS_LEN
]
=
{
0
};
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
char
type
=
*
(
char
*
)
val
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
assert
(
*
(
uint32_t
*
)
varDataVal
(
realData
)
==
TSDB_DATA_JSON_null
);
// json null value
assert
(
varDataLen
(
realData
)
==
INT_BYTES
);
cJSON
*
value
=
cJSON_CreateNull
();
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
tagJsonValue
);
if
(
length
<
0
)
{
tsdbError
(
"charset:%s to %s. val:%s convert json value failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
val
);
goto
end
;
}
cJSON
*
value
=
cJSON_CreateString
(
tagJsonValue
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
){
double
jsonVd
=
*
(
double
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
){
int64_t
jsonVd
=
*
(
int64_t
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BOOL
)
{
char
jsonVd
=
*
(
char
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateBool
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
{
tsdbError
(
"unsupportted json value"
);
}
}
}
string
=
cJSON_PrintUnformatted
(
json
);
end:
cJSON_Delete
(
json
);
return
string
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录