Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5bc1a121
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看板
提交
5bc1a121
编写于
8月 28, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
schemaless: performance optimization: no hash table for each point/kv
上级
5bdb3bf4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
28 deletion
+12
-28
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+12
-28
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
5bc1a121
...
@@ -32,6 +32,8 @@ typedef struct {
...
@@ -32,6 +32,8 @@ typedef struct {
uint8_t
type
;
uint8_t
type
;
int16_t
length
;
int16_t
length
;
char
*
value
;
char
*
value
;
uint32_t
fieldSchemaIdx
;
}
TAOS_SML_KV
;
}
TAOS_SML_KV
;
typedef
struct
{
typedef
struct
{
...
@@ -44,6 +46,8 @@ typedef struct {
...
@@ -44,6 +46,8 @@ typedef struct {
// first kv must be timestamp
// first kv must be timestamp
TAOS_SML_KV
*
fields
;
TAOS_SML_KV
*
fields
;
int32_t
fieldNum
;
int32_t
fieldNum
;
uint32_t
schemaIdx
;
}
TAOS_SML_DATA_POINT
;
}
TAOS_SML_DATA_POINT
;
typedef
enum
{
typedef
enum
{
...
@@ -56,7 +60,6 @@ typedef enum {
...
@@ -56,7 +60,6 @@ typedef enum {
typedef
struct
{
typedef
struct
{
uint64_t
id
;
uint64_t
id
;
SHashObj
*
smlDataToSchema
;
}
SSmlLinesInfo
;
}
SSmlLinesInfo
;
//=================================================================================================
//=================================================================================================
...
@@ -175,8 +178,7 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra
...
@@ -175,8 +178,7 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra
taosHashPut
(
hash
,
field
.
name
,
tagKeyLen
,
&
fieldIdx
,
sizeof
(
fieldIdx
));
taosHashPut
(
hash
,
field
.
name
,
tagKeyLen
,
&
fieldIdx
,
sizeof
(
fieldIdx
));
}
}
uintptr_t
valPointer
=
(
uintptr_t
)
smlKv
;
smlKv
->
fieldSchemaIdx
=
(
uint32_t
)
fieldIdx
;
taosHashPut
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
),
&
fieldIdx
,
sizeof
(
fieldIdx
));
return
0
;
return
0
;
}
}
...
@@ -270,8 +272,7 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint,
...
@@ -270,8 +272,7 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint,
}
}
}
}
uintptr_t
valPointer
=
(
uintptr_t
)
point
;
point
->
schemaIdx
=
(
uint32_t
)
stableIdx
;
taosHashPut
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
),
&
stableIdx
,
sizeof
(
stableIdx
));
}
}
size_t
numStables
=
taosArrayGetSize
(
stableSchemas
);
size_t
numStables
=
taosArrayGetSize
(
stableSchemas
);
...
@@ -916,10 +917,7 @@ static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int nu
...
@@ -916,10 +917,7 @@ static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int nu
SHashObj
*
cname2points
,
SArray
*
stableSchemas
,
SSmlLinesInfo
*
info
)
{
SHashObj
*
cname2points
,
SArray
*
stableSchemas
,
SSmlLinesInfo
*
info
)
{
for
(
int32_t
i
=
0
;
i
<
numPoints
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numPoints
;
++
i
)
{
TAOS_SML_DATA_POINT
*
point
=
points
+
i
;
TAOS_SML_DATA_POINT
*
point
=
points
+
i
;
uintptr_t
valPointer
=
(
uintptr_t
)
point
;
SSmlSTableSchema
*
stableSchema
=
taosArrayGet
(
stableSchemas
,
point
->
schemaIdx
);
size_t
*
pSchemaIndex
=
taosHashGet
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
));
assert
(
pSchemaIndex
!=
NULL
);
SSmlSTableSchema
*
stableSchema
=
taosArrayGet
(
stableSchemas
,
*
pSchemaIndex
);
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
tags
+
j
;
TAOS_SML_KV
*
kv
=
point
->
tags
+
j
;
...
@@ -963,10 +961,7 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
...
@@ -963,10 +961,7 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
TAOS_SML_DATA_POINT
*
pDataPoint
=
taosArrayGetP
(
cTablePoints
,
i
);
TAOS_SML_DATA_POINT
*
pDataPoint
=
taosArrayGetP
(
cTablePoints
,
i
);
for
(
int
j
=
0
;
j
<
pDataPoint
->
tagNum
;
++
j
)
{
for
(
int
j
=
0
;
j
<
pDataPoint
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
pDataPoint
->
tags
+
j
;
TAOS_SML_KV
*
kv
=
pDataPoint
->
tags
+
j
;
uintptr_t
valPointer
=
(
uintptr_t
)
kv
;
tagKVs
[
kv
->
fieldSchemaIdx
]
=
kv
;
size_t
*
pFieldSchemaIdx
=
taosHashGet
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
));
assert
(
pFieldSchemaIdx
!=
NULL
);
tagKVs
[
*
pFieldSchemaIdx
]
=
kv
;
}
}
}
}
...
@@ -980,10 +975,7 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
...
@@ -980,10 +975,7 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
for
(
int
j
=
0
;
j
<
numTags
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numTags
;
++
j
)
{
if
(
tagKVs
[
j
]
==
NULL
)
continue
;
if
(
tagKVs
[
j
]
==
NULL
)
continue
;
TAOS_SML_KV
*
kv
=
tagKVs
[
j
];
TAOS_SML_KV
*
kv
=
tagKVs
[
j
];
uintptr_t
valPointer
=
(
uintptr_t
)
kv
;
TAOS_BIND
*
bind
=
taosArrayGet
(
tagBinds
,
kv
->
fieldSchemaIdx
);
size_t
*
pFieldSchemaIdx
=
taosHashGet
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
));
assert
(
pFieldSchemaIdx
!=
NULL
);
TAOS_BIND
*
bind
=
taosArrayGet
(
tagBinds
,
*
pFieldSchemaIdx
);
bind
->
buffer_type
=
kv
->
type
;
bind
->
buffer_type
=
kv
->
type
;
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
*
bind
->
length
=
kv
->
length
;
*
bind
->
length
=
kv
->
length
;
...
@@ -1026,10 +1018,7 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema,
...
@@ -1026,10 +1018,7 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema,
}
}
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
fields
+
j
;
TAOS_SML_KV
*
kv
=
point
->
fields
+
j
;
uintptr_t
valPointer
=
(
uintptr_t
)
kv
;
TAOS_BIND
*
bind
=
colBinds
+
kv
->
fieldSchemaIdx
;
size_t
*
pFieldSchemaIdx
=
taosHashGet
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
));
assert
(
pFieldSchemaIdx
!=
NULL
);
TAOS_BIND
*
bind
=
colBinds
+
*
pFieldSchemaIdx
;
bind
->
buffer_type
=
kv
->
type
;
bind
->
buffer_type
=
kv
->
type
;
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
bind
->
length
=
malloc
(
sizeof
(
uintptr_t
*
));
*
bind
->
length
=
kv
->
length
;
*
bind
->
length
=
kv
->
length
;
...
@@ -1067,10 +1056,7 @@ static int32_t applyDataPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t
...
@@ -1067,10 +1056,7 @@ static int32_t applyDataPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t
SArray
*
cTablePoints
=
*
pCTablePoints
;
SArray
*
cTablePoints
=
*
pCTablePoints
;
TAOS_SML_DATA_POINT
*
point
=
taosArrayGetP
(
cTablePoints
,
0
);
TAOS_SML_DATA_POINT
*
point
=
taosArrayGetP
(
cTablePoints
,
0
);
uintptr_t
valPointer
=
(
uintptr_t
)
point
;
SSmlSTableSchema
*
sTableSchema
=
taosArrayGet
(
stableSchemas
,
point
->
schemaIdx
);
size_t
*
pSchemaIndex
=
taosHashGet
(
info
->
smlDataToSchema
,
&
valPointer
,
sizeof
(
uintptr_t
));
assert
(
pSchemaIndex
!=
NULL
);
SSmlSTableSchema
*
sTableSchema
=
taosArrayGet
(
stableSchemas
,
*
pSchemaIndex
);
tscDebug
(
"SML:0x%"
PRIx64
" apply child table tags. child table: %s"
,
info
->
id
,
point
->
childTableName
);
tscDebug
(
"SML:0x%"
PRIx64
" apply child table tags. child table: %s"
,
info
->
id
,
point
->
childTableName
);
code
=
applyChildTableTags
(
taos
,
point
->
childTableName
,
point
->
stableName
,
sTableSchema
,
cTablePoints
,
info
);
code
=
applyChildTableTags
(
taos
,
point
->
childTableName
,
point
->
stableName
,
sTableSchema
,
cTablePoints
,
info
);
...
@@ -1113,7 +1099,6 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
...
@@ -1113,7 +1099,6 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
tscDebug
(
"SML:0x%"
PRIx64
" taos_sml_insert. number of points: %d"
,
info
->
id
,
numPoint
);
tscDebug
(
"SML:0x%"
PRIx64
" taos_sml_insert. number of points: %d"
,
info
->
id
,
numPoint
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
info
->
smlDataToSchema
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
false
);
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
...
@@ -1143,11 +1128,10 @@ clean_up:
...
@@ -1143,11 +1128,10 @@ clean_up:
taosArrayDestroy
(
schema
->
tags
);
taosArrayDestroy
(
schema
->
tags
);
}
}
taosArrayDestroy
(
stableSchemas
);
taosArrayDestroy
(
stableSchemas
);
taosHashCleanup
(
info
->
smlDataToSchema
);
return
code
;
return
code
;
}
}
int
t
aos
_sml_insert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
)
{
int
t
sc
_sml_insert
(
TAOS
*
taos
,
TAOS_SML_DATA_POINT
*
points
,
int
numPoint
)
{
SSmlLinesInfo
*
info
=
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
calloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genLinesSmlId
();
info
->
id
=
genLinesSmlId
();
int
code
=
tscSmlInsert
(
taos
,
points
,
numPoint
,
info
);
int
code
=
tscSmlInsert
(
taos
,
points
,
numPoint
,
info
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录