Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
735509d7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
735509d7
编写于
12月 09, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opti:modify logic for telnet and json in schemaless
上级
aae94079
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
11 deletion
+22
-11
source/client/src/clientSml.c
source/client/src/clientSml.c
+22
-11
未找到文件。
source/client/src/clientSml.c
浏览文件 @
735509d7
...
...
@@ -200,6 +200,7 @@ typedef struct {
int32_t
sTableNameLen
;
char
childTableName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
uid
;
void
*
key
;
// for openTsdb telnet
SArray
*
tags
;
...
...
@@ -855,7 +856,7 @@ static uint8_t smlPrecisionConvert[7] = {TSDB_TIME_PRECISION_NANO, TSDB_TIME_PRE
TSDB_TIME_PRECISION_NANO
};
static
int64_t
smlFactorNS
[
3
]
=
{
NANOSECOND_PER_MSEC
,
NANOSECOND_PER_USEC
,
1
};
static
int64_t
smlFactorS
[
3
]
=
{
1000LL
,
1000000LL
,
1000000000LL
};
static
int64_t
smlToMilli
[
3
]
=
{
3600
LL
,
60LL
,
1
LL
};
static
int64_t
smlToMilli
[
3
]
=
{
3600
000LL
,
60000LL
,
1000
LL
};
static
int64_t
smlGetTimeValue
(
const
char
*
value
,
int32_t
len
,
uint8_t
fromPrecision
,
uint8_t
toPrecision
)
{
char
*
endPtr
=
NULL
;
...
...
@@ -1149,6 +1150,13 @@ int32_t is_same_child_table_json(const void *a, const void *b){
return
(
cJSON_Compare
((
const
cJSON
*
)
a
,
(
const
cJSON
*
)
b
,
true
))
?
0
:
1
;
}
int32_t
is_same_child_table_telnet
(
const
void
*
a
,
const
void
*
b
){
SSmlLineInfo
*
t1
=
(
SSmlLineInfo
*
)
a
;
SSmlLineInfo
*
t2
=
(
SSmlLineInfo
*
)
b
;
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
;
}
#define IS_SAME_CHILD_TABLE (elements->measureTagsLen == info->preLine.measureTagsLen \
&& memcmp(elements->measure, info->preLine.measure, elements->measureTagsLen) == 0)
...
...
@@ -1687,7 +1695,7 @@ static void smlParseTelnetElement(char **sql, char *sqlEnd, char **data, int32_t
}
static
int32_t
smlParseTelnetTags
(
SSmlHandle
*
info
,
char
*
data
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
,
SSmlMsgBuf
*
msg
)
{
if
(
IS_SAME_CHILD_TABLE
){
if
(
is_same_child_table_telnet
(
elements
,
&
info
->
preLine
)
){
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1725,7 +1733,6 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
const
char
*
sql
=
data
;
size_t
childTableNameLen
=
strlen
(
tsSmlChildTableName
);
while
(
sql
<
sqlEnd
)
{
JUMP_SPACE
(
sql
,
sqlEnd
)
if
(
unlikely
(
*
sql
==
'\0'
))
break
;
...
...
@@ -1839,7 +1846,7 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
cnt
++
;
}
SSmlTableInfo
*
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
->
measure
,
elements
->
measureTagsLen
,
NULL
);
SSmlTableInfo
*
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
,
POINTER_BYTES
,
is_same_child_table_telnet
);
if
(
unlikely
(
tinfo
==
NULL
))
{
tinfo
=
smlBuildTableInfo
(
1
,
elements
->
measure
,
elements
->
measureLen
);
if
(
!
tinfo
)
{
...
...
@@ -1858,7 +1865,10 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
}
nodeListSet
(
&
info
->
childTables
,
elements
->
measure
,
elements
->
measureTagsLen
,
tinfo
);
SSmlLineInfo
*
key
=
taosMemoryMalloc
(
sizeof
(
SSmlLineInfo
));
*
key
=
*
elements
;
tinfo
->
key
=
key
;
nodeListSet
(
&
info
->
childTables
,
key
,
POINTER_BYTES
,
tinfo
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1906,11 +1916,8 @@ static int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, S
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
// move measure before tags to combine keys to identify child table
memmove
(
sql
-
elements
->
measureLen
,
elements
->
measure
,
elements
->
measureLen
);
elements
->
measure
=
sql
-
elements
->
measureLen
;
elements
->
measureLen
+=
sqlEnd
-
sql
;
elements
->
tags
=
sql
;
elements
->
tagsLen
=
sqlEnd
-
sql
;
int
ret
=
smlParseTelnetTags
(
info
,
sql
,
sqlEnd
,
elements
,
&
info
->
msgBuf
);
if
(
unlikely
(
ret
!=
TSDB_CODE_SUCCESS
))
{
...
...
@@ -1987,6 +1994,7 @@ static void smlDestroyTableInfo(SSmlTableInfo *tag) {
taosHashCleanup
(
kvHash
);
}
taosMemoryFree
(
tag
->
key
);
taosArrayDestroy
(
tag
->
cols
);
taosArrayDestroy
(
tag
->
tags
);
taosMemoryFree
(
tag
);
...
...
@@ -2433,6 +2441,7 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *root, SSmlLineInfo
return
TSDB_CODE_TSC_INVALID_JSON
;
}
elements
->
tags
=
(
char
*
)
tags
;
if
(
is_same_child_table_json
(
elements
->
tags
,
info
->
preLine
.
tags
)
==
0
){
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2654,8 +2663,10 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
for
(
int32_t
i
=
0
;
i
<
info
->
lineNum
;
i
++
){
SSmlLineInfo
*
elements
=
info
->
lines
+
i
;
SSmlTableInfo
*
tinfo
=
NULL
;
if
(
info
->
protocol
!=
TSDB_SML_JSON
_PROTOCOL
){
if
(
info
->
protocol
==
TSDB_SML_LINE
_PROTOCOL
){
tinfo
=
(
SSmlTableInfo
*
)
nodeListGet
(
info
->
childTables
,
elements
->
measure
,
elements
->
measureTagsLen
,
NULL
);
}
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
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录