Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0260512d
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看板
未验证
提交
0260512d
编写于
1月 03, 2023
作者:
wmmhello
提交者:
GitHub
1月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19335 from taosdata/refact/submit_req_marks
fix:Refact/submit req marks
上级
dbd41bff
50d2a1c1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
107 addition
and
27 deletion
+107
-27
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+2
-1
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+2
-2
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+11
-2
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
+3
-3
tests/system-test/2-query/sml.py
tests/system-test/2-query/sml.py
+10
-7
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+79
-12
未找到文件。
source/client/src/clientSmlJson.c
浏览文件 @
0260512d
...
...
@@ -409,7 +409,7 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
(
*
start
)
++
;
}
if
(
unlikely
(
index
!=
OTD_JSON_FIELDS_NUM
))
{
if
(
unlikely
(
index
!=
0
&&
index
!=
OTD_JSON_FIELDS_NUM
))
{
uError
(
"elements != %d"
,
OTD_JSON_FIELDS_NUM
)
return
-
1
;
}
...
...
@@ -1161,6 +1161,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
int32_t
payloadNum
=
1
<<
15
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
uDebug
(
"SML:0x%"
PRIx64
"json:%s"
,
info
->
id
,
payload
);
int
cnt
=
0
;
char
*
dataPointStart
=
payload
;
while
(
1
)
{
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
0260512d
...
...
@@ -23,8 +23,8 @@
int32_t
is_same_child_table_telnet
(
const
void
*
a
,
const
void
*
b
){
SSmlLineInfo
*
t1
=
(
SSmlLineInfo
*
)
a
;
SSmlLineInfo
*
t2
=
(
SSmlLineInfo
*
)
b
;
uError
(
"is_same_child_table_telnet len:%d,%d %s,%s @@@ len:%d,%d %s,%s"
,
t1
->
measureLen
,
t2
->
measureLen
,
t1
->
measure
,
t2
->
measure
,
t1
->
tagsLen
,
t2
->
tagsLen
,
t1
->
tags
,
t2
->
tags
);
//
uError("is_same_child_table_telnet len:%d,%d %s,%s @@@ len:%d,%d %s,%s", t1->measureLen, t2->measureLen,
//
t1->measure, t2->measure, t1->tagsLen, t2->tagsLen, t1->tags, t2->tags);
if
(
t1
==
NULL
||
t2
==
NULL
||
t1
->
measure
==
NULL
||
t2
->
measure
==
NULL
||
t1
->
tags
==
NULL
||
t2
->
tags
==
NULL
)
return
1
;
...
...
source/libs/parser/src/parInsertSml.c
浏览文件 @
0260512d
...
...
@@ -189,14 +189,23 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32
SSchema
*
pColSchema
=
schema
+
index
;
SColVal
*
pVal
=
taosArrayGet
(
pTableCxt
->
pValues
,
index
);
SSmlKv
*
kv
=
(
SSmlKv
*
)
data
;
if
(
kv
->
keyLen
!=
strlen
(
pColSchema
->
name
)
||
memcmp
(
kv
->
key
,
pColSchema
->
name
,
kv
->
keyLen
)
!=
0
){
ret
=
TSDB_CODE_SML_INVALID_DATA
;
goto
end
;
}
if
(
kv
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
len
=
0
;
char
*
pUcs4
=
taosMemoryCalloc
(
1
,
pColSchema
->
bytes
-
VARSTR_HEADER_SIZE
);
int64_t
size
=
pColSchema
->
bytes
-
VARSTR_HEADER_SIZE
;
if
(
size
<=
0
){
ret
=
TSDB_CODE_SML_INVALID_DATA
;
goto
end
;
}
char
*
pUcs4
=
taosMemoryCalloc
(
1
,
size
);
if
(
NULL
==
pUcs4
)
{
ret
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
if
(
!
taosMbsToUcs4
(
kv
->
value
,
kv
->
length
,
(
TdUcs4
*
)
pUcs4
,
pColSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
len
))
{
if
(
!
taosMbsToUcs4
(
kv
->
value
,
kv
->
length
,
(
TdUcs4
*
)
pUcs4
,
size
,
&
len
))
{
if
(
errno
==
E2BIG
)
{
ret
=
TSDB_CODE_PAR_VALUE_TOO_LONG
;
goto
end
;
...
...
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
浏览文件 @
0260512d
...
...
@@ -1432,9 +1432,9 @@ class TDTestCase:
self
.
_conn
.
schemaless_insert
([
json
.
dumps
(
input_json
)],
TDSmlProtocolType
.
JSON
.
value
,
None
)
query_sql
=
'select * from `rFa$sta`'
query_res
=
tdSql
.
query
(
query_sql
,
True
)
tdSql
.
checkEqual
(
query_res
,
[(
datetime
.
datetime
(
2021
,
7
,
11
,
20
,
33
,
54
),
True
,
'rFas$ta_1'
,
'ncharTagValue'
,
2147483647
,
9223372036854775807
,
22.123456789
,
'binaryTagValue'
,
32767
,
11.12345027923584
,
False
,
127
)])
tdSql
.
checkEqual
(
query_res
,
[(
datetime
.
datetime
(
2021
,
7
,
11
,
20
,
33
,
54
),
True
,
False
,
127
,
32767
,
2147483647
,
9223372036854775807
,
11.12345027923584
,
22.123456789
,
'binaryTagValue'
,
'ncharTagValue'
,
'rFas$ta_1'
)])
col_tag_res
=
tdSql
.
getColNameList
(
query_sql
)
tdSql
.
checkEqual
(
col_tag_res
,
[
'_ts'
,
'_value'
,
'
id'
,
't!@#$%^&*()_+[];:<>?,9'
,
't$3'
,
't%4'
,
't&6'
,
't*7'
,
't@2'
,
't^5'
,
'Tt!0'
,
'tT@1
'
])
tdSql
.
checkEqual
(
col_tag_res
,
[
'_ts'
,
'_value'
,
'
Tt!0'
,
'tT@1'
,
't@2'
,
't$3'
,
't%4'
,
't^5'
,
't&6'
,
't*7'
,
't!@#$%^&*()_+[];:<>?,9'
,
'id
'
])
tdSql
.
execute
(
'drop table `rFa$sta`'
)
def
pointTransCheckCase
(
self
,
value_type
=
"obj"
):
...
...
@@ -1758,7 +1758,7 @@ class TDTestCase:
self
.
batchErrorInsertCheckCase
()
self
.
chineseCheckCase
()
# self.spellCheckCase()
#
self.tbnameTagsColsNameCheckCase()
self
.
tbnameTagsColsNameCheckCase
()
# # MultiThreads
# self.sStbStbDdataInsertMultiThreadCheckCase()
# self.sStbStbDdataAtInsertMultiThreadCheckCase()
...
...
tests/system-test/2-query/sml.py
浏览文件 @
0260512d
...
...
@@ -71,23 +71,26 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
2
,
"web01"
)
tdSql
.
query
(
f
"select distinct tbname from
{
dbname
}
.`sys.cpu.nice`"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.`sys.cpu.nice` order by _ts"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
.000000000
)
tdSql
.
checkData
(
0
,
2
,
"web0
2
"
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
1
,
13
.000000000
)
tdSql
.
checkData
(
0
,
2
,
"web0
1
"
)
tdSql
.
checkData
(
0
,
3
,
None
)
tdSql
.
checkData
(
0
,
4
,
"lga"
)
tdSql
.
checkData
(
1
,
1
,
18
.000000000
)
tdSql
.
checkData
(
1
,
2
,
"web0
1
"
)
tdSql
.
checkData
(
1
,
3
,
"t1"
)
tdSql
.
checkData
(
1
,
1
,
9
.000000000
)
tdSql
.
checkData
(
1
,
2
,
"web0
2
"
)
tdSql
.
checkData
(
3
,
3
,
"t1"
)
tdSql
.
checkData
(
0
,
4
,
"lga"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.macylr"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.qelhxo"
)
tdSql
.
checkRows
(
5
)
tdSql
.
query
(
f
"desc
{
dbname
}
.macylr"
)
tdSql
.
checkRows
(
25
)
return
...
...
utils/test/c/sml_test.c
浏览文件 @
0260512d
...
...
@@ -114,13 +114,53 @@ int smlProcess_json1_Test() {
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:18,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:166234404
2
,
\"
value
\"
:9,
\"
tags
\"
:{
\"
host
\"
:
\"
web02
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:18,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:166234404
5
,
\"
value
\"
:9,
\"
tags
\"
:{
\"
host
\"
:
\"
web02
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
){
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
}
else
{
printf
(
"%s result:success
\n
"
,
__FUNCTION__
);
}
taos_free_result
(
pRes
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
const
char
*
sql2
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:1662344041,
\"
value
\"
:13,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
dc
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:1662344042,
\"
value
\"
:9,
\"
tags
\"
:{
\"
host
\"
:
\"
web02
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
,
};
char
*
sql3
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql3
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql3
[
i
],
sql2
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql3
,
sizeof
(
sql3
)
/
sizeof
(
sql3
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
){
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
}
else
{
printf
(
"%s result:success
\n
"
,
__FUNCTION__
);
}
taos_free_result
(
pRes
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql3
[
i
]);
}
taos_close
(
taos
);
return
code
;
...
...
@@ -138,13 +178,26 @@ int smlProcess_json2_Test() {
const
char
*
sql
[]
=
{
"{
\"
metric
\"
:
\"
meter_current0
\"
,
\"
timestamp
\"
:{
\"
value
\"
:1662344042,
\"
type
\"
:
\"
s
\"
},
\"
value
\"
:{
\"
value
\"
:10.3,
\"
type
\"
:
\"
i64
\"
},
\"
tags
\"
:{
\"
groupid
\"
:{
\"
value
\"
:2,
\"
type
\"
:
\"
bigint
\"
},
\"
location
\"
:{
\"
value
\"
:
\"
北京
\"
,
\"
type
\"
:
\"
binary
\"
},
\"
id
\"
:
\"
d1001
\"
}}"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
){
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
}
else
{
printf
(
"%s result:success
\n
"
,
__FUNCTION__
);
}
taos_free_result
(
pRes
);
taos_close
(
taos
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
return
code
;
}
...
...
@@ -158,15 +211,29 @@ int smlProcess_json3_Test() {
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
:0,
\"
value
\"
:
\"
18
\"
,
\"
tags
\"
:{
\"
host
\"
:
\"
web01
\"
,
\"
id
\"
:
\"
t1
\"
,
\"
dc
\"
:
\"
lga
\"
}}]"
// "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]"
"{
\"
metric
\"
:
\"
dcxnmr
\"
,
\"
timestamp
\"
: {
\"
value
\"
: 1626006833639000000,
\"
type
\"
:
\"
ns
\"
},
\"
value
\"
: {
\"
value
\"
: false,
\"
type
\"
:
\"
bool
\"
},
\"
tags
\"
: {
\"
t0
\"
: {
\"
value
\"
: false,
\"
type
\"
:
\"
bool
\"
},
\"
t1
\"
: {
\"
value
\"
: 127,
\"
type
\"
:
\"
tinyint
\"
},
\"
t2
\"
: {
\"
value
\"
: 32767,
\"
type
\"
:
\"
smallint
\"
},
\"
t3
\"
: {
\"
value
\"
: 2147483647,
\"
type
\"
:
\"
int
\"
},
\"
t4
\"
: {
\"
value
\"
: 9223372036854775807,
\"
type
\"
:
\"
bigint
\"
},
\"
t5
\"
: {
\"
value
\"
: 11.12345027923584,
\"
type
\"
:
\"
float
\"
},
\"
t6
\"
: {
\"
value
\"
: 22.123456789,
\"
type
\"
:
\"
double
\"
},
\"
t7
\"
: {
\"
value
\"
:
\"
binaryTagValue
\"
,
\"
type
\"
:
\"
binary
\"
},
\"
t8
\"
: {
\"
value
\"
:
\"
abc{aaa
\"
,
\"
type
\"
:
\"
nchar
\"
}}}"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
char
*
sql1
[
1
]
=
{
0
};
for
(
int
i
=
0
;
i
<
1
;
i
++
){
sql1
[
i
]
=
taosMemoryCalloc
(
1
,
1024
);
strncpy
(
sql1
[
i
],
sql
[
i
],
1023
);
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
){
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
}
else
{
printf
(
"%s result:success
\n
"
,
__FUNCTION__
);
}
taos_free_result
(
pRes
);
taos_close
(
taos
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
taosMemoryFree
(
sql1
[
i
]);
}
return
code
;
}
...
...
@@ -235,7 +302,7 @@ int sml_16384_Test() {
if
(
code
)
return
code
;
const
char
*
sql1
[]
=
{
"qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L
\"
ncharColValue
\"
,c10=t 162600683363
9
000000"
,
"qelhxo,id=pnnqhsa,t0=t,t1=127i8 c0=f,c1=127i8,c11=L
\"
ncharColValue
\"
,c10=t 162600683363
1
000000"
,
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
1
,
TSDB_SML_LINE_PROTOCOL
,
0
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
...
...
@@ -799,7 +866,7 @@ int sml_19221_Test() {
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"qelhxo,id=pnnqhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 162600683363
9000000
\n
qelhxo,id=pnnhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 1626006833639000000
\n
#comment
\n
qelhxo,id=pnqhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 1626006833639
000000"
,
"qelhxo,id=pnnqhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 162600683363
2000000
\n
qelhxo,id=pnnhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 1626006833633000000
\n
#comment
\n
qelhxo,id=pnqhsa,t0=t,t1=127i8 c11=L
\"
ncharColValue
\"
,c0=t,c1=127i8 1626006833634
000000"
,
};
pRes
=
taos_query
(
taos
,
"use sml_db"
);
...
...
@@ -938,9 +1005,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
);
ASSERT
(
!
ret
);
ret
=
sml_TD15662_Test
();
ASSERT
(
!
ret
);
ret
=
sml_TD15742_Test
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录