Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed3beb24
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看板
提交
ed3beb24
编写于
10月 15, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
d0e645e4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
95 addition
and
10 deletion
+95
-10
include/server/vnode/meta/meta.h
include/server/vnode/meta/meta.h
+5
-2
source/server/vnode/meta/src/metaMain.c
source/server/vnode/meta/src/metaMain.c
+28
-4
source/server/vnode/meta/test/metaTests.cpp
source/server/vnode/meta/test/metaTests.cpp
+62
-4
未找到文件。
include/server/vnode/meta/meta.h
浏览文件 @
ed3beb24
...
...
@@ -58,9 +58,12 @@ SMetaQueryOpts *metaQueryOptionsCreate();
void
metaQueryOptionsDestroy
(
SMetaQueryOpts
*
);
// STableOpts
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
;
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
void
metaNormalTableOptsInit
(
STableOpts
*
,
const
char
*
name
,
const
STSchema
*
pSchema
);
void
metaTableOptsDestroy
(
STableOpts
*
);
void
metaSuperTableOptsInit
(
STableOpts
*
,
const
char
*
name
,
tb_uid_t
uid
,
const
STSchema
*
pSchema
,
const
STSchema
*
pTagSchema
);
void
metaChildTableOptsInit
(
STableOpts
*
,
const
char
*
name
,
tb_uid_t
suid
,
const
SKVRow
tags
);
void
metaTableOptsClear
(
STableOpts
*
);
/* ------------------------ Impl should hidden ------------------------ */
typedef
enum
{
META_INIT_TABLE
=
0
,
META_SUPER_TABLE
=
1
,
META_CHILD_TABLE
=
2
,
META_NORMAL_TABLE
=
3
}
EMetaTableT
;
...
...
source/server/vnode/meta/src/metaMain.c
浏览文件 @
ed3beb24
...
...
@@ -167,7 +167,7 @@ static int metaCreateChildTable(SMeta *pMeta, const char *tbname, const SChildTa
vallen
=
0
;
pBuf
=
(
void
*
)
buffer
;
vallen
+=
taosEncodeString
(
&
pBuf
,
tbname
);
vallen
+=
taosEncodeFixedU64
(
pBuf
,
pChildTableOpts
->
suid
);
vallen
+=
taosEncodeFixedU64
(
&
pBuf
,
pChildTableOpts
->
suid
);
tkvPut
(
pMeta
->
tableDb
,
NULL
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
buffer
,
vallen
);
// Put tbname -> uid
...
...
@@ -218,18 +218,42 @@ void metaNormalTableOptsInit(STableOpts *pTableOpts, const char *name, const STS
pTableOpts
->
normalOpts
.
pSchema
=
tdDupSchema
(
pSchema
);
}
void
metaTableOptsDestroy
(
STableOpts
*
pTableOpts
)
{
void
metaSuperTableOptsInit
(
STableOpts
*
pTableOpts
,
const
char
*
name
,
tb_uid_t
uid
,
const
STSchema
*
pSchema
,
const
STSchema
*
pTagSchema
)
{
pTableOpts
->
type
=
META_SUPER_TABLE
;
pTableOpts
->
name
=
strdup
(
name
);
pTableOpts
->
superOpts
.
uid
=
uid
;
pTableOpts
->
superOpts
.
pSchema
=
tdDupSchema
(
pSchema
);
pTableOpts
->
superOpts
.
pTagSchema
=
tdDupSchema
(
pTagSchema
);
}
void
metaChildTableOptsInit
(
STableOpts
*
pTableOpts
,
const
char
*
name
,
tb_uid_t
suid
,
const
SKVRow
tags
)
{
pTableOpts
->
type
=
META_CHILD_TABLE
;
pTableOpts
->
name
=
strdup
(
name
);
pTableOpts
->
childOpts
.
suid
=
suid
;
pTableOpts
->
childOpts
.
tags
=
tdKVRowDup
(
tags
);
}
void
metaTableOptsClear
(
STableOpts
*
pTableOpts
)
{
switch
(
pTableOpts
->
type
)
{
case
META_NORMAL_TABLE
:
tfree
(
pTableOpts
->
name
);
tdFreeSchema
(
pTableOpts
->
normalOpts
.
pSchema
);
break
;
case
META_SUPER_TABLE
:
tdFreeSchema
(
pTableOpts
->
superOpts
.
pTagSchema
);
tdFreeSchema
(
pTableOpts
->
superOpts
.
pSchema
);
tfree
(
pTableOpts
->
name
);
break
;
case
META_CHILD_TABLE
:
kvRowFree
(
pTableOpts
->
childOpts
.
tags
);
tfree
(
pTableOpts
->
name
);
break
;
default:
break
;
}
// TODO
pTableOpts
->
type
=
META_INIT_TABLE
;
memset
(
pTableOpts
,
0
,
sizeof
(
*
pTableOpts
));
}
void
metaDestroy
(
const
char
*
path
)
{
taosRemoveDir
(
path
);
}
source/server/vnode/meta/test/metaTests.cpp
浏览文件 @
ed3beb24
...
...
@@ -6,7 +6,7 @@
static
STSchema
*
metaGetSimpleSchema
()
{
STSchema
*
pSchema
=
NULL
;
STSchemaBuilder
sb
;
STSchemaBuilder
sb
=
{
0
}
;
tdInitTSchemaBuilder
(
&
sb
,
0
);
tdAddColToSchema
(
&
sb
,
TSDB_DATA_TYPE_TIMESTAMP
,
0
,
8
);
...
...
@@ -18,13 +18,31 @@ static STSchema *metaGetSimpleSchema() {
return
pSchema
;
}
TEST
(
MetaTest
,
meta_create_1m_normal_tables_test
)
{
static
SKVRow
metaGetSimpleTags
()
{
SKVRowBuilder
kvrb
=
{
0
};
SKVRow
row
;
tdInitKVRowBuilder
(
&
kvrb
);
int64_t
ts
=
1634287978000
;
int32_t
a
=
10
;
tdAddColToKVRow
(
&
kvrb
,
0
,
TSDB_DATA_TYPE_TIMESTAMP
,
(
void
*
)(
&
ts
));
tdAddColToKVRow
(
&
kvrb
,
0
,
TSDB_DATA_TYPE_INT
,
(
void
*
)(
&
a
));
row
=
tdGetKVRowFromBuilder
(
&
kvrb
);
tdDestroyKVRowBuilder
(
&
kvrb
);
return
row
;
}
TEST
(
MetaTest
,
DISABLED_meta_create_1m_normal_tables_test
)
{
// Open Meta
SMeta
*
meta
=
metaOpen
(
NULL
);
std
::
cout
<<
"Meta is opened!"
<<
std
::
endl
;
// Create 1000000 normal tables
META_TABLE_OPTS_DECLARE
(
tbOpts
)
META_TABLE_OPTS_DECLARE
(
tbOpts
)
;
STSchema
*
pSchema
=
metaGetSimpleSchema
();
char
tbname
[
128
];
...
...
@@ -32,8 +50,48 @@ TEST(MetaTest, meta_create_1m_normal_tables_test) {
sprintf
(
tbname
,
"ntb%ld"
,
i
);
metaNormalTableOptsInit
(
&
tbOpts
,
tbname
,
pSchema
);
metaCreateTable
(
meta
,
&
tbOpts
);
metaTableOptsDestroy
(
&
tbOpts
);
metaTableOptsClear
(
&
tbOpts
);
}
tdFreeSchema
(
pSchema
);
// Close Meta
metaClose
(
meta
);
std
::
cout
<<
"Meta is closed!"
<<
std
::
endl
;
// Destroy Meta
metaDestroy
(
"meta"
);
std
::
cout
<<
"Meta is destroyed!"
<<
std
::
endl
;
}
TEST
(
MetaTest
,
meta_create_1m_child_tables_test
)
{
// Open Meta
SMeta
*
meta
=
metaOpen
(
NULL
);
std
::
cout
<<
"Meta is opened!"
<<
std
::
endl
;
// Create a super tables
tb_uid_t
uid
=
477529885843758ul
;
META_TABLE_OPTS_DECLARE
(
tbOpts
);
STSchema
*
pSchema
=
metaGetSimpleSchema
();
STSchema
*
pTagSchema
=
metaGetSimpleSchema
();
metaSuperTableOptsInit
(
&
tbOpts
,
"st"
,
uid
,
pSchema
,
pTagSchema
);
metaCreateTable
(
meta
,
&
tbOpts
);
metaTableOptsClear
(
&
tbOpts
);
tdFreeSchema
(
pSchema
);
tdFreeSchema
(
pTagSchema
);
// Create 1000000 child tables
char
name
[
128
];
SKVRow
row
=
metaGetSimpleTags
();
for
(
size_t
i
=
0
;
i
<
1000000
;
i
++
)
{
sprintf
(
name
,
"ctb%ld"
,
i
);
metaChildTableOptsInit
(
&
tbOpts
,
name
,
uid
,
row
);
metaCreateTable
(
meta
,
&
tbOpts
);
metaTableOptsClear
(
&
tbOpts
);
}
kvRowFree
(
row
);
// Close Meta
metaClose
(
meta
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录