Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
32ee9bf7
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看板
提交
32ee9bf7
编写于
9月 29, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10445]<enhance>: change API name from taos_insert_lines to taos_schemaless_insert
上级
0182f95c
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
39 addition
and
33 deletion
+39
-33
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+2
-1
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+5
-5
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+6
-6
src/connector/python/README.md
src/connector/python/README.md
+2
-2
src/connector/python/examples/insert-lines.py
src/connector/python/examples/insert-lines.py
+2
-2
src/connector/python/taos/__init__.py
src/connector/python/taos/__init__.py
+2
-2
src/connector/python/taos/connection.py
src/connector/python/taos/connection.py
+18
-13
src/connector/python/tests/test_lines.py
src/connector/python/tests/test_lines.py
+2
-2
未找到文件。
src/client/src/TSDBJNIConnector.c
浏览文件 @
32ee9bf7
...
...
@@ -17,6 +17,7 @@
#include "taos.h"
#include "tlog.h"
#include "tscUtil.h"
#include "tscParseLine.h"
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
...
...
@@ -1070,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
c_lines
[
i
]
=
(
char
*
)(
*
env
)
->
GetStringUTFChars
(
env
,
line
,
0
);
}
int
code
=
taos_schemaless_insert
(
taos
,
c_lines
,
numLines
,
0
);
int
code
=
taos_schemaless_insert
(
taos
,
c_lines
,
numLines
,
SML_LINE_PROTOCOL
);
for
(
int
i
=
0
;
i
<
numLines
;
++
i
)
{
jstring
line
=
(
jstring
)((
*
env
)
->
GetObjectArrayElement
(
env
,
lines
,
i
));
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
32ee9bf7
...
...
@@ -1811,8 +1811,8 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
while
(
*
cur
!=
'\0'
)
{
if
(
len
>
TSDB_COL_NAME_LEN
-
1
)
{
tscError
(
"SML:0x%"
PRIx64
" Key field cannot exceeds
64 characters"
,
info
->
id
);
if
(
len
>
=
TSDB_COL_NAME_LEN
-
1
)
{
tscError
(
"SML:0x%"
PRIx64
" Key field cannot exceeds
%d characters"
,
info
->
id
,
TSDB_COL_NAME_LEN
-
1
);
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
//unescaped '=' identifies a tag key
...
...
@@ -1898,8 +1898,8 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
}
while
(
*
cur
!=
'\0'
)
{
if
(
len
>
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"SML:0x%"
PRIx64
" Measurement field cannot exceeds
192 characters"
,
info
->
id
);
if
(
len
>
=
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"SML:0x%"
PRIx64
" Measurement field cannot exceeds
%d characters"
,
info
->
id
,
TSDB_TABLE_NAME_LEN
-
1
);
free
(
pSml
->
stableName
);
pSml
->
stableName
=
NULL
;
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
...
...
@@ -1931,7 +1931,7 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
//Table name can only contain digits(0-9),alphebet(a-z),underscore(_)
int32_t
isValidChildTableName
(
const
char
*
pTbName
,
int16_t
len
,
SSmlLinesInfo
*
info
)
{
if
(
len
>
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"SML:0x%"
PRIx64
" child table name cannot exceeds
192 characters"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" child table name cannot exceeds
%d characters"
,
info
->
id
,
TSDB_TABLE_NAME_LEN
-
1
);
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
}
const
char
*
cur
=
pTbName
;
...
...
src/client/src/tscParseOpenTSDB.c
浏览文件 @
32ee9bf7
...
...
@@ -48,8 +48,8 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
}
while
(
*
cur
!=
'\0'
)
{
if
(
len
>
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Metric cannot exceeds
192 characters"
,
info
->
id
);
if
(
len
>
=
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Metric cannot exceeds
%d characters"
,
info
->
id
,
TSDB_TABLE_NAME_LEN
-
1
);
tfree
(
pSml
->
stableName
);
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
}
...
...
@@ -180,8 +180,8 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
while
(
*
cur
!=
'\0'
)
{
if
(
len
>
TSDB_COL_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Tag key cannot exceeds
64 characters"
,
info
->
id
);
if
(
len
>
=
TSDB_COL_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Tag key cannot exceeds
%d characters"
,
info
->
id
,
TSDB_COL_NAME_LEN
-
1
);
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
if
(
*
cur
==
' '
)
{
...
...
@@ -447,7 +447,7 @@ static int32_t parseMetricFromJSON(cJSON *root, TAOS_SML_DATA_POINT* pSml, SSmlL
size_t
stableLen
=
strlen
(
metric
->
valuestring
);
if
(
stableLen
>
TSDB_TABLE_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Metric cannot exceeds
192 characters in JSON"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Metric cannot exceeds
%d characters in JSON"
,
info
->
id
,
TSDB_TABLE_NAME_LEN
-
1
);
return
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
}
...
...
@@ -882,7 +882,7 @@ static int32_t parseTagsFromJSON(cJSON *root, TAOS_SML_KV **pKVs, int *num_kvs,
//key
size_t
keyLen
=
strlen
(
tag
->
string
);
if
(
keyLen
>
TSDB_COL_NAME_LEN
-
1
)
{
tscError
(
"OTD:0x%"
PRIx64
" Tag key cannot exceeds
64 characters in JSON"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Tag key cannot exceeds
%d characters in JSON"
,
info
->
id
,
TSDB_COL_NAME_LEN
-
1
);
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
}
pkv
->
key
=
tcalloc
(
keyLen
+
1
,
sizeof
(
char
));
...
...
src/connector/python/README.md
浏览文件 @
32ee9bf7
...
...
@@ -404,13 +404,13 @@ lines = [
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns'
,
]
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
print
(
"inserted"
)
lines
=
[
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns'
,
]
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
result
=
conn
.
query
(
"show tables"
)
for
row
in
result
:
...
...
src/connector/python/examples/insert-lines.py
浏览文件 @
32ee9bf7
...
...
@@ -9,10 +9,10 @@ conn.select_db(dbname)
lines
=
[
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns'
,
]
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
print
(
"inserted"
)
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
result
=
conn
.
query
(
"show tables"
)
for
row
in
result
:
...
...
src/connector/python/taos/__init__.py
浏览文件 @
32ee9bf7
...
...
@@ -406,13 +406,13 @@ lines = [
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
]
conn.schemaless_insert(lines)
conn.schemaless_insert(lines
, 0
)
print("inserted")
lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns',
]
conn.schemaless_insert(lines)
conn.schemaless_insert(lines
, 0
)
result = conn.query("show tables")
for row in result:
...
...
src/connector/python/taos/connection.py
浏览文件 @
32ee9bf7
...
...
@@ -132,19 +132,31 @@ class TaosConnection(object):
lines = [
'ste,t2=5,t3=L"ste" c1=true,c2=4,c3="string" 1626056811855516532',
]
conn.schemaless_insert(lines)
conn.schemaless_insert(lines
, 0
)
```
2.OpenTSDB telnet style API format support
## Example
cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"
import taos
conn = taos.connect()
conn.exec("drop database if exists test")
conn.select_db("test")
lines = [
'cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"',
]
conn.schemaless_insert(lines, 1)
3.OpenTSDB HTTP JSON format support
## Example
"{
import taos
conn = taos.connect()
conn.exec("drop database if exists test")
conn.select_db("test")
payload = ['''
{
"metric": "cpu_load_0",
"timestamp": 1626006833610123,
"value": 55.5,
...
...
@@ -154,16 +166,9 @@ class TaosConnection(object):
"interface": "eth0",
"Id": "tb0"
}
}"
## Exception
```python
try:
conn.schemaless_insert(lines)
except SchemalessError as err:
print(err)
```
}
''']
conn.schemaless_insert(lines, 2)
"""
return
taos_schemaless_insert
(
self
.
_conn
,
lines
,
protocol
)
...
...
src/connector/python/tests/test_lines.py
浏览文件 @
32ee9bf7
...
...
@@ -27,13 +27,13 @@ def test_schemaless_insert(conn):
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns'
,
]
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
print
(
"inserted"
)
lines
=
[
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000ns'
,
]
conn
.
schemaless_insert
(
lines
)
conn
.
schemaless_insert
(
lines
,
0
)
print
(
"inserted"
)
result
=
conn
.
query
(
"select * from st"
)
print
(
*
result
.
fields
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录