Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
62e4b0b5
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
62e4b0b5
编写于
7月 12, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add timestamp precision support
上级
4a75ebe4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
15 deletion
+42
-15
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+29
-10
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+13
-5
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
62e4b0b5
...
...
@@ -21,6 +21,7 @@ typedef struct {
SHashObj
*
fieldHash
;
SArray
*
tags
;
//SArray<SSchema>
SArray
*
fields
;
//SArray<SSchema>
uint8_t
precision
;
}
SSmlSTableSchema
;
typedef
struct
{
...
...
@@ -117,6 +118,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) {
taosHashGetClone
(
tscTableMetaInfo
,
fullTableName
,
strlen
(
fullTableName
),
NULL
,
tableMeta
,
-
1
);
tstrncpy
(
schema
->
sTableName
,
tableName
,
strlen
(
tableName
)
+
1
);
schema
->
precision
=
tableMeta
->
tableInfo
.
precision
;
for
(
int
i
=
0
;
i
<
tableMeta
->
tableInfo
.
numOfColumns
;
++
i
)
{
SSchema
field
;
tstrncpy
(
field
.
name
,
tableMeta
->
schema
[
i
].
name
,
strlen
(
tableMeta
->
schema
[
i
].
name
)
+
1
);
...
...
@@ -486,6 +488,25 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints)
strncpy
(
point
->
childTableName
,
childTableName
,
tableNameLen
);
point
->
childTableName
[
tableNameLen
]
=
'\0'
;
}
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
tags
+
j
;
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
point
->
schema
->
precision
);
*
(
int64_t
*
)(
kv
->
value
)
=
ts
;
}
}
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
fields
+
j
;
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
point
->
schema
->
precision
);
*
(
int64_t
*
)(
kv
->
value
)
=
ts
;
}
}
SArray
*
cTablePoints
=
NULL
;
SArray
**
pCTablePoints
=
taosHashGet
(
cname2points
,
point
->
childTableName
,
strlen
(
point
->
childTableName
));
if
(
pCTablePoints
)
{
...
...
@@ -596,7 +617,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
point
->
schema
=
pStableSchema
;
}
SArray
*
schemaActions
=
taosArrayInit
(
32
,
sizeof
(
SSchemaAction
));
size_t
numStable
=
taosArrayGetSize
(
stableArray
);
for
(
int
i
=
0
;
i
<
numStable
;
++
i
)
{
SSmlSTableSchema
*
pointSchema
=
taosArrayGet
(
stableArray
,
i
);
...
...
@@ -615,8 +635,10 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
memcpy
(
schemaAction
.
createSTable
.
sTableName
,
pointSchema
->
sTableName
,
TSDB_TABLE_NAME_LEN
);
schemaAction
.
createSTable
.
tags
=
pointSchema
->
tags
;
schemaAction
.
createSTable
.
fields
=
pointSchema
->
fields
;
taosArrayPush
(
schemaActions
,
&
schemaAction
);
}
else
if
(
code
==
TSDB_CODE_SUCCESS
)
{
applySchemaAction
(
taos
,
&
schemaAction
);
code
=
loadTableMeta
(
taos
,
pointSchema
->
sTableName
,
&
dbSchema
);
pointSchema
->
precision
=
dbSchema
.
precision
;
}
else
if
(
code
==
TSDB_CODE_SUCCESS
)
{
size_t
pointTagSize
=
taosArrayGetSize
(
pointSchema
->
tags
);
size_t
pointFieldSize
=
taosArrayGetSize
(
pointSchema
->
fields
);
...
...
@@ -629,7 +651,7 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
bool
actionNeeded
=
false
;
generateSchemaAction
(
pointTag
,
dbTagHash
,
true
,
pointSchema
->
sTableName
,
&
schemaAction
,
&
actionNeeded
);
if
(
actionNeeded
)
{
taosArrayPush
(
schemaAction
s
,
&
schemaAction
);
applySchemaAction
(
tao
s
,
&
schemaAction
);
}
}
...
...
@@ -643,19 +665,16 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
bool
actionNeeded
=
false
;
generateSchemaAction
(
pointCol
,
dbFieldHash
,
false
,
pointSchema
->
sTableName
,
&
schemaAction
,
&
actionNeeded
);
if
(
actionNeeded
)
{
taosArrayPush
(
schemaAction
s
,
&
schemaAction
);
applySchemaAction
(
tao
s
,
&
schemaAction
);
}
}
pointSchema
->
precision
=
dbSchema
.
precision
;
}
else
{
return
code
;
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
schemaActions
);
++
i
)
{
SSchemaAction
*
action
=
taosArrayGet
(
schemaActions
,
i
);
applySchemaAction
(
taos
,
action
);
}
insertPoints
(
taos
,
points
,
numPoint
);
return
code
;
}
...
...
tests/examples/c/apitest.c
浏览文件 @
62e4b0b5
...
...
@@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) {
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test
precision 'us'
;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
...
...
@@ -950,11 +950,19 @@ void verify_stream(TAOS* taos) {
}
int32_t
verify_schema_less
(
TAOS
*
taos
)
{
prepare_data
(
taos
);
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database test precision 'us';"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
char
*
lines
[]
=
{
"st,t1=3i,t2=4,t3=
\"
t3
\"
c1=3i,c3=L
\"
passit
\"
,c2=false,c4=4 1626006833639"
,
"st,t1=4i,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833640"
,
"st,t1=4i,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833642"
"st,t1=3i,t2=4,t3=
\"
t3
\"
c1=3i,c3=L
\"
passit
\"
,c2=false,c4=4 1626006833639
000000
"
,
"st,t1=4i,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833640
000000
"
,
"st,t1=4i,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833642
000000
"
};
int
code
=
taos_insert_by_lines
(
taos
,
lines
,
3
);
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录