Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
100001ca
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看板
未验证
提交
100001ca
编写于
1月 03, 2023
作者:
D
dapan1121
提交者:
GitHub
1月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19296 from taosdata/refact/submit_req
opti:json parse logic in schemaless
上级
2313d531
0260512d
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
1151 addition
and
390 deletion
+1151
-390
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+10
-6
source/client/src/clientSml.c
source/client/src/clientSml.c
+18
-7
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+904
-201
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+24
-68
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+20
-12
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+51
-51
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+11
-2
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+4
-4
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
+3
-4
tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
...system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
+6
-7
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
+90
-21
未找到文件。
source/client/inc/clientSml.h
浏览文件 @
100001ca
...
...
@@ -69,6 +69,7 @@ extern "C" {
#define VALUE "_value"
#define VALUE_LEN 6
#define OTD_JSON_FIELDS_NUM 4
#define MAX_RETRY_TIMES 5
typedef
TSDB_SML_PROTOCOL_TYPE
SMLProtocolType
;
...
...
@@ -177,12 +178,14 @@ typedef struct {
int32_t
lineNum
;
SSmlMsgBuf
msgBuf
;
//
cJSON *root; // for parse json
int8_t
offset
[
4
];
cJSON
*
root
;
// for parse json
int8_t
offset
[
OTD_JSON_FIELDS_NUM
];
SSmlLineInfo
*
lines
;
// element is SSmlLineInfo
bool
parseJsonByLib
;
//
SArray
*
preLineTagKV
;
SArray
*
maxTagKVs
;
SArray
*
preLineColKV
;
SSmlLineInfo
preLine
;
...
...
@@ -197,7 +200,7 @@ typedef struct {
#define IS_SAME_SUPER_TABLE (elements->measureLen == info->preLine.measureLen \
&& memcmp(elements->measure, info->preLine.measure, elements->measureLen) == 0)
#define IS_SAME_KEY (
preKV->keyLen == kv.keyLen && memcmp(pre
KV->key, kv.key, kv.keyLen) == 0)
#define IS_SAME_KEY (
maxKV->keyLen == kv.keyLen && memcmp(max
KV->key, kv.key, kv.keyLen) == 0)
extern
int64_t
smlFactorNS
[
3
];
extern
int64_t
smlFactorS
[
3
];
...
...
@@ -206,9 +209,9 @@ typedef int32_t (*_equal_fn_sml)(const void *, const void *);
SSmlHandle
*
smlBuildSmlInfo
(
TAOS
*
taos
);
void
smlDestroyInfo
(
SSmlHandle
*
info
);
void
smlJsonParseObjFirst
(
char
**
start
,
SSmlLineInfo
*
element
,
int8_t
*
offset
);
void
smlJsonParseObj
(
char
**
start
,
SSmlLineInfo
*
element
,
int8_t
*
offset
);
SArray
*
smlJsonParseTags
(
char
*
start
,
char
*
end
);
int
smlJsonParseObjFirst
(
char
**
start
,
SSmlLineInfo
*
element
,
int8_t
*
offset
);
int
smlJsonParseObj
(
char
**
start
,
SSmlLineInfo
*
element
,
int8_t
*
offset
);
//
SArray *smlJsonParseTags(char *start, char *end);
bool
smlParseNumberOld
(
SSmlKv
*
kvVal
,
SSmlMsgBuf
*
msg
);
void
*
nodeListGet
(
NodeList
*
list
,
const
void
*
key
,
int32_t
len
,
_equal_fn_sml
fn
);
int
nodeListSet
(
NodeList
**
list
,
const
void
*
key
,
int32_t
len
,
void
*
value
,
_equal_fn_sml
fn
);
...
...
@@ -226,6 +229,7 @@ int32_t is_same_child_table_telnet(const void *a, const void *b);
int64_t
smlParseOpenTsdbTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
);
int32_t
smlClearForRerun
(
SSmlHandle
*
info
);
int32_t
smlParseValue
(
SSmlKv
*
pVal
,
SSmlMsgBuf
*
msg
);
uint8_t
smlGetTimestampLen
(
int64_t
num
);
int32_t
smlParseInfluxString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
int32_t
smlParseTelnetString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
...
...
source/client/src/clientSml.c
浏览文件 @
100001ca
...
...
@@ -1008,12 +1008,16 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
return
TSDB_CODE_SUCCESS
;
}
static
void
smlDestroyTableInfo
(
SSmlTableInfo
*
tag
)
{
static
void
smlDestroyTableInfo
(
SSml
Handle
*
info
,
SSml
TableInfo
*
tag
)
{
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
tag
->
cols
);
i
++
)
{
SHashObj
*
kvHash
=
(
SHashObj
*
)
taosArrayGetP
(
tag
->
cols
,
i
);
taosHashCleanup
(
kvHash
);
}
if
(
info
->
parseJsonByLib
){
SSmlLineInfo
*
key
=
(
SSmlLineInfo
*
)(
tag
->
key
);
if
(
key
!=
NULL
)
taosMemoryFree
(
key
->
tags
);
}
taosMemoryFree
(
tag
->
key
);
taosArrayDestroy
(
tag
->
cols
);
taosArrayDestroy
(
tag
->
tags
);
...
...
@@ -1028,7 +1032,7 @@ void smlDestroyInfo(SSmlHandle *info) {
NodeList
*
tmp
=
info
->
childTables
;
while
(
tmp
)
{
if
(
tmp
->
data
.
used
)
{
smlDestroyTableInfo
((
SSmlTableInfo
*
)
tmp
->
data
.
value
);
smlDestroyTableInfo
(
info
,
(
SSmlTableInfo
*
)
tmp
->
data
.
value
);
}
NodeList
*
t
=
tmp
->
next
;
taosMemoryFree
(
tmp
);
...
...
@@ -1050,11 +1054,15 @@ void smlDestroyInfo(SSmlHandle *info) {
taosHashCleanup
(
info
->
pVgHash
);
taosArrayDestroy
(
info
->
preLineTagKV
);
taosArrayDestroy
(
info
->
maxTagKVs
);
taosArrayDestroy
(
info
->
preLineColKV
);
if
(
!
info
->
dataFormat
)
{
for
(
int
i
=
0
;
i
<
info
->
lineNum
;
i
++
)
{
taosArrayDestroy
(
info
->
lines
[
i
].
colArray
);
if
(
info
->
parseJsonByLib
){
taosMemoryFree
(
info
->
lines
[
i
].
tags
);
}
}
taosMemoryFree
(
info
->
lines
);
}
...
...
@@ -1083,6 +1091,7 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
info
->
dataFormat
=
true
;
info
->
preLineTagKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
info
->
maxTagKVs
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
info
->
preLineColKV
=
taosArrayInit
(
8
,
sizeof
(
SSmlKv
));
if
(
NULL
==
info
->
pVgHash
)
{
...
...
@@ -1251,7 +1260,7 @@ int32_t smlClearForRerun(SSmlHandle *info) {
NodeList
*
pList
=
info
->
childTables
;
while
(
pList
)
{
if
(
pList
->
data
.
used
)
{
smlDestroyTableInfo
((
SSmlTableInfo
*
)
pList
->
data
.
value
);
smlDestroyTableInfo
(
info
,
(
SSmlTableInfo
*
)
pList
->
data
.
value
);
pList
->
data
.
used
=
false
;
}
pList
=
pList
->
next
;
...
...
@@ -1267,11 +1276,13 @@ int32_t smlClearForRerun(SSmlHandle *info) {
pList
=
pList
->
next
;
}
if
(
unlikely
(
info
->
lines
!=
NULL
))
{
uError
(
"SML:0x%"
PRIx64
" info->lines != NULL"
,
info
->
id
);
return
TSDB_CODE_SML_INVALID_DATA
;
if
(
!
info
->
dataFormat
){
if
(
unlikely
(
info
->
lines
!=
NULL
))
{
uError
(
"SML:0x%"
PRIx64
" info->lines != NULL"
,
info
->
id
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
info
->
lines
=
(
SSmlLineInfo
*
)
taosMemoryCalloc
(
info
->
lineNum
,
sizeof
(
SSmlLineInfo
));
}
info
->
lines
=
(
SSmlLineInfo
*
)
taosMemoryCalloc
(
info
->
lineNum
,
sizeof
(
SSmlLineInfo
));
memset
(
&
info
->
preLine
,
0
,
sizeof
(
SSmlLineInfo
));
info
->
currSTableMeta
=
NULL
;
...
...
source/client/src/clientSmlJson.c
浏览文件 @
100001ca
此差异已折叠。
点击以展开。
source/client/src/clientSmlLine.c
浏览文件 @
100001ca
...
...
@@ -57,52 +57,6 @@ uint8_t smlPrecisionConvert[7] = {TSDB_TIME_PRECISION_NANO, TSDB_TIME_PRECISION_
TSDB_TIME_PRECISION_SECONDS
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_MICRO
,
TSDB_TIME_PRECISION_NANO
};
static
bool
smlParseBool
(
SSmlKv
*
kvVal
)
{
const
char
*
pVal
=
kvVal
->
value
;
int32_t
len
=
kvVal
->
length
;
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
't'
||
pVal
[
0
]
==
'T'
))
{
kvVal
->
i
=
TSDB_TRUE
;
return
true
;
}
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
'f'
||
pVal
[
0
]
==
'F'
))
{
kvVal
->
i
=
TSDB_FALSE
;
return
true
;
}
if
((
len
==
4
)
&&
!
strncasecmp
(
pVal
,
"true"
,
len
))
{
kvVal
->
i
=
TSDB_TRUE
;
return
true
;
}
if
((
len
==
5
)
&&
!
strncasecmp
(
pVal
,
"false"
,
len
))
{
kvVal
->
i
=
TSDB_FALSE
;
return
true
;
}
return
false
;
}
static
bool
smlIsBinary
(
const
char
*
pVal
,
uint16_t
len
)
{
// binary: "abc"
if
(
len
<
2
)
{
return
false
;
}
if
(
pVal
[
0
]
==
'"'
&&
pVal
[
len
-
1
]
==
'"'
)
{
return
true
;
}
return
false
;
}
static
bool
smlIsNchar
(
const
char
*
pVal
,
uint16_t
len
)
{
// nchar: L"abc"
if
(
len
<
3
)
{
return
false
;
}
if
(
pVal
[
1
]
==
'"'
&&
pVal
[
len
-
1
]
==
'"'
&&
(
pVal
[
0
]
==
'l'
||
pVal
[
0
]
==
'L'
))
{
return
true
;
}
return
false
;
}
static
int64_t
smlParseInfluxTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
)
{
uint8_t
toPrecision
=
info
->
currSTableMeta
?
info
->
currSTableMeta
->
tableInfo
.
precision
:
TSDB_TIME_PRECISION_NANO
;
...
...
@@ -189,6 +143,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
int
cnt
=
0
;
SArray
*
preLineKV
=
info
->
preLineTagKV
;
SArray
*
maxKVs
=
info
->
maxTagKVs
;
bool
isSuperKVInit
=
true
;
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
...
...
@@ -212,12 +167,12 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
}
taosArraySetSize
(
preLineKV
,
0
);
taosArraySetSize
(
maxKVs
,
0
);
}
}
else
{
taosArraySetSize
(
preLineKV
,
0
);
taosArraySetSize
(
maxKVs
,
0
);
}
taosArraySetSize
(
preLineKV
,
0
);
while
(
*
sql
<
sqlEnd
)
{
if
(
unlikely
(
IS_SPACE
(
*
sql
)))
{
...
...
@@ -295,14 +250,14 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
if
(
isSameMeasure
){
if
(
unlikely
(
cnt
>=
taosArrayGetSize
(
preLineKV
)))
{
if
(
unlikely
(
cnt
>=
taosArrayGetSize
(
maxKVs
)))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
preKV
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
pre
KV
->
length
)){
pre
KV
->
length
=
kv
.
length
;
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
maxKVs
,
cnt
);
if
(
unlikely
(
kv
.
length
>
max
KV
->
length
)){
max
KV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
ASSERT
(
tableMeta
!=
NULL
);
...
...
@@ -322,11 +277,11 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
pre
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
pre
KV
->
length
))
{
pre
KV
->
length
=
kv
.
length
;
SSmlKv
*
max
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
max
KV
->
length
))
{
max
KV
->
length
=
kv
.
length
;
}
else
{
kv
.
length
=
pre
KV
->
length
;
kv
.
length
=
max
KV
->
length
;
}
info
->
needModifySchema
=
true
;
...
...
@@ -338,11 +293,12 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
else
{
taosArrayPush
(
superKV
,
&
kv
);
}
taosArrayPush
(
preLineKV
,
&
kv
);
taosArrayPush
(
maxKVs
,
&
kv
);
}
}
else
{
taosArrayPush
(
preLineKV
,
&
kv
);
taosArrayPush
(
maxKVs
,
&
kv
);
}
taosArrayPush
(
preLineKV
,
&
kv
);
cnt
++
;
if
(
IS_SPACE
(
*
sql
)){
...
...
@@ -518,15 +474,15 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
pre
KV
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
cnt
);
if
(
kv
.
type
!=
pre
KV
->
type
){
SSmlKv
*
max
KV
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
cnt
);
if
(
kv
.
type
!=
max
KV
->
type
){
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
if
(
unlikely
(
IS_VAR_DATA_TYPE
(
kv
.
type
)
&&
kv
.
length
>
pre
KV
->
length
)){
pre
KV
->
length
=
kv
.
length
;
if
(
unlikely
(
IS_VAR_DATA_TYPE
(
kv
.
type
)
&&
kv
.
length
>
max
KV
->
length
)){
max
KV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
NULL
);
ASSERT
(
tableMeta
!=
NULL
);
...
...
@@ -546,18 +502,18 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
pre
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
type
!=
pre
KV
->
type
)){
SSmlKv
*
max
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
type
!=
max
KV
->
type
)){
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
if
(
IS_VAR_DATA_TYPE
(
kv
.
type
)){
if
(
kv
.
length
>
pre
KV
->
length
)
{
pre
KV
->
length
=
kv
.
length
;
if
(
kv
.
length
>
max
KV
->
length
)
{
max
KV
->
length
=
kv
.
length
;
}
else
{
kv
.
length
=
pre
KV
->
length
;
kv
.
length
=
max
KV
->
length
;
}
info
->
needModifySchema
=
true
;
}
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
100001ca
...
...
@@ -23,6 +23,11 @@
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);
if
(
t1
==
NULL
||
t2
==
NULL
||
t1
->
measure
==
NULL
||
t2
->
measure
==
NULL
||
t1
->
tags
==
NULL
||
t2
->
tags
==
NULL
)
return
1
;
return
(((
t1
->
measureLen
==
t2
->
measureLen
)
&&
memcmp
(
t1
->
measure
,
t2
->
measure
,
t1
->
measureLen
)
==
0
)
&&
((
t1
->
tagsLen
==
t2
->
tagsLen
)
&&
memcmp
(
t1
->
tags
,
t2
->
tags
,
t1
->
tagsLen
)
==
0
))
?
0
:
1
;
}
...
...
@@ -73,6 +78,7 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
int
cnt
=
0
;
SArray
*
preLineKV
=
info
->
preLineTagKV
;
SArray
*
maxKVs
=
info
->
maxTagKVs
;
bool
isSuperKVInit
=
true
;
SArray
*
superKV
=
NULL
;
if
(
info
->
dataFormat
){
...
...
@@ -96,12 +102,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
if
(
unlikely
(
taosArrayGetSize
(
superKV
)
==
0
)){
isSuperKVInit
=
false
;
}
taosArraySetSize
(
preLineKV
,
0
);
taosArraySetSize
(
maxKVs
,
0
);
}
}
else
{
taosArraySetSize
(
preLineKV
,
0
);
taosArraySetSize
(
maxKVs
,
0
);
}
taosArraySetSize
(
preLineKV
,
0
);
const
char
*
sql
=
data
;
while
(
sql
<
sqlEnd
)
{
JUMP_SPACE
(
sql
,
sqlEnd
)
...
...
@@ -168,14 +175,14 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
if
(
isSameMeasure
){
if
(
unlikely
(
cnt
>=
taosArrayGetSize
(
preLineKV
)))
{
if
(
unlikely
(
cnt
>=
taosArrayGetSize
(
maxKVs
)))
{
info
->
dataFormat
=
false
;
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
preKV
=
(
SSmlKv
*
)
taosArrayGet
(
preLineKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
pre
KV
->
length
)){
pre
KV
->
length
=
kv
.
length
;
SSmlKv
*
maxKV
=
(
SSmlKv
*
)
taosArrayGet
(
maxKVs
,
cnt
);
if
(
unlikely
(
kv
.
length
>
max
KV
->
length
)){
max
KV
->
length
=
kv
.
length
;
SSmlSTableMeta
*
tableMeta
=
(
SSmlSTableMeta
*
)
nodeListGet
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
NULL
);
ASSERT
(
tableMeta
!=
NULL
);
...
...
@@ -195,11 +202,11 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
info
->
reRun
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SSmlKv
*
pre
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
pre
KV
->
length
))
{
pre
KV
->
length
=
kv
.
length
;
SSmlKv
*
max
KV
=
(
SSmlKv
*
)
taosArrayGet
(
superKV
,
cnt
);
if
(
unlikely
(
kv
.
length
>
max
KV
->
length
))
{
max
KV
->
length
=
kv
.
length
;
}
else
{
kv
.
length
=
pre
KV
->
length
;
kv
.
length
=
max
KV
->
length
;
}
info
->
needModifySchema
=
true
;
...
...
@@ -211,11 +218,12 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
else
{
taosArrayPush
(
superKV
,
&
kv
);
}
taosArrayPush
(
preLineKV
,
&
kv
);
taosArrayPush
(
maxKVs
,
&
kv
);
}
}
else
{
taosArrayPush
(
preLineKV
,
&
kv
);
taosArrayPush
(
maxKVs
,
&
kv
);
}
taosArrayPush
(
preLineKV
,
&
kv
);
cnt
++
;
}
SSmlTableInfo
*
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
...
...
source/client/test/smlTest.cpp
浏览文件 @
100001ca
...
...
@@ -411,28 +411,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
};
...
...
@@ -503,35 +503,35 @@ TEST(testCase, smlParseTelnetLine_Test) {
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlParseTelnetLine_diff_json_type2_Test
)
{
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_JSON_PROTOCOL
;
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"[{
\"
metric
\"
:
\"
sys.cpu.nice
\"
,
\"
timestamp
\"
: 1346846400,
\"
value
\"
: 18,
\"
tags
\"
: {
\"
host
\"
:
\"
lga
\"
}},{
\"
metric
\"
:
\"
sys.sdfa
\"
,
\"
timestamp
\"
: 1346846400,
\"
value
\"
:
\"
18
\"
,
\"
tags
\"
: {
\"
host
\"
: 8932}},]"
,
};
for
(
int
i
=
0
;
i
<
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]);
i
++
)
{
char
*
dataPointStart
=
(
char
*
)
sql
[
i
];
int8_t
offset
[
4
]
=
{
0
};
while
(
1
)
{
SSmlLineInfo
elements
=
{
0
};
if
(
offset
[
0
]
==
0
){
smlJsonParseObjFirst
(
&
dataPointStart
,
&
elements
,
offset
);
}
else
{
smlJsonParseObj
(
&
dataPointStart
,
&
elements
,
offset
);
}
if
(
*
dataPointStart
==
'\0'
)
break
;
SArray
*
tags
=
smlJsonParseTags
(
elements
.
tags
,
elements
.
tags
+
elements
.
tagsLen
);
size_t
num
=
taosArrayGetSize
(
tags
);
ASSERT_EQ
(
num
,
1
);
taosArrayDestroy
(
tags
);
}
}
smlDestroyInfo
(
info
);
}
//
TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
//
SSmlHandle *info = smlBuildSmlInfo(NULL);
//
info->protocol = TSDB_SML_JSON_PROTOCOL;
//
ASSERT_NE(info, nullptr);
//
//
const char *sql[] = {
//
"[{\"metric\":\"sys.cpu.nice\",\"timestamp\": 1346846400,\"value\": 18,\"tags\": {\"host\": \"lga\"}},{\"metric\": \"sys.sdfa\",\"timestamp\": 1346846400,\"value\": \"18\",\"tags\": {\"host\": 8932}},]",
//
};
//
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
//
char *dataPointStart = (char *)sql[i];
//
int8_t offset[4] = {0};
//
while (1) {
//
SSmlLineInfo elements = {0};
//
if(offset[0] == 0){
//
smlJsonParseObjFirst(&dataPointStart, &elements, offset);
//
}else{
//
smlJsonParseObj(&dataPointStart, &elements, offset);
//
}
//
if(*dataPointStart == '\0') break;
//
//
SArray *tags = smlJsonParseTags(elements.tags, elements.tags + elements.tagsLen);
//
size_t num = taosArrayGetSize(tags);
//
ASSERT_EQ(num, 1);
//
//
taosArrayDestroy(tags);
//
}
//
}
//
smlDestroyInfo(info);
//
}
TEST
(
testCase
,
smlParseNumber_performance_Test
)
{
char
msg
[
256
]
=
{
0
};
...
...
source/libs/parser/src/parInsertSml.c
浏览文件 @
100001ca
...
...
@@ -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/parallel_test/cases.task
浏览文件 @
100001ca
...
...
@@ -423,8 +423,8 @@
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
,,
y
,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
,,
y
,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
,,
n
,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
,,
n
,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_set_tbname_tag.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_stable.py
...
...
@@ -1037,7 +1037,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py
#develop test
#
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/default_json.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py
...
...
@@ -1046,7 +1046,7 @@
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py
#
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R
,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R
...
...
tests/system-test/1-insert/opentsdb_json_taosc_insert.py
浏览文件 @
100001ca
...
...
@@ -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"
):
...
...
@@ -1719,7 +1719,6 @@ class TDTestCase:
print
(
err
.
errno
)
def
runAll
(
self
):
"""
for
value_type
in
[
"obj"
,
"default"
]:
self
.
initCheckCase
(
value_type
)
self
.
symbolsCheckCase
(
value_type
)
...
...
@@ -1772,7 +1771,7 @@ class TDTestCase:
# self.sStbStbDdataDtsMtInsertMultiThreadCheckCase()
# self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase()
# self.lengthIcreaseCrashCheckCase()
"""
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
self
.
createDb
()
...
...
tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py
浏览文件 @
100001ca
...
...
@@ -243,7 +243,7 @@ class TDTestCase:
if
t_add_tag
is
not
None
:
sql_seq
=
f
'
{
stb_name
}
{
ts
}
{
value
}
t0=
{
t0
}
t1=
{
t1
}
t2=
{
t2
}
t3=
{
t3
}
t4=
{
t4
}
t5=
{
t5
}
t6=
{
t6
}
t7=
{
t7
}
t8=
{
t8
}
t9=
{
t8
}
'
if
id_change_tag
is
not
None
:
sql_seq
=
f
'
{
stb_name
}
{
ts
}
{
value
}
t0=
{
t0
}
{
id
}
=
{
tb_name
}
t1=
{
t1
}
t2=
{
t2
}
t3=
{
t3
}
t4=
{
t4
}
t5=
{
t5
}
t6=
{
t6
}
t7=
{
t7
}
t8=
{
t8
}
'
sql_seq
=
f
'
{
stb_name
}
{
ts
}
{
value
}
{
id
}
=
{
tb_name
}
t0=
{
t0
}
t1=
{
t1
}
t2=
{
t2
}
t3=
{
t3
}
t4=
{
t4
}
t5=
{
t5
}
t6=
{
t6
}
t7=
{
t7
}
t8=
{
t8
}
'
if
id_double_tag
is
not
None
:
sql_seq
=
f
'
{
stb_name
}
{
ts
}
{
value
}
{
id
}
=
\"
{
tb_name
}
_1
\"
t0=
{
t0
}
t1=
{
t1
}
{
id
}
=
\"
{
tb_name
}
_2
\"
t2=
{
t2
}
t3=
{
t3
}
t4=
{
t4
}
t5=
{
t5
}
t6=
{
t6
}
t7=
{
t7
}
t8=
{
t8
}
'
if
t_add_tag
is
not
None
:
...
...
@@ -1126,9 +1126,9 @@ class TDTestCase:
self
.
_conn
.
schemaless_insert
([
input_sql
],
TDSmlProtocolType
.
TELNET
.
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
),
9.223372036854776e+18
,
'
2147483647i32'
,
'L"ncharTagValue"'
,
'32767i16'
,
'9223372036854775807i64'
,
'22.123456789f64'
,
'"ddzhiksj"'
,
'11.12345f32'
,
'true'
,
'127Ii8
'
)])
tdSql
.
checkEqual
(
query_res
,
[(
datetime
.
datetime
(
2021
,
7
,
11
,
20
,
33
,
54
),
9.223372036854776e+18
,
'
true'
,
'127Ii8'
,
'32767i16'
,
'2147483647i32'
,
'9223372036854775807i64'
,
'11.12345f32'
,
'22.123456789f64'
,
'"ddzhiksj"'
,
'L"ncharTagValue"
'
)])
col_tag_res
=
tdSql
.
getColNameList
(
query_sql
)
tdSql
.
checkEqual
(
col_tag_res
,
[
'_ts'
,
'_value'
,
'
"t$3"'
,
't!@#$%^&*()_+[];:<>?,9'
,
't#2'
,
't%4'
,
't&6'
,
't*7'
,
'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
'
])
tdSql
.
execute
(
'drop table `rFa$sta`'
)
def
tcpKeywordsCheckCase
(
self
,
protocol
=
"telnet-tcp"
):
...
...
@@ -1207,7 +1207,6 @@ class TDTestCase:
tdLog
.
info
(
f
'
{
sys
.
_getframe
().
f_code
.
co_name
}
() function is running'
)
tdCom
.
cleanTb
(
dbname
=
"test"
)
input_sql
=
self
.
genSqlList
()[
0
]
print
(
input_sql
)
self
.
multiThreadRun
(
self
.
genMultiThreadSeq
(
input_sql
))
tdSql
.
query
(
f
"show tables;"
)
tdSql
.
checkRows
(
5
)
...
...
@@ -1416,8 +1415,8 @@ class TDTestCase:
self
.
symbolsCheckCase
()
self
.
tsCheckCase
()
self
.
openTstbTelnetTsCheckCase
()
#self.idSeqCheckCase()
#
self.idLetterCheckCase()
#
self.idSeqCheckCase()
self
.
idLetterCheckCase
()
self
.
noIdCheckCase
()
self
.
maxColTagCheckCase
()
self
.
stbTbNameCheckCase
()
...
...
@@ -1450,7 +1449,7 @@ class TDTestCase:
self
.
spellCheckCase
()
self
.
pointTransCheckCase
()
self
.
defaultTypeCheckCase
()
#
self.tbnameTagsColsNameCheckCase()
self
.
tbnameTagsColsNameCheckCase
()
# # # MultiThreads
# self.stbInsertMultiThreadCheckCase()
# self.sStbStbDdataInsertMultiThreadCheckCase()
...
...
tests/system-test/2-query/sml.py
浏览文件 @
100001ca
...
...
@@ -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
浏览文件 @
100001ca
...
...
@@ -78,21 +78,23 @@ int smlProcess_telnet_Test() {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
char
*
sql
[
4
]
=
{
0
};
sql
[
0
]
=
taosMemoryCalloc
(
1
,
128
);
sql
[
1
]
=
taosMemoryCalloc
(
1
,
128
);
sql
[
2
]
=
taosMemoryCalloc
(
1
,
128
);
sql
[
3
]
=
taosMemoryCalloc
(
1
,
128
);
//
char *sql[4] = {0};
//
sql[0] = taosMemoryCalloc(1, 128);
//
sql[1] = taosMemoryCalloc(1, 128);
//
sql[2] = taosMemoryCalloc(1, 128);
//
sql[3] = taosMemoryCalloc(1, 128);
const
char
*
sql1
[]
=
{
"sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0"
,
"sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01 "
,
"sys.if.bytes.out 1479496102 1.3E3 network=tcp"
,
" sys.procs.running 1479496100 42 host=web01 "
};
for
(
int
i
=
0
;
i
<
4
;
i
++
){
strncpy
(
sql
[
i
],
sql1
[
i
],
128
);
}
//
for(int i = 0; i < 4; i++){
//
strncpy(sql[i], sql1[i], 128);
//
}
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_TELNET_PROTOCOL
,
// pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_TELNET_PROTOCOL,
// TSDB_SML_TIMESTAMP_NANO_SECONDS);
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
...
...
@@ -112,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
;
...
...
@@ -136,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
;
}
...
...
@@ -156,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
;
}
...
...
@@ -233,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
));
...
...
@@ -797,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"
);
...
...
@@ -936,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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录