Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bc95808b
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看板
提交
bc95808b
编写于
8月 30, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6442]<feature>: Support OpenTSDB telnet style data import format
上级
9c1813dc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
29 deletion
+28
-29
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+28
-29
未找到文件。
src/client/src/tscParseOpenTSDB.c
浏览文件 @
bc95808b
...
...
@@ -72,7 +72,7 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
char
*
value
=
NULL
;
start
=
cur
=
*
index
;
*
pTS
=
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
*
pTS
=
t
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
while
(
*
cur
!=
'\0'
)
{
if
(
*
cur
==
' '
)
{
...
...
@@ -83,22 +83,22 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
}
if
(
len
>
0
)
{
value
=
calloc
(
len
+
1
,
1
);
value
=
t
calloc
(
len
+
1
,
1
);
memcpy
(
value
,
start
,
len
);
}
else
{
free
(
*
pTS
);
t
free
(
*
pTS
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
ret
=
convertSmlTimeStamp
(
*
pTS
,
value
,
len
,
info
);
if
(
ret
)
{
free
(
value
);
free
(
*
pTS
);
t
free
(
value
);
t
free
(
*
pTS
);
return
ret
;
}
free
(
value
);
t
free
(
value
);
(
*
pTS
)
->
key
=
calloc
(
sizeof
(
key
),
1
);
(
*
pTS
)
->
key
=
t
calloc
(
sizeof
(
key
),
1
);
memcpy
((
*
pTS
)
->
key
,
key
,
sizeof
(
key
));
*
num_kvs
+=
1
;
...
...
@@ -117,7 +117,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
char
*
value
=
NULL
;
start
=
cur
=
*
index
;
pVal
=
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
pVal
=
t
calloc
(
1
,
sizeof
(
TAOS_SML_KV
));
while
(
*
cur
!=
'\0'
)
{
if
(
*
cur
==
' '
)
{
...
...
@@ -128,23 +128,23 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
}
if
(
len
>
0
)
{
value
=
calloc
(
len
+
1
,
1
);
value
=
t
calloc
(
len
+
1
,
1
);
memcpy
(
value
,
start
,
len
);
}
else
{
free
(
pVal
);
t
free
(
pVal
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
if
(
!
convertSmlValueType
(
pVal
,
value
,
len
,
info
))
{
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
info
->
id
,
value
);
free
(
value
);
free
(
pVal
);
t
free
(
value
);
t
free
(
pVal
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
free
(
value
);
t
free
(
value
);
pVal
->
key
=
calloc
(
sizeof
(
key
),
1
);
pVal
->
key
=
t
calloc
(
sizeof
(
key
),
1
);
memcpy
(
pVal
->
key
,
key
,
sizeof
(
key
));
*
num_kvs
+=
1
;
...
...
@@ -181,7 +181,7 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
pKV
->
key
=
calloc
(
len
+
1
,
1
);
pKV
->
key
=
t
calloc
(
len
+
1
,
1
);
memcpy
(
pKV
->
key
,
key
,
len
+
1
);
//tscDebug("SML:0x%"PRIx64" Key:%s|len:%d", info->id, pKV->key, len);
*
index
=
cur
+
1
;
...
...
@@ -207,19 +207,18 @@ static bool parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
len
++
;
}
value
=
calloc
(
len
+
1
,
1
);
value
=
t
calloc
(
len
+
1
,
1
);
memcpy
(
value
,
start
,
len
);
value
[
len
]
=
'\0'
;
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
))
{
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
info
->
id
,
value
);
//free previous alocated key field
free
(
pKV
->
key
);
pKV
->
key
=
NULL
;
free
(
value
);
tfree
(
pKV
->
key
);
tfree
(
value
);
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
free
(
value
);
t
free
(
value
);
*
index
=
(
*
cur
==
'\0'
)
?
cur
:
cur
+
1
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -234,7 +233,7 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
bool
is_last_kv
=
false
;
int32_t
capacity
=
4
;
*
pKVs
=
calloc
(
capacity
,
sizeof
(
TAOS_SML_KV
));
*
pKVs
=
t
calloc
(
capacity
,
sizeof
(
TAOS_SML_KV
));
pkv
=
*
pKVs
;
while
(
*
cur
!=
'\0'
)
{
...
...
@@ -256,8 +255,8 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
childTableName
=
malloc
(
pkv
->
length
+
1
);
memcpy
(
childTableName
,
pkv
->
value
,
pkv
->
length
);
childTableName
[
pkv
->
length
]
=
'\0'
;
free
(
pkv
->
key
);
free
(
pkv
->
value
);
t
free
(
pkv
->
key
);
t
free
(
pkv
->
value
);
}
else
{
*
num_kvs
+=
1
;
}
...
...
@@ -347,7 +346,7 @@ int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, SArray*
int
taos_insert_telnet_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
)
{
int32_t
code
=
0
;
SSmlLinesInfo
*
info
=
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
t
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genUID
();
if
(
numLines
<=
0
||
numLines
>
65536
)
{
...
...
@@ -359,7 +358,7 @@ int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines) {
for
(
int
i
=
0
;
i
<
numLines
;
++
i
)
{
if
(
lines
[
i
]
==
NULL
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_insert_lines line %d is NULL"
,
info
->
id
,
i
);
free
(
info
);
t
free
(
info
);
code
=
TSDB_CODE_TSC_APP_ERROR
;
return
code
;
}
...
...
@@ -368,7 +367,7 @@ int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines) {
SArray
*
lpPoints
=
taosArrayInit
(
numLines
,
sizeof
(
TAOS_SML_DATA_POINT
));
if
(
lpPoints
==
NULL
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_insert_lines failed to allocate memory"
,
info
->
id
);
free
(
info
);
t
free
(
info
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -396,14 +395,14 @@ cleanup:
taosArrayDestroy
(
lpPoints
);
free
(
info
);
t
free
(
info
);
return
code
;
}
int
taos_telnet_insert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
)
{
SSmlLinesInfo
*
info
=
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
t
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genUID
();
int
code
=
tscSmlInsert
(
taos
,
points
,
numPoint
,
info
);
free
(
info
);
t
free
(
info
);
return
code
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录