Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
097a2b92
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
097a2b92
编写于
12月 15, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opti:modify parse json
上级
ac16bfc4
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
283 addition
and
944 deletion
+283
-944
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+3
-3
source/client/src/clientSml.c
source/client/src/clientSml.c
+1
-2
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+211
-481
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+27
-27
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+1
-1
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+37
-146
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+3
-284
未找到文件。
source/client/inc/clientSml.h
浏览文件 @
097a2b92
...
...
@@ -113,7 +113,7 @@ typedef struct {
int32_t
sTableNameLen
;
char
childTableName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
void
*
key
;
// for openTsdb
telnet
void
*
key
;
// for openTsdb
SArray
*
tags
;
...
...
@@ -177,7 +177,7 @@ typedef struct {
int32_t
lineNum
;
SSmlMsgBuf
msgBuf
;
cJSON
*
root
;
// for parse json
//
cJSON *root; // for parse json
SSmlLineInfo
*
lines
;
// element is SSmlLineInfo
//
...
...
@@ -216,7 +216,7 @@ SSmlSTableMeta* smlBuildSTableMeta(bool isDataFormat);
int32_t
smlSetCTableName
(
SSmlTableInfo
*
oneTable
);
STableMeta
*
smlGetMeta
(
SSmlHandle
*
info
,
const
void
*
measure
,
int32_t
measureLen
);
int32_t
is_same_child_table_telnet
(
const
void
*
a
,
const
void
*
b
);
int
32_t
is_same_child_table_json
(
const
void
*
a
,
const
void
*
b
);
int
64_t
smlParseOpenTsdbTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
);
int32_t
smlClearForRerun
(
SSmlHandle
*
info
);
int32_t
smlParseInfluxString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
...
...
source/client/src/clientSml.c
浏览文件 @
097a2b92
...
...
@@ -1060,7 +1060,6 @@ static void smlDestroyInfo(SSmlHandle *info) {
taosMemoryFree
(
info
->
lines
);
}
cJSON_Delete
(
info
->
root
);
taosMemoryFreeClear
(
info
);
}
...
...
@@ -1125,7 +1124,7 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
}
else
if
(
info
->
protocol
==
TSDB_SML_TELNET_PROTOCOL
){
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
}
else
{
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
->
tags
,
POINTER_BYTES
,
is_same_child_table_json
);
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
}
if
(
tinfo
==
NULL
){
...
...
source/client/src/clientSmlJson.c
浏览文件 @
097a2b92
此差异已折叠。
点击以展开。
source/client/src/clientSmlLine.c
浏览文件 @
097a2b92
...
...
@@ -456,7 +456,7 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
bool
isInQuote
=
false
;
while
(
*
sql
<
sqlEnd
)
{
// parse value
if
(
IS_QUOTE
(
*
sql
))
{
if
(
unlikely
(
IS_QUOTE
(
*
sql
)
))
{
isInQuote
=
!
isInQuote
;
(
*
sql
)
++
;
continue
;
...
...
@@ -513,32 +513,32 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
if
(
isSameMeasure
){
if
(
cnt
>=
taosArrayGetSize
(
preLineKV
))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
preKV
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
cnt
);
if
(
kv
.
type
!=
preKV
->
type
){
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
if
(
unlikely
(
IS_VAR_DATA_TYPE
(
kv
.
type
)
&&
kv
.
length
>
preKV
->
length
)){
preKV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
ASSERT
(
tableMeta
!=
NULL
);
SSmlKv
*
oldKV
=
(
SSmlKv
*
)
taosArrayGet
(
tableMeta
->
cols
,
cnt
);
oldKV
->
length
=
kv
.
length
;
info
->
needModifySchema
=
true
;
}
if
(
unlikely
(
!
IS_SAME_KEY
)){
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
//
if(cnt >= taosArrayGetSize(preLineKV)) {
//
info->dataFormat = false;
//
info->reRun = true;
//
return TSDB_CODE_SUCCESS;
//
}
//
SSmlKv *preKV = (SSmlKv *)taosArrayGet(preLineKV, cnt);
//
if(kv.type != preKV->type){
//
info->dataFormat = false;
//
info->reRun = true;
//
return TSDB_CODE_SUCCESS;
//
}
//
//
if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > preKV->length)){
//
preKV->length = kv.length;
//
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
//
ASSERT(tableMeta != NULL);
//
//
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->cols, cnt);
//
oldKV->length = kv.length;
//
info->needModifySchema = true;
//
}
//
if(unlikely(!IS_SAME_KEY)){
//
info->dataFormat = false;
//
info->reRun = true;
//
return TSDB_CODE_SUCCESS;
//
}
}
else
{
if
(
isSuperKVInit
){
if
(
unlikely
(
cnt
>=
taosArrayGetSize
(
superKV
)))
{
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
097a2b92
...
...
@@ -27,7 +27,7 @@ int32_t is_same_child_table_telnet(const void *a, const void *b){
&&
((
t1
->
tagsLen
==
t2
->
tagsLen
)
&&
memcmp
(
t1
->
tags
,
t2
->
tags
,
t1
->
tagsLen
)
==
0
))
?
0
:
1
;
}
static
int64_t
smlParseOpenTsdbTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
)
{
int64_t
smlParseOpenTsdbTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
)
{
uint8_t
toPrecision
=
info
->
currSTableMeta
?
info
->
currSTableMeta
->
tableInfo
.
precision
:
TSDB_TIME_PRECISION_NANO
;
if
(
unlikely
(
!
data
))
{
...
...
source/client/test/smlTest.cpp
浏览文件 @
097a2b92
...
...
@@ -414,28 +414,28 @@ TEST(testCase, smlParseCols_Test) {
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlGetTimestampLen_Test
)
{
uint8_t
len
=
smlGetTimestampLen
(
0
);
ASSERT_EQ
(
len
,
1
);
len
=
smlGetTimestampLen
(
1
);
ASSERT_EQ
(
len
,
1
);
len
=
smlGetTimestampLen
(
10
);
ASSERT_EQ
(
len
,
2
);
len
=
smlGetTimestampLen
(
390
);
ASSERT_EQ
(
len
,
3
);
len
=
smlGetTimestampLen
(
-
1
);
ASSERT_EQ
(
len
,
1
);
len
=
smlGetTimestampLen
(
-
10
);
ASSERT_EQ
(
len
,
2
);
len
=
smlGetTimestampLen
(
-
390
);
ASSERT_EQ
(
len
,
3
);
}
//
TEST(testCase, smlGetTimestampLen_Test) {
//
uint8_t len = smlGetTimestampLen(0);
//
ASSERT_EQ(len, 1);
//
//
len = smlGetTimestampLen(1);
//
ASSERT_EQ(len, 1);
//
//
len = smlGetTimestampLen(10);
//
ASSERT_EQ(len, 2);
//
//
len = smlGetTimestampLen(390);
//
ASSERT_EQ(len, 3);
//
//
len = smlGetTimestampLen(-1);
//
ASSERT_EQ(len, 1);
//
//
len = smlGetTimestampLen(-10);
//
ASSERT_EQ(len, 2);
//
//
len = smlGetTimestampLen(-390);
//
ASSERT_EQ(len, 3);
//
}
TEST
(
testCase
,
smlParseNumber_Test
)
{
SSmlKv
kv
=
{
0
};
...
...
@@ -487,139 +487,32 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlParseTelnetLine_
json_error
_Test
)
{
TEST
(
testCase
,
smlParseTelnetLine_
diff_json_type2
_Test
)
{
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_JSON_PROTOCOL
;
info
->
dataFormat
=
false
;
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 13468464009999333322222223,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
:
\"
web01
\"
,
\n
"
"
\"
dc
\"
:
\"
lga
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400i,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
:
\"
web01
\"
,
\n
"
"
\"
dc
\"
:
\"
lga
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
groupid
\"
: {
\n
"
"
\"
value
\"
: 2,
\n
"
"
\"
type
\"
:
\"
nchar
\"\n
"
" },
\n
"
"
\"
location
\"
: {
\n
"
"
\"
value
\"
:
\"
北京
\"
,
\n
"
"
\"
type
\"
:
\"
binary
\"\n
"
" },
\n
"
"
\"
id
\"
:
\"
d1001
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
: 1346846400,
\"
value
\"
: 18,
\"
tags
\"
: {
\"
host
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.sdfa
\"
,
\"
timestamp
\"
: 1346846400,
\"
value
\"
:
\"
18
\"
,
\"
tags
\"
: {
\"
host
\"
: 8932}},]"
,
};
int
ret
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]);
i
++
)
{
SSmlLineInfo
elements
=
{
0
};
ret
=
smlParseTelnetString
(
info
,
(
char
*
)
sql
[
i
],
(
char
*
)(
sql
[
i
]
+
strlen
(
sql
[
i
])),
&
elements
);
ASSERT_NE
(
ret
,
0
);
}
char
*
dataPointStart
=
(
char
*
)
sql
[
i
];
char
*
dataPointEnd
=
NULL
;
while
(
1
)
{
dataPointEnd
=
smlJsonGetObj
(
dataPointStart
);
if
(
dataPointEnd
==
NULL
)
break
;
smlDestroyInfo
(
info
)
;
}
SSmlLineInfo
elements
=
{
0
}
;
smlJsonParseObj
(
dataPointStart
,
dataPointEnd
,
&
elements
);
TEST
(
testCase
,
smlParseTelnetLine_diff_json_type1_Test
)
{
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_JSON_PROTOCOL
;
info
->
dataFormat
=
false
;
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
:
\"
lga
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
: 8
\n
"
" }
\n
"
" },
\n
"
"]"
,
};
SArray
*
tags
=
smlJsonParseTags
(
elements
.
tags
,
elements
.
tags
+
elements
.
tagsLen
);
size_t
num
=
taosArrayGetSize
(
tags
);
ASSERT_EQ
(
num
,
1
);
int
ret
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]);
i
++
)
{
SSmlLineInfo
elements
=
{
0
};
ret
=
smlParseTelnetString
(
info
,
(
char
*
)
sql
[
i
],
(
char
*
)(
sql
[
i
]
+
strlen
(
sql
[
i
])),
&
elements
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
break
;
}
ASSERT_NE
(
ret
,
0
);
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlParseTelnetLine_diff_json_type2_Test
)
{
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_JSON_PROTOCOL
;
info
->
dataFormat
=
false
;
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400,
\n
"
"
\"
value
\"
: 18,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
:
\"
lga
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
"[
\n
"
" {
\n
"
"
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\n
"
"
\"
timestamp
\"
: 1346846400,
\n
"
"
\"
value
\"
:
\"
18
\"
,
\n
"
"
\"
tags
\"
: {
\n
"
"
\"
host
\"
:
\"
fff
\"\n
"
" }
\n
"
" },
\n
"
"]"
,
};
int
ret
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]);
i
++
)
{
SSmlLineInfo
elements
=
{
0
};
ret
=
smlParseTelnetString
(
info
,
(
char
*
)
sql
[
i
],
(
char
*
)(
sql
[
i
]
+
strlen
(
sql
[
i
])),
&
elements
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
break
;
taosArrayDestroy
(
tags
);
dataPointStart
=
dataPointEnd
;
}
}
ASSERT_NE
(
ret
,
0
);
smlDestroyInfo
(
info
);
}
...
...
@@ -647,6 +540,4 @@ TEST(testCase, smlParseNumber_performance_Test) {
printf
(
"smlParseNumberOld:%s cost:%"
PRId64
,
str
[
i
],
taosGetTimestampUs
()
-
t2
);
printf
(
"
\n\n
"
);
}
}
\ No newline at end of file
utils/test/c/sml_test.c
浏览文件 @
097a2b92
...
...
@@ -156,28 +156,7 @@ int smlProcess_json3_Test() {
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"{
\"
metric
\"
:
\"
meter_current1
\"
,
\"
timestamp
\"
:{
\"
value
\"
:1662344042,
\"
type
\"
:
\"
s
\"
},
\"
value
\"
:{
\"
value
\"
:10.3,
\"
type
\"
:
\"
i64
\"
},
\"
tags
\"
:{
\"
t1
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
bigint
\"
},
\"
t2
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
int
\"
},
\"
t3
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
i16
\"
},
\"
t4
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
i8
\"
},
\"
t5
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
f32
\"
},
\"
t6
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
double
\"
},
\"
t7
\"
:{
\"
value
\"
:
\"
8323
\"
,
\"
type
\"
:
\"
binary
\"
},
\"
t8
\"
:{
\"
value
\"
:
\"
北京
\"
,
\"
type
\"
:
\"
nchar
\"
},
\"
t9
\"
:{
\"
value
\"
:true,
\"
type
\"
:
\"
bool
\"
},
\"
id
\"
:
\"
d1001
\"
}}"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
smlProcess_json4_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists sml_db schemaless 1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"{
\"
metric
\"
:
\"
meter_current2
\"
,
\"
timestamp
\"
:{
\"
value
\"
:1662344042000,
\"
type
\"
:
\"
ms
\"
},
\"
value
\"
:
\"
ni
\"
,
\"
tags
\"
:{
\"
t1
\"
:{
\"
value
\"
:20,
\"
type
\"
:
\"
i64
\"
},
\"
t2
\"
:{
\"
value
\"
:25,
\"
type
\"
:
\"
i32
\"
},
\"
t3
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
smallint
\"
},
\"
t4
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
tinyint
\"
},
\"
t5
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
float
\"
},
\"
t6
\"
:{
\"
value
\"
:0.2,
\"
type
\"
:
\"
f64
\"
},
\"
t7
\"
:
\"
nsj
\"
,
\"
t8
\"
:{
\"
value
\"
:
\"
北京
\"
,
\"
type
\"
:
\"
nchar
\"
},
\"
t9
\"
:false,
\"
id
\"
:
\"
d1001
\"
}}"
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:
\"
18
\"
,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -686,52 +665,6 @@ int sml_oom_Test() {
return
code
;
}
int
sml_16368_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists sml_db schemaless 1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
st123456
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639000,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: 1, "
"
\"
tags
\"
: {
\"
t1
\"
: 3,
\"
t2
\"
: {
\"
value
\"
: 4,
\"
type
\"
:
\"
double
\"
},
\"
t3
\"
: {
\"
value
\"
:
\"
t3
\"
,
\"
type
\"
: "
"
\"
binary
\"
}}},"
"{
\"
metric
\"
:
\"
st123456
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833739000,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: 2, "
"
\"
tags
\"
: {
\"
t1
\"
: {
\"
value
\"
: 4,
\"
type
\"
:
\"
double
\"
},
\"
t3
\"
: {
\"
value
\"
:
\"
t4
\"
,
\"
type
\"
:
\"
binary
\"
}, "
"
\"
t2
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
t4
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
}}},"
"{
\"
metric
\"
:
\"
stb_name
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639100,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: 3, "
"
\"
tags
\"
: {
\"
t2
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
t3
\"
: {
\"
value
\"
:
\"
ste
\"
,
\"
type
\"
:
\"
nchar
\"
}}},"
"{
\"
metric
\"
:
\"
stf567890
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639200,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: 4, "
"
\"
tags
\"
: {
\"
t1
\"
: {
\"
value
\"
: 4,
\"
type
\"
:
\"
bigint
\"
},
\"
t3
\"
: {
\"
value
\"
:
\"
t4
\"
,
\"
type
\"
:
\"
binary
\"
}, "
"
\"
t2
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
t4
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
}}},"
"{
\"
metric
\"
:
\"
st123456
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639300,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: "
"{
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
tags
\"
: {
\"
t1
\"
: {
\"
value
\"
: 4,
\"
type
\"
:
\"
double
\"
},
\"
t2
\"
: 5.0, "
"
\"
t3
\"
: {
\"
value
\"
:
\"
t4
\"
,
\"
type
\"
:
\"
binary
\"
}}},"
"{
\"
metric
\"
:
\"
stb_name
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639400,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: "
"{
\"
value
\"
: 6,
\"
type
\"
:
\"
double
\"
},
\"
tags
\"
: {
\"
t2
\"
: 5.0,
\"
t3
\"
: {
\"
value
\"
:
\"
ste2
\"
,
\"
type
\"
: "
"
\"
nchar
\"
}}},"
"{
\"
metric
\"
:
\"
stb_name
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006834639400,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: "
"{
\"
value
\"
: 7,
\"
type
\"
:
\"
double
\"
},
\"
tags
\"
: {
\"
t2
\"
: {
\"
value
\"
: 5.0,
\"
type
\"
:
\"
double
\"
},
\"
t3
\"
: "
"{
\"
value
\"
:
\"
ste2
\"
,
\"
type
\"
:
\"
nchar
\"
}}},"
"{
\"
metric
\"
:
\"
st123456
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833839006,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: "
"{
\"
value
\"
: 8,
\"
type
\"
:
\"
double
\"
},
\"
tags
\"
: {
\"
t1
\"
: {
\"
value
\"
: 4,
\"
type
\"
:
\"
double
\"
},
\"
t3
\"
: "
"{
\"
value
\"
:
\"
t4
\"
,
\"
type
\"
:
\"
binary
\"
},
\"
t2
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
t4
\"
: {
\"
value
\"
: 5, "
"
\"
type
\"
:
\"
double
\"
}}},"
"{
\"
metric
\"
:
\"
st123456
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833939007,
\"
type
\"
:
\"
us
\"
},
\"
value
\"
: "
"{
\"
value
\"
: 9,
\"
type
\"
:
\"
double
\"
},
\"
tags
\"
: {
\"
t1
\"
: 4,
\"
t3
\"
: {
\"
value
\"
:
\"
t4
\"
,
\"
type
\"
:
\"
binary
\"
}, "
"
\"
t2
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
},
\"
t4
\"
: {
\"
value
\"
: 5,
\"
type
\"
:
\"
double
\"
}}}]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
0
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_MICRO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_dup_time_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -771,214 +704,6 @@ int sml_dup_time_Test() {
return
code
;
}
int
sml_16960_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists sml_db schemaless 1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"["
"{"
"
\"
timestamp
\"
:"
""
"{
\"
value
\"
: 1664418955000,
\"
type
\"
:
\"
ms
\"
}"
","
"
\"
value
\"
:"
""
"{
\"
value
\"
: 830525384,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
tags
\"
: {"
"
\"
id
\"
:
\"
stb00_0
\"
,"
"
\"
t0
\"
:"
""
"{
\"
value
\"
: 83972721,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t1
\"
:"
""
"{
\"
value
\"
: 539147525,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t2
\"
:"
""
"{
\"
value
\"
: 618258572,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t3
\"
:"
""
"{
\"
value
\"
: -10536201,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t4
\"
:"
""
"{
\"
value
\"
: 349227409,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t5
\"
:"
""
"{
\"
value
\"
: 249347042,
\"
type
\"
:
\"
int
\"
}"
"},"
"
\"
metric
\"
:
\"
stb0
\"
"
"},"
"{"
"
\"
timestamp
\"
:"
""
"{
\"
value
\"
: 1664418955001,
\"
type
\"
:
\"
ms
\"
}"
","
"
\"
value
\"
:"
""
"{
\"
value
\"
: -588348364,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
tags
\"
: {"
"
\"
id
\"
:
\"
stb00_0
\"
,"
"
\"
t0
\"
:"
""
"{
\"
value
\"
: 83972721,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t1
\"
:"
""
"{
\"
value
\"
: 539147525,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t2
\"
:"
""
"{
\"
value
\"
: 618258572,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t3
\"
:"
""
"{
\"
value
\"
: -10536201,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t4
\"
:"
""
"{
\"
value
\"
: 349227409,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t5
\"
:"
""
"{
\"
value
\"
: 249347042,
\"
type
\"
:
\"
int
\"
}"
"},"
"
\"
metric
\"
:
\"
stb0
\"
"
"},"
"{"
"
\"
timestamp
\"
:"
""
"{
\"
value
\"
: 1664418955002,
\"
type
\"
:
\"
ms
\"
}"
","
"
\"
value
\"
:"
""
"{
\"
value
\"
: -370310823,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
tags
\"
: {"
"
\"
id
\"
:
\"
stb00_0
\"
,"
"
\"
t0
\"
:"
""
"{
\"
value
\"
: 83972721,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t1
\"
:"
""
"{
\"
value
\"
: 539147525,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t2
\"
:"
""
"{
\"
value
\"
: 618258572,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t3
\"
:"
""
"{
\"
value
\"
: -10536201,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t4
\"
:"
""
"{
\"
value
\"
: 349227409,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t5
\"
:"
""
"{
\"
value
\"
: 249347042,
\"
type
\"
:
\"
int
\"
}"
"},"
"
\"
metric
\"
:
\"
stb0
\"
"
"},"
"{"
"
\"
timestamp
\"
:"
""
"{
\"
value
\"
: 1664418955003,
\"
type
\"
:
\"
ms
\"
}"
","
"
\"
value
\"
:"
""
"{
\"
value
\"
: -811250191,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
tags
\"
: {"
"
\"
id
\"
:
\"
stb00_0
\"
,"
"
\"
t0
\"
:"
""
"{
\"
value
\"
: 83972721,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t1
\"
:"
""
"{
\"
value
\"
: 539147525,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t2
\"
:"
""
"{
\"
value
\"
: 618258572,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t3
\"
:"
""
"{
\"
value
\"
: -10536201,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t4
\"
:"
""
"{
\"
value
\"
: 349227409,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t5
\"
:"
""
"{
\"
value
\"
: 249347042,
\"
type
\"
:
\"
int
\"
}"
"},"
"
\"
metric
\"
:
\"
stb0
\"
"
"},"
"{"
"
\"
timestamp
\"
:"
""
"{
\"
value
\"
: 1664418955004,
\"
type
\"
:
\"
ms
\"
}"
","
"
\"
value
\"
:"
""
"{
\"
value
\"
: -330340558,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
tags
\"
: {"
"
\"
id
\"
:
\"
stb00_0
\"
,"
"
\"
t0
\"
:"
""
"{
\"
value
\"
: 83972721,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t1
\"
:"
""
"{
\"
value
\"
: 539147525,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t2
\"
:"
""
"{
\"
value
\"
: 618258572,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t3
\"
:"
""
"{
\"
value
\"
: -10536201,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t4
\"
:"
""
"{
\"
value
\"
: 349227409,
\"
type
\"
:
\"
int
\"
}"
","
"
\"
t5
\"
:"
""
"{
\"
value
\"
: 249347042,
\"
type
\"
:
\"
int
\"
}"
"},"
"
\"
metric
\"
:
\"
stb0
\"
"
"}"
"]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_add_tag_col_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -1211,11 +936,9 @@ int main(int argc, char *argv[]) {
ret
=
smlProcess_json1_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_json2_Test
();
ASSERT
(
!
ret
);
ASSERT
(
ret
);
ret
=
smlProcess_json3_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_json4_Test
();
ASSERT
(
!
ret
);
ASSERT
(
ret
);
ret
=
sml_TD15662_Test
();
ASSERT
(
!
ret
);
ret
=
sml_TD15742_Test
();
...
...
@@ -1224,12 +947,8 @@ int main(int argc, char *argv[]) {
ASSERT
(
!
ret
);
ret
=
sml_oom_Test
();
ASSERT
(
!
ret
);
ret
=
sml_16368_Test
();
ASSERT
(
!
ret
);
ret
=
sml_dup_time_Test
();
ASSERT
(
!
ret
);
ret
=
sml_16960_Test
();
ASSERT
(
!
ret
);
ret
=
sml_add_tag_col_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_18784_Test
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录