Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bbbadfcf
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看板
提交
bbbadfcf
编写于
10月 19, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--reuse-message=HEAD
上级
492c2e5a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
65 deletion
+72
-65
src/client/inc/tscParseLine.h
src/client/inc/tscParseLine.h
+4
-8
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+51
-55
src/inc/taos.h
src/inc/taos.h
+17
-2
未找到文件。
src/client/inc/tscParseLine.h
浏览文件 @
bbbadfcf
...
...
@@ -23,6 +23,8 @@ extern "C" {
#define SML_TIMESTAMP_SECOND_DIGITS 10
#define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13
typedef
SML_PROTOCOL_TYPE
SMLProtocolType
;
typedef
struct
{
char
*
key
;
uint8_t
type
;
...
...
@@ -46,22 +48,16 @@ typedef struct {
}
TAOS_SML_DATA_POINT
;
typedef
enum
{
SML_TIME_STAMP_NO
W
,
SML_TIME_STAMP_NO
T_CONFIGURED
,
SML_TIME_STAMP_HOURS
,
SML_TIME_STAMP_MINUTES
,
SML_TIME_STAMP_SECONDS
,
SML_TIME_STAMP_MILLI_SECONDS
,
SML_TIME_STAMP_MICRO_SECONDS
,
SML_TIME_STAMP_NANO_SECONDS
,
SML_TIME_STAMP_NO
T_CONFIGURED
SML_TIME_STAMP_NO
W
}
SMLTimeStampType
;
typedef
enum
{
SML_LINE_PROTOCOL
=
0
,
SML_TELNET_PROTOCOL
=
1
,
SML_JSON_PROTOCOL
=
2
,
}
SMLProtocolType
;
typedef
struct
{
uint64_t
id
;
SMLProtocolType
protocol
;
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
bbbadfcf
...
...
@@ -2300,52 +2300,52 @@ cleanup:
return
code
;
}
int32_t
convertPrecisionStrType
(
const
char
*
precision
,
SMLTimeStampType
*
tsType
)
{
if
(
precision
==
NULL
)
{
*
tsType
=
SML_TIME_STAMP_NOT_CONFIGURED
;
return
TSDB_CODE_SUCCESS
;
}
if
(
strcmp
(
precision
,
"μ"
)
==
0
)
{
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
return
TSDB_CODE_SUCCESS
;
static
int32_t
convertPrecisionType
(
int
precision
,
SMLTimeStampType
*
tsType
)
{
switch
(
precision
)
{
case
SML_TIMESTAMP_NOT_CONFIGURED
:
*
tsType
=
SML_TIME_STAMP_NOT_CONFIGURED
;
break
;
case
SML_TIMESTAMP_HOURS
:
*
tsType
=
SML_TIME_STAMP_HOURS
;
break
;
case
SML_TIMESTAMP_MILLI_SECONDS
:
*
tsType
=
SML_TIME_STAMP_MILLI_SECONDS
;
break
;
case
SML_TIMESTAMP_NANO_SECONDS
:
*
tsType
=
SML_TIME_STAMP_NANO_SECONDS
;
break
;
case
SML_TIMESTAMP_MICRO_SECONDS
:
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
break
;
case
SML_TIMESTAMP_SECONDS
:
*
tsType
=
SML_TIME_STAMP_SECONDS
;
break
;
case
SML_TIMESTAMP_MINUTES
:
*
tsType
=
SML_TIME_STAMP_MINUTES
;
break
;
default:
return
TSDB_CODE_TSC_INVALID_PRECISION_TYPE
;
}
int32_t
len
=
(
int32_t
)
strlen
(
precision
);
if
(
len
==
1
)
{
switch
(
precision
[
0
])
{
case
'u'
:
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
break
;
case
's'
:
*
tsType
=
SML_TIME_STAMP_SECONDS
;
break
;
case
'm'
:
*
tsType
=
SML_TIME_STAMP_MINUTES
;
break
;
case
'h'
:
*
tsType
=
SML_TIME_STAMP_HOURS
;
break
;
default:
return
TSDB_CODE_TSC_INVALID_PRECISION_TYPE
;
}
}
else
if
(
len
==
2
&&
precision
[
1
]
==
's'
)
{
switch
(
precision
[
0
])
{
case
'm'
:
*
tsType
=
SML_TIME_STAMP_MILLI_SECONDS
;
break
;
case
'n'
:
*
tsType
=
SML_TIME_STAMP_NANO_SECONDS
;
break
;
default:
return
TSDB_CODE_TSC_INVALID_PRECISION_TYPE
;
}
}
else
{
return
TSDB_CODE_TSC_INVALID_PRECISION_TYPE
;
return
TSDB_CODE_SUCCESS
;
}
static
SSqlObj
*
createSmlQueryObj
(
int32_t
affected_rows
,
int32_t
code
)
{
SSqlObj
*
pNew
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pNew
==
NULL
)
{
return
NULL
;
}
pNew
->
signature
=
pNew
;
tsem_init
(
&
pNew
->
rspSem
,
0
,
0
);
registerSqlObj
(
pNew
);
return
TSDB_CODE_SUCCESS
;
pNew
->
res
.
numOfRows
=
affected_rows
;
pNew
->
res
.
code
=
code
;
return
pNew
;
}
/**
* taos_schemaless_insert() parse and insert data points into database according to
* different protocol.
...
...
@@ -2367,39 +2367,35 @@ int32_t convertPrecisionStrType(const char* precision, SMLTimeStampType *tsType)
*
*/
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
const
char
*
precision
,
int
*
affectedRows
,
char
*
msg
,
int
msgBufLen
)
{
int
code
;
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
int
code
=
TSDB_CODE_SUCCESS
;
int
affected_rows
=
0
;
SMLTimeStampType
tsType
;
if
(
protocol
==
SML_LINE_PROTOCOL
)
{
code
=
convertPrecision
Str
Type
(
precision
,
&
tsType
);
code
=
convertPrecisionType
(
precision
,
&
tsType
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
msg
!=
NULL
)
{
tstrncpy
(
msg
,
tstrerror
(
code
),
msgBufLen
);
}
return
code
;
return
NULL
;
}
}
switch
(
protocol
)
{
case
SML_LINE_PROTOCOL
:
code
=
taos_insert_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
,
affectedR
ows
);
code
=
taos_insert_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
,
&
affected_r
ows
);
break
;
case
SML_TELNET_PROTOCOL
:
code
=
taos_insert_telnet_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
,
affectedR
ows
);
code
=
taos_insert_telnet_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
,
&
affected_r
ows
);
break
;
case
SML_JSON_PROTOCOL
:
code
=
taos_insert_json_payload
(
taos
,
*
lines
,
protocol
,
tsType
,
affectedR
ows
);
code
=
taos_insert_json_payload
(
taos
,
*
lines
,
protocol
,
tsType
,
&
affected_r
ows
);
break
;
default:
code
=
TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE
;
break
;
}
if
(
msg
!=
NULL
)
{
tstrncpy
(
msg
,
tstrerror
(
code
),
msgBufLen
);
}
return
code
;
SSqlObj
*
pSql
=
createSmlQueryObj
(
affected_rows
,
code
);
return
(
TAOS_RES
*
)
pSql
;
}
src/inc/taos.h
浏览文件 @
bbbadfcf
...
...
@@ -72,6 +72,22 @@ typedef enum {
SET_CONF_RET_ERR_TOO_LONG
=
-
6
}
SET_CONF_RET_CODE
;
typedef
enum
{
SML_LINE_PROTOCOL
=
1
,
SML_TELNET_PROTOCOL
=
2
,
SML_JSON_PROTOCOL
=
3
,
}
SML_PROTOCOL_TYPE
;
typedef
enum
{
SML_TIMESTAMP_NOT_CONFIGURED
=
0
,
SML_TIMESTAMP_HOURS
,
SML_TIMESTAMP_MINUTES
,
SML_TIMESTAMP_SECONDS
,
SML_TIMESTAMP_MILLI_SECONDS
,
SML_TIMESTAMP_MICRO_SECONDS
,
SML_TIMESTAMP_NANO_SECONDS
,
}
SML_TIMESTAMP_TYPE
;
#define RET_MSG_LENGTH 1024
typedef
struct
setConfRet
{
SET_CONF_RET_CODE
retCode
;
...
...
@@ -188,8 +204,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
const
char
*
precision
,
int
*
affectedRows
,
char
*
msg
,
int
msgBufLen
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录