Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f3bd507f
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看板
提交
f3bd507f
编写于
11月 25, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10870]<enhance>: [schemaless]add a NULL tag to accommodate influxDB tag is optional
上级
7965f860
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
17 deletion
+32
-17
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+32
-17
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
f3bd507f
...
...
@@ -152,7 +152,9 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra
static
int32_t
getSmlMd5ChildTableName
(
TAOS_SML_DATA_POINT
*
point
,
char
*
tableName
,
int
*
tableNameLen
,
SSmlLinesInfo
*
info
)
{
tscDebug
(
"SML:0x%"
PRIx64
" taos_sml_insert get child table name through md5"
,
info
->
id
);
qsort
(
point
->
tags
,
point
->
tagNum
,
sizeof
(
TAOS_SML_KV
),
compareSmlColKv
);
if
(
point
->
tagNum
)
{
qsort
(
point
->
tags
,
point
->
tagNum
,
sizeof
(
TAOS_SML_KV
),
compareSmlColKv
);
}
SStringBuilder
sb
;
memset
(
&
sb
,
0
,
sizeof
(
sb
));
char
sTableName
[
TSDB_TABLE_NAME_LEN
+
TS_ESCAPE_CHAR_SIZE
]
=
{
0
};
...
...
@@ -185,6 +187,18 @@ static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableNa
return
0
;
}
static
int32_t
buildSmlChildTableName
(
TAOS_SML_DATA_POINT
*
point
,
SSmlLinesInfo
*
info
)
{
tscDebug
(
"SML:0x%"
PRIx64
" taos_sml_insert build child table name"
,
info
->
id
);
char
childTableName
[
TSDB_TABLE_NAME_LEN
+
TS_ESCAPE_CHAR_SIZE
];
int32_t
tableNameLen
=
TSDB_TABLE_NAME_LEN
+
TS_ESCAPE_CHAR_SIZE
;
getSmlMd5ChildTableName
(
point
,
childTableName
,
&
tableNameLen
,
info
);
point
->
childTableName
=
calloc
(
1
,
tableNameLen
+
1
);
strncpy
(
point
->
childTableName
,
childTableName
,
tableNameLen
);
point
->
childTableName
[
tableNameLen
]
=
'\0'
;
return
0
;
}
static
int32_t
buildDataPointSchemas
(
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
,
SArray
*
stableSchemas
,
SSmlLinesInfo
*
info
)
{
int32_t
code
=
0
;
SHashObj
*
sname2shema
=
taosHashInit
(
32
,
...
...
@@ -216,12 +230,7 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint,
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
tagKv
=
point
->
tags
+
j
;
if
(
!
point
->
childTableName
)
{
char
childTableName
[
TSDB_TABLE_NAME_LEN
+
TS_ESCAPE_CHAR_SIZE
];
int32_t
tableNameLen
=
TSDB_TABLE_NAME_LEN
+
TS_ESCAPE_CHAR_SIZE
;
getSmlMd5ChildTableName
(
point
,
childTableName
,
&
tableNameLen
,
info
);
point
->
childTableName
=
calloc
(
1
,
tableNameLen
+
1
);
strncpy
(
point
->
childTableName
,
childTableName
,
tableNameLen
);
point
->
childTableName
[
tableNameLen
]
=
'\0'
;
buildSmlChildTableName
(
point
,
info
);
}
code
=
buildSmlKvSchema
(
tagKv
,
pStableSchema
->
tagHash
,
pStableSchema
->
tags
,
info
);
...
...
@@ -231,16 +240,22 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint,
}
}
const
char
tagNullName
[]
=
"`_tag_null`"
;
size_t
*
pTagNullIdx
=
taosHashGet
(
pStableSchema
->
tagHash
,
tagNullName
,
strlen
(
tagNullName
));
if
(
!
pTagNullIdx
)
{
SSchema
tagNull
=
{
0
};
tagNull
.
type
=
TSDB_DATA_TYPE_NCHAR
;
tagNull
.
bytes
=
6
;
strncpy
(
tagNull
.
name
,
tagNullName
,
strlen
(
tagNullName
));
taosArrayPush
(
pStableSchema
->
tags
,
&
tagNull
);
size_t
tagNullIdx
=
taosArrayGetSize
(
pStableSchema
->
tags
)
-
1
;
taosHashPut
(
pStableSchema
->
tagHash
,
tagNull
.
name
,
strlen
(
tagNullName
),
&
tagNullIdx
,
sizeof
(
tagNullIdx
));
//for Line Protocol tags may be omitted, add a tag with NULL value
if
(
point
->
tagNum
==
0
)
{
if
(
!
point
->
childTableName
)
{
buildSmlChildTableName
(
point
,
info
);
}
const
char
tagNullName
[]
=
"`_tag_null`"
;
size_t
*
pTagNullIdx
=
taosHashGet
(
pStableSchema
->
tagHash
,
tagNullName
,
strlen
(
tagNullName
));
if
(
!
pTagNullIdx
)
{
SSchema
tagNull
=
{
0
};
tagNull
.
type
=
TSDB_DATA_TYPE_NCHAR
;
tagNull
.
bytes
=
6
;
strncpy
(
tagNull
.
name
,
tagNullName
,
strlen
(
tagNullName
));
taosArrayPush
(
pStableSchema
->
tags
,
&
tagNull
);
size_t
tagNullIdx
=
taosArrayGetSize
(
pStableSchema
->
tags
)
-
1
;
taosHashPut
(
pStableSchema
->
tagHash
,
tagNull
.
name
,
strlen
(
tagNullName
),
&
tagNullIdx
,
sizeof
(
tagNullIdx
));
}
}
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录