Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b50103d4
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b50103d4
编写于
12月 19, 2022
作者:
wmmhello
提交者:
GitHub
12月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19005 from taosdata/refact/submit_req_marks
opti:schemaless logic
上级
28559dc4
a13d2158
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
627 addition
and
904 deletion
+627
-904
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+5
-3
source/client/src/clientSml.c
source/client/src/clientSml.c
+178
-5
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+276
-432
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+48
-23
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+3
-4
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+66
-145
tests/system-test/2-query/sml.py
tests/system-test/2-query/sml.py
+7
-6
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+44
-286
未找到文件。
source/client/inc/clientSml.h
浏览文件 @
b50103d4
...
...
@@ -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,8 @@ typedef struct {
int32_t
lineNum
;
SSmlMsgBuf
msgBuf
;
cJSON
*
root
;
// for parse json
// cJSON *root; // for parse json
int8_t
offset
[
4
];
SSmlLineInfo
*
lines
;
// element is SSmlLineInfo
//
...
...
@@ -216,8 +217,9 @@ 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
smlParseValue
(
SSmlKv
*
pVal
,
SSmlMsgBuf
*
msg
);
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
浏览文件 @
b50103d4
...
...
@@ -235,7 +235,182 @@ SSmlSTableMeta *smlBuildSTableMeta(bool isDataFormat) {
return
NULL
;
}
//uint16_t smlCalTypeSum(char* endptr, int32_t left){
// uint16_t sum = 0;
// for(int i = 0; i < left; i++){
// sum += endptr[i];
// }
// return sum;
//}
#define RETURN_FALSE \
smlBuildInvalidDataMsg(msg, "invalid data", pVal); \
return false;
#define SET_DOUBLE kvVal->type = TSDB_DATA_TYPE_DOUBLE;\
kvVal->d = result;
#define SET_FLOAT \
if (!IS_VALID_FLOAT(result)) {\
smlBuildInvalidDataMsg(msg, "float out of range[-3.402823466e+38,3.402823466e+38]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_FLOAT;\
kvVal->f = (float)result;
#define SET_BIGINT \
if (smlDoubleToInt64OverFlow(result)) {\
errno = 0;\
int64_t tmp = taosStr2Int64(pVal, &endptr, 10);\
if (errno == ERANGE) {\
smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_BIGINT;\
kvVal->i = tmp;\
return true;\
}\
kvVal->type = TSDB_DATA_TYPE_BIGINT;\
kvVal->i = (int64_t)result;
#define SET_INT \
if (!IS_VALID_INT(result)) {\
smlBuildInvalidDataMsg(msg, "int out of range[-2147483648,2147483647]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_INT;\
kvVal->i = result;
#define SET_SMALL_INT \
if (!IS_VALID_SMALLINT(result)) {\
smlBuildInvalidDataMsg(msg, "small int our of range[-32768,32767]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_SMALLINT;\
kvVal->i = result;
#define SET_UBIGINT \
if (result >= (double)UINT64_MAX || result < 0) {\
errno = 0;\
uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10);\
if (errno == ERANGE || result < 0) {\
smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_UBIGINT;\
kvVal->u = tmp;\
return true;\
}\
kvVal->type = TSDB_DATA_TYPE_UBIGINT;\
kvVal->u = result;
#define SET_UINT \
if (!IS_VALID_UINT(result)) {\
smlBuildInvalidDataMsg(msg, "unsigned int out of range[0,4294967295]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_UINT;\
kvVal->u = result;
#define SET_USMALL_INT \
if (!IS_VALID_USMALLINT(result)) {\
smlBuildInvalidDataMsg(msg, "unsigned small int out of rang[0,65535]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_USMALLINT;\
kvVal->u = result;
#define SET_TINYINT \
if (!IS_VALID_TINYINT(result)) { \
smlBuildInvalidDataMsg(msg, "tiny int out of range[-128,127]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_TINYINT;\
kvVal->i = result;
#define SET_UTINYINT \
if (!IS_VALID_UTINYINT(result)) {\
smlBuildInvalidDataMsg(msg, "unsigned tiny int out of range[0,255]", pVal);\
return false;\
}\
kvVal->type = TSDB_DATA_TYPE_UTINYINT;\
kvVal->u = result;
bool
smlParseNumber
(
SSmlKv
*
kvVal
,
SSmlMsgBuf
*
msg
)
{
const
char
*
pVal
=
kvVal
->
value
;
int32_t
len
=
kvVal
->
length
;
char
*
endptr
=
NULL
;
double
result
=
taosStr2Double
(
pVal
,
&
endptr
);
if
(
pVal
==
endptr
)
{
RETURN_FALSE
}
int32_t
left
=
len
-
(
endptr
-
pVal
);
if
(
left
==
0
)
{
SET_DOUBLE
}
else
if
(
left
==
3
)
{
if
(
endptr
[
0
]
==
'f'
||
endptr
[
0
]
==
'F'
){
if
(
endptr
[
1
]
==
'6'
&&
endptr
[
2
]
==
'4'
){
SET_DOUBLE
}
else
if
(
endptr
[
1
]
==
'3'
&&
endptr
[
2
]
==
'2'
){
SET_FLOAT
}
else
{
RETURN_FALSE
}
}
else
if
(
endptr
[
0
]
==
'i'
||
endptr
[
0
]
==
'I'
){
if
(
endptr
[
1
]
==
'6'
&&
endptr
[
2
]
==
'4'
){
SET_BIGINT
}
else
if
(
endptr
[
1
]
==
'3'
&&
endptr
[
2
]
==
'2'
){
SET_INT
}
else
if
(
endptr
[
1
]
==
'1'
&&
endptr
[
2
]
==
'6'
){
SET_SMALL_INT
}
else
{
RETURN_FALSE
}
}
else
if
(
endptr
[
0
]
==
'u'
||
endptr
[
0
]
==
'U'
){
if
(
endptr
[
1
]
==
'6'
&&
endptr
[
2
]
==
'4'
){
SET_UBIGINT
}
else
if
(
endptr
[
1
]
==
'3'
&&
endptr
[
2
]
==
'2'
){
SET_UINT
}
else
if
(
endptr
[
1
]
==
'1'
&&
endptr
[
2
]
==
'6'
){
SET_USMALL_INT
}
else
{
RETURN_FALSE
}
}
else
{
RETURN_FALSE
}
}
else
if
(
left
==
2
){
if
(
endptr
[
0
]
==
'i'
||
endptr
[
0
]
==
'I'
){
if
(
endptr
[
1
]
==
'8'
)
{
SET_TINYINT
}
else
{
RETURN_FALSE
}
}
else
if
(
endptr
[
0
]
==
'u'
||
endptr
[
0
]
==
'U'
)
{
if
(
endptr
[
1
]
==
'8'
)
{
SET_UTINYINT
}
else
{
RETURN_FALSE
}
}
else
{
RETURN_FALSE
}
}
else
if
(
left
==
1
){
if
(
endptr
[
0
]
==
'i'
||
endptr
[
0
]
==
'I'
){
SET_BIGINT
}
else
if
(
endptr
[
0
]
==
'u'
||
endptr
[
0
]
==
'U'
)
{
SET_UBIGINT
}
else
{
RETURN_FALSE
}
}
else
{
RETURN_FALSE
;
}
return
true
;
}
bool
smlParseNumberOld
(
SSmlKv
*
kvVal
,
SSmlMsgBuf
*
msg
)
{
const
char
*
pVal
=
kvVal
->
value
;
int32_t
len
=
kvVal
->
length
;
char
*
endptr
=
NULL
;
...
...
@@ -885,7 +1060,6 @@ static void smlDestroyInfo(SSmlHandle *info) {
taosMemoryFree
(
info
->
lines
);
}
cJSON_Delete
(
info
->
root
);
taosMemoryFreeClear
(
info
);
}
...
...
@@ -950,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
){
...
...
@@ -1201,7 +1375,7 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
return
code
;
}
info
->
cost
.
lineNum
=
numLines
;
info
->
cost
.
lineNum
=
info
->
lineNum
;
info
->
cost
.
numOfSTables
=
nodeListSize
(
info
->
superTables
);
info
->
cost
.
numOfCTables
=
nodeListSize
(
info
->
childTables
);
...
...
@@ -1288,10 +1462,9 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
request
->
code
=
code
;
info
->
cost
.
endTime
=
taosGetTimestampUs
();
info
->
cost
.
code
=
code
;
smlPrintStatisticInfo
(
info
);
//
smlPrintStatisticInfo(info);
end:
uDebug
(
"resultend:%s"
,
request
->
msgBuf
);
smlDestroyInfo
(
info
);
return
(
TAOS_RES
*
)
request
;
}
...
...
source/client/src/clientSmlJson.c
浏览文件 @
b50103d4
此差异已折叠。
点击以展开。
source/client/src/clientSmlLine.c
浏览文件 @
b50103d4
...
...
@@ -120,34 +120,58 @@ static int64_t smlParseInfluxTime(SSmlHandle *info, const char *data, int32_t le
return
ts
;
}
static
int32_t
smlParseValue
(
SSmlKv
*
pVal
,
SSmlMsgBuf
*
msg
)
{
// binary
if
(
smlIsBinary
(
pVal
->
value
,
pVal
->
length
))
{
pVal
->
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
length
-=
BINARY_ADD_LEN
;
if
(
pVal
->
length
>
TSDB_MAX_BINARY_LEN
-
VARSTR_HEADER_SIZE
)
{
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
int32_t
smlParseValue
(
SSmlKv
*
pVal
,
SSmlMsgBuf
*
msg
)
{
if
(
pVal
->
value
[
0
]
==
'"'
){
// binary
if
(
pVal
->
length
>=
2
&&
pVal
->
value
[
pVal
->
length
-
1
]
==
'"'
)
{
pVal
->
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
length
-=
BINARY_ADD_LEN
;
if
(
pVal
->
length
>
TSDB_MAX_BINARY_LEN
-
VARSTR_HEADER_SIZE
)
{
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
}
pVal
->
value
+=
(
BINARY_ADD_LEN
-
1
);
return
TSDB_CODE_SUCCESS
;
}
pVal
->
value
+=
(
BINARY_ADD_LEN
-
1
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
// nchar
if
(
smlIsNchar
(
pVal
->
value
,
pVal
->
length
))
{
pVal
->
type
=
TSDB_DATA_TYPE_NCHAR
;
pVal
->
length
-=
NCHAR_ADD_LEN
;
if
(
pVal
->
length
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
if
(
pVal
->
value
[
0
]
==
'l'
||
pVal
->
value
[
0
]
==
'L'
){
// nchar
if
(
pVal
->
value
[
1
]
==
'"'
&&
pVal
->
value
[
pVal
->
length
-
1
]
==
'"'
&&
pVal
->
length
>=
3
){
pVal
->
type
=
TSDB_DATA_TYPE_NCHAR
;
pVal
->
length
-=
NCHAR_ADD_LEN
;
if
(
pVal
->
length
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
;
}
pVal
->
value
+=
(
NCHAR_ADD_LEN
-
1
);
return
TSDB_CODE_SUCCESS
;
}
pVal
->
value
+=
(
NCHAR_ADD_LEN
-
1
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
// bool
if
(
smlParseBool
(
pVal
))
{
pVal
->
type
=
TSDB_DATA_TYPE_BOOL
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
return
TSDB_CODE_SUCCESS
;
if
(
pVal
->
value
[
0
]
==
't'
||
pVal
->
value
[
0
]
==
'T'
){
if
(
pVal
->
length
==
1
||
(
pVal
->
length
==
4
&&
(
pVal
->
value
[
1
]
==
'r'
||
pVal
->
value
[
1
]
==
'R'
)
&&
(
pVal
->
value
[
2
]
==
'u'
||
pVal
->
value
[
2
]
==
'U'
)
&&
(
pVal
->
value
[
3
]
==
'e'
||
pVal
->
value
[
3
]
==
'E'
))){
pVal
->
i
=
TSDB_TRUE
;
pVal
->
type
=
TSDB_DATA_TYPE_BOOL
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
if
(
pVal
->
value
[
0
]
==
'f'
||
pVal
->
value
[
0
]
==
'F'
){
if
(
pVal
->
length
==
1
||
(
pVal
->
length
==
5
&&
(
pVal
->
value
[
1
]
==
'a'
||
pVal
->
value
[
1
]
==
'A'
)
&&
(
pVal
->
value
[
2
]
==
'l'
||
pVal
->
value
[
2
]
==
'L'
)
&&
(
pVal
->
value
[
3
]
==
's'
||
pVal
->
value
[
3
]
==
'S'
)
&&
(
pVal
->
value
[
4
]
==
'e'
||
pVal
->
value
[
4
]
==
'E'
))){
pVal
->
i
=
TSDB_FALSE
;
pVal
->
type
=
TSDB_DATA_TYPE_BOOL
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
// number
if
(
smlParseNumber
(
pVal
,
msg
))
{
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
...
...
@@ -432,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
;
...
...
@@ -468,6 +492,7 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
value
=
value
,
.
length
=
valueLen
};
int32_t
ret
=
smlParseValue
(
&
kv
,
&
info
->
msgBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlParseValue error"
,
value
);
return
ret
;
}
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
b50103d4
...
...
@@ -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
))
{
...
...
@@ -283,11 +283,10 @@ int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine
}
SSmlKv
kv
=
{.
key
=
VALUE
,
.
keyLen
=
VALUE_LEN
,
.
value
=
elements
->
cols
,
.
length
=
(
size_t
)
elements
->
colsLen
};
if
(
smlParseNumber
(
&
kv
,
&
info
->
msgBuf
))
{
kv
.
length
=
(
int16_t
)
tDataTypes
[
kv
.
type
].
bytes
;
}
else
{
if
(
smlParseValue
(
&
kv
,
&
info
->
msgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
JUMP_SPACE
(
sql
,
sqlEnd
)
elements
->
tags
=
sql
;
...
...
source/client/test/smlTest.cpp
浏览文件 @
b50103d4
...
...
@@ -239,6 +239,7 @@ TEST(testCase, smlParseCols_Test) {
info
->
protocol
=
TSDB_SML_LINE_PROTOCOL
;
info
->
dataFormat
=
false
;
SSmlLineInfo
elements
=
{
0
};
info
->
msgBuf
=
msgBuf
;
const
char
*
data
=
"st,t=1 cb
\\
=in=
\"
pass
\\
,it "
...
...
@@ -413,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
};
...
...
@@ -486,138 +487,58 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlParseTelnetLine_json_error_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
"
"]"
,
};
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
);
}
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
smlParseTelnetLine_diff_json_type1_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
\"
: 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
"
"]"
,
"[{
\"
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
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
break
;
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
);
}
}
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
;
TEST
(
testCase
,
smlParseNumber_performance_Test
)
{
char
msg
[
256
]
=
{
0
};
SSmlMsgBuf
msgBuf
;
SSmlKv
kv
;
char
*
str
[
3
]
=
{
"2893f64"
,
"2323u32"
,
"93u8"
};
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int64_t
t1
=
taosGetTimestampUs
();
for
(
int
j
=
0
;
j
<
10000000
;
++
j
)
{
kv
.
value
=
str
[
i
];
kv
.
length
=
strlen
(
str
[
i
]);
smlParseNumber
(
&
kv
,
&
msgBuf
);
}
printf
(
"smlParseNumber:%s cost:%"
PRId64
,
str
[
i
],
taosGetTimestampUs
()
-
t1
);
printf
(
"
\n
"
);
int64_t
t2
=
taosGetTimestampUs
();
for
(
int
j
=
0
;
j
<
10000000
;
++
j
)
{
kv
.
value
=
str
[
i
];
kv
.
length
=
strlen
(
str
[
i
]);
smlParseNumberOld
(
&
kv
,
&
msgBuf
);
}
printf
(
"smlParseNumberOld:%s cost:%"
PRId64
,
str
[
i
],
taosGetTimestampUs
()
-
t2
);
printf
(
"
\n\n
"
);
}
ASSERT_NE
(
ret
,
0
);
smlDestroyInfo
(
info
);
}
}
\ No newline at end of file
tests/system-test/2-query/sml.py
浏览文件 @
b50103d4
...
...
@@ -76,13 +76,14 @@ class TDTestCase:
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
,
"lga"
)
tdSql
.
checkData
(
0
,
3
,
"web02"
)
tdSql
.
checkData
(
0
,
4
,
None
)
tdSql
.
checkData
(
0
,
2
,
"web02"
)
tdSql
.
checkData
(
0
,
3
,
None
)
tdSql
.
checkData
(
0
,
4
,
"lga"
)
tdSql
.
checkData
(
1
,
1
,
18.000000000
)
tdSql
.
checkData
(
1
,
2
,
"
lga
"
)
tdSql
.
checkData
(
1
,
3
,
"
web0
1"
)
tdSql
.
checkData
(
1
,
4
,
"t1
"
)
tdSql
.
checkData
(
1
,
2
,
"
web01
"
)
tdSql
.
checkData
(
1
,
3
,
"
t
1"
)
tdSql
.
checkData
(
0
,
4
,
"lga
"
)
tdSql
.
query
(
f
"select * from
{
dbname
}
.macylr"
)
tdSql
.
checkRows
(
2
)
...
...
utils/test/c/sml_test.c
浏览文件 @
b50103d4
...
...
@@ -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
);
...
...
@@ -1013,10 +738,10 @@ int sml_add_tag_col_Test() {
int
smlProcess_18784_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_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
db_18784
schemaless 1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use
sml_db
"
);
pRes
=
taos_query
(
taos
,
"use
db_18784
"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
...
...
@@ -1159,7 +884,46 @@ int sml_ttl_Test() {
return
code
;
}
//char *str[] ={
// "",
// "f64",
// "F64",
// "f32",
// "F32",
// "i",
// "I",
// "i64",
// "I64",
// "u",
// "U",
// "u64",
// "U64",
// "i32",
// "I32",
// "u32",
// "U32",
// "i16",
// "I16",
// "u16",
// "U16",
// "i8",
// "I8",
// "u8",
// "U8",
//};
//uint8_t smlCalTypeSum(char* endptr, int32_t left){
// uint8_t sum = 0;
// for(int i = 0; i < left; i++){
// sum += endptr[i];
// }
// return sum;
//}
int
main
(
int
argc
,
char
*
argv
[])
{
// for(int i = 0; i < sizeof(str)/sizeof(str[0]); i++){
// printf("str:%s \t %d\n", str[i], smlCalTypeSum(str[i], strlen(str[i])));
// }
int
ret
=
0
;
ret
=
sml_ttl_Test
();
ASSERT
(
!
ret
);
...
...
@@ -1172,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
();
...
...
@@ -1185,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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录