Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e9bf4fce
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
Star
22018
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看板
提交
e9bf4fce
编写于
11月 02, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
40d58ce1
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
240 addition
and
95 deletion
+240
-95
include/os/osDir.h
include/os/osDir.h
+1
-1
source/dnode/vnode/meta/inc/metaDB.h
source/dnode/vnode/meta/inc/metaDB.h
+39
-0
source/dnode/vnode/meta/inc/metaDef.h
source/dnode/vnode/meta/inc/metaDef.h
+5
-9
source/dnode/vnode/meta/inc/metaOptions.h
source/dnode/vnode/meta/inc/metaOptions.h
+33
-0
source/dnode/vnode/meta/inc/metaTbOptions.h
source/dnode/vnode/meta/inc/metaTbOptions.h
+27
-0
source/dnode/vnode/meta/inc/metaUid.h
source/dnode/vnode/meta/inc/metaUid.h
+5
-8
source/dnode/vnode/meta/src/metaDB.c
source/dnode/vnode/meta/src/metaDB.c
+14
-0
source/dnode/vnode/meta/src/metaMain.c
source/dnode/vnode/meta/src/metaMain.c
+67
-48
source/dnode/vnode/meta/src/metaOptions.c
source/dnode/vnode/meta/src/metaOptions.c
+8
-2
source/dnode/vnode/meta/src/metaTbOptions.c
source/dnode/vnode/meta/src/metaTbOptions.c
+14
-0
source/dnode/vnode/meta/src/metaUid.c
source/dnode/vnode/meta/src/metaUid.c
+2
-2
source/dnode/vnode/meta/test/CMakeLists.txt
source/dnode/vnode/meta/test/CMakeLists.txt
+24
-24
source/os/src/osDir.c
source/os/src/osDir.c
+1
-1
未找到文件。
include/os/osDir.h
浏览文件 @
e9bf4fce
...
@@ -22,7 +22,7 @@ extern "C" {
...
@@ -22,7 +22,7 @@ extern "C" {
void
taosRemoveDir
(
const
char
*
dirname
);
void
taosRemoveDir
(
const
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
bool
taosMkDir
(
char
*
dirname
);
bool
taosMkDir
(
c
onst
c
har
*
dirname
);
void
taosRemoveOldFiles
(
char
*
dirname
,
int32_t
keepDays
);
void
taosRemoveOldFiles
(
char
*
dirname
,
int32_t
keepDays
);
bool
taosExpandDir
(
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
bool
taosExpandDir
(
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
bool
taosRealPath
(
char
*
dirname
,
int32_t
maxlen
);
bool
taosRealPath
(
char
*
dirname
,
int32_t
maxlen
);
...
...
source/dnode/vnode/meta/inc/metaDB.h
0 → 100644
浏览文件 @
e9bf4fce
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_META_DB_H_
#define _TD_META_DB_H_
#include "meta.h"
#include "tkv.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SMetaDB
{
STkvDb
*
pDB
;
STkvDb
*
pIdx
;
STkvCache
*
pCache
;
}
SMetaDB
;
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_DB_H_*/
\ No newline at end of file
source/dnode/vnode/meta/inc/metaDef.h
浏览文件 @
e9bf4fce
...
@@ -16,22 +16,18 @@
...
@@ -16,22 +16,18 @@
#ifndef _TD_META_DEF_H_
#ifndef _TD_META_DEF_H_
#define _TD_META_DEF_H_
#define _TD_META_DEF_H_
#include "metaDB.h"
#include "metaUid.h"
#include "metaUid.h"
#include "tkv.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
struct
SMeta
{
struct
SMeta
{
STableUidGenerator
uidGenerator
;
char
*
path
;
// path of current meta
STbUidGenerator
uidGenerator
;
// meta table UID generator
STkvDb
*
tableDb
;
// uid->table obj
SMetaDB
*
pMetaDB
;
// meta DB for real storage engine
STkvDb
*
tbnameDb
;
// tbname --> uid
SMetaOptions
options
;
// meta option
STkvDb
*
schemaDb
;
// uid+version --> schema
STkvDb
*
tagDb
;
// uid --> tag
STkvDb
*
tagIdx
;
// TODO: need to integrate lucene or our own
// STkvCache* metaCache; // TODO: add a global cache here
};
};
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/dnode/vnode/meta/inc/metaOptions.h
0 → 100644
浏览文件 @
e9bf4fce
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_META_OPTIONS_H_
#define _TD_META_OPTIONS_H_
#include "meta.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
const
SMetaOptions
defaultMetaOptions
;
int
metaValidateOptions
(
const
SMetaOptions
*
);
void
metaOptionsCopy
(
SMetaOptions
*
pDest
,
const
SMetaOptions
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_OPTIONS_H_*/
\ No newline at end of file
source/dnode/vnode/meta/inc/metaTbOptions.h
0 → 100644
浏览文件 @
e9bf4fce
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_META_TABLE_OPTIONS_H_
#define _TD_META_TABLE_OPTIONS_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_TABLE_OPTIONS_H_*/
\ No newline at end of file
source/dnode/vnode/meta/inc/metaUid.h
浏览文件 @
e9bf4fce
...
@@ -23,21 +23,18 @@ extern "C" {
...
@@ -23,21 +23,18 @@ extern "C" {
#endif
#endif
/* ------------------------ APIS EXPOSED ------------------------ */
/* ------------------------ APIS EXPOSED ------------------------ */
typedef
struct
STableUidGenerator
STableUidGenerator
;
typedef
struct
STbUidGenerator
{
tb_uid_t
nextUid
;
}
STbUidGenerator
;
// tb_uid_t
// tb_uid_t
#define IVLD_TB_UID 0
#define IVLD_TB_UID 0
tb_uid_t
generateUid
(
ST
able
UidGenerator
*
);
tb_uid_t
generateUid
(
ST
b
UidGenerator
*
);
// STableUidGenerator
// STableUidGenerator
void
tableUidGeneratorInit
(
ST
able
UidGenerator
*
,
tb_uid_t
suid
);
void
tableUidGeneratorInit
(
ST
b
UidGenerator
*
,
tb_uid_t
suid
);
#define tableUidGeneratorClear(ug)
#define tableUidGeneratorClear(ug)
/* ------------------------ FOR TEST AND COMPILE ONLY ------------------------ */
struct
STableUidGenerator
{
tb_uid_t
nextUid
;
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/meta/src/metaDB.c
0 → 100644
浏览文件 @
e9bf4fce
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
source/dnode/vnode/meta/src/metaMain.c
浏览文件 @
e9bf4fce
...
@@ -13,74 +13,62 @@
...
@@ -13,74 +13,62 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tcoding.h"
#include "meta.h"
#include "meta.h"
#include "metaDef.h"
#include "metaDef.h"
#include "tcoding.h"
#include "metaOptions.h"
#include "metaDB.h"
static
int
metaCreateSuperTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SSuperTableOpts
*
pSuperTableOpts
);
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMetaOptions
*
pMetaOptions
);
static
int
metaCreateChildTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SChildTableOpts
*
pChildTableOpts
);
static
void
metaFree
(
SMeta
*
pMeta
);
static
int
metaCreateNormalTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SNormalTableOpts
*
pNormalTableOpts
);
static
int
metaCreateSuperTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SSuperTableOpts
*
pSuperTableOpts
);
static
int
metaCreateChildTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SChildTableOpts
*
pChildTableOpts
);
static
int
metaCreateNormalTable
(
SMeta
*
pMeta
,
const
char
*
tbname
,
const
SNormalTableOpts
*
pNormalTableOpts
);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaOptions
*
pMetaOpts
)
{
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaOptions
*
pMetaOpt
ion
s
)
{
SMeta
*
pMeta
=
NULL
;
SMeta
*
pMeta
=
NULL
;
pMeta
=
(
SMeta
*
)
calloc
(
1
,
sizeof
(
*
pMeta
));
// Set default options
if
(
pMetaOptions
==
NULL
)
{
pMetaOptions
=
&
defaultMetaOptions
;
}
// Validate the options
if
(
metaValidateOptions
(
pMetaOptions
)
<
0
)
{
// TODO: deal with error
return
NULL
;
}
// Allocate handle
pMeta
=
metaNew
(
path
,
pMetaOptions
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
// TODO: handle error
return
NULL
;
}
// Create META path
taosMkDir
(
path
);
// Open the DBs needed
if
(
metaOpenDB
(
pMeta
)
<
0
)
{
// TODO: handle error
metaFree
(
pMeta
);
return
NULL
;
return
NULL
;
}
}
// TODO: check if file exists and handle the error
taosMkDir
(
"meta"
);
// Open tableDb
STkvOpts
*
tableDbOpts
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
tableDbOpts
,
1
);
pMeta
->
tableDb
=
tkvOpen
(
tableDbOpts
,
"meta/table_db"
);
tkvOptsDestroy
(
tableDbOpts
);
// Open tbnameDb
STkvOpts
*
tbnameDbOpts
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
tbnameDbOpts
,
1
);
pMeta
->
tbnameDb
=
tkvOpen
(
tbnameDbOpts
,
"meta/tbname_db"
);
tkvOptsDestroy
(
tbnameDbOpts
);
// Open schemaDb
STkvOpts
*
schemaDbOpts
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
schemaDbOpts
,
1
);
pMeta
->
schemaDb
=
tkvOpen
(
schemaDbOpts
,
"meta/schema_db"
);
tkvOptsDestroy
(
schemaDbOpts
);
// Open tagDb
STkvOpts
*
tagDbOpts
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
tagDbOpts
,
1
);
pMeta
->
tagDb
=
tkvOpen
(
tagDbOpts
,
"meta/tag_db"
);
tkvOptsDestroy
(
tagDbOpts
);
// Open tagIdx
STkvOpts
*
tagIdxDbOpts
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
tagIdxDbOpts
,
1
);
pMeta
->
tagIdx
=
tkvOpen
(
tagIdxDbOpts
,
"meta/tag_idx_db"
);
tkvOptsDestroy
(
tagIdxDbOpts
);
// TODO: need to figure out how to persist the START UID
tableUidGeneratorInit
(
&
(
pMeta
->
uidGenerator
),
IVLD_TB_UID
);
return
pMeta
;
return
pMeta
;
}
}
void
metaClose
(
SMeta
*
pMeta
)
{
void
metaClose
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
if
(
pMeta
)
{
tableUidGeneratorClear
(
&
pMeta
->
uidGenerator
);
tableUidGeneratorClear
(
&
pMeta
->
uidGenerator
);
metaCloseDB
(
pMeta
);
tkvClose
(
pMeta
->
tagIdx
);
tkvClose
(
pMeta
->
tagDb
);
tkvClose
(
pMeta
->
schemaDb
);
tkvClose
(
pMeta
->
tbnameDb
);
tkvClose
(
pMeta
->
tableDb
);
free
(
pMeta
);
free
(
pMeta
);
}
}
}
}
#if 0
int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
size_t vallen;
size_t vallen;
char * pUid;
char * pUid;
...
@@ -106,8 +94,37 @@ int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
...
@@ -106,8 +94,37 @@ int metaCreateTable(SMeta *pMeta, const STableOptions *pTableOpts) {
return 0;
return 0;
}
}
#endif
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMetaOptions
*
pMetaOptions
)
{
SMeta
*
pMeta
;
size_t
psize
=
strlen
(
path
);
pMeta
=
(
SMeta
*
)
calloc
(
1
,
sizeof
(
*
pMeta
));
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
pMeta
->
path
=
strdup
(
path
);
if
(
pMeta
->
path
==
NULL
)
{
return
NULL
;
}
metaOptionsCopy
(
&
(
pMeta
->
options
),
pMetaOptions
);
return
pMeta
;
};
static
void
metaFree
(
SMeta
*
pMeta
)
{
if
(
pMeta
)
{
tfree
(
pMeta
->
path
);
free
(
pMeta
);
}
}
// OLD -------------------------------------------------------------------
#if 0
static int metaCreateSuperTable(SMeta *pMeta, const char *tbname, const SSuperTableOpts *pSuperTableOpts) {
static int metaCreateSuperTable(SMeta *pMeta, const char *tbname, const SSuperTableOpts *pSuperTableOpts) {
size_t vallen;
size_t vallen;
size_t keylen;
size_t keylen;
...
@@ -258,3 +275,5 @@ void metaTableOptsClear(STableOptions *pTableOpts) {
...
@@ -258,3 +275,5 @@ void metaTableOptsClear(STableOptions *pTableOpts) {
}
}
void metaDestroy(const char *path) { taosRemoveDir(path); }
void metaDestroy(const char *path) { taosRemoveDir(path); }
#endif
\ No newline at end of file
source/dnode/vnode/meta/src/metaOptions.c
浏览文件 @
e9bf4fce
...
@@ -26,5 +26,11 @@ void metaOptionsClear(SMetaOptions *pMetaOptions) {
...
@@ -26,5 +26,11 @@ void metaOptionsClear(SMetaOptions *pMetaOptions) {
// TODO
// TODO
}
}
/* ------------------------ STATIC METHODS ------------------------ */
int
metaValidateOptions
(
const
SMetaOptions
*
pMetaOptions
)
{
static
void
metaOptionsCopy
(
SMetaOptions
*
pDest
,
const
SMetaOptions
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
*
pSrc
));
}
// TODO
\ No newline at end of file
return
0
;
}
void
metaOptionsCopy
(
SMetaOptions
*
pDest
,
const
SMetaOptions
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
*
pSrc
));
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/dnode/vnode/meta/src/metaTbOptions.c
0 → 100644
浏览文件 @
e9bf4fce
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
source/dnode/vnode/meta/src/metaUid.c
浏览文件 @
e9bf4fce
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
#include "metaUid.h"
#include "metaUid.h"
tb_uid_t
generateUid
(
ST
able
UidGenerator
*
pGen
)
{
tb_uid_t
generateUid
(
ST
b
UidGenerator
*
pGen
)
{
// Generate a new table UID
// Generate a new table UID
return
++
(
pGen
->
nextUid
);
return
++
(
pGen
->
nextUid
);
}
}
void
tableUidGeneratorInit
(
ST
able
UidGenerator
*
pGen
,
tb_uid_t
suid
)
{
void
tableUidGeneratorInit
(
ST
b
UidGenerator
*
pGen
,
tb_uid_t
suid
)
{
// Init a generator
// Init a generator
pGen
->
nextUid
=
suid
;
pGen
->
nextUid
=
suid
;
}
}
\ No newline at end of file
source/dnode/vnode/meta/test/CMakeLists.txt
浏览文件 @
e9bf4fce
add_executable
(
metaTest
""
)
# add_executable(metaTest "")
target_sources
(
metaTest
# target_sources(metaTest
PRIVATE
# PRIVATE
"../src/metaMain.c"
# "../src/metaMain.c"
"../src/metaUid.c"
# "../src/metaUid.c"
"metaTests.cpp"
# "metaTests.cpp"
)
# )
target_include_directories
(
metaTest
# target_include_directories(metaTest
PUBLIC
# PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/vnode/meta"
# "${CMAKE_SOURCE_DIR}/include/server/vnode/meta"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
# "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
# )
target_link_libraries
(
metaTest
# target_link_libraries(metaTest
os
# os
util
# util
common
# common
gtest_main
# gtest_main
tkv
# tkv
)
# )
enable_testing
()
# enable_testing()
add_test
(
# add_test(
NAME meta_test
# NAME meta_test
COMMAND metaTest
# COMMAND metaTest
)
# )
\ No newline at end of file
\ No newline at end of file
source/os/src/osDir.c
浏览文件 @
e9bf4fce
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
bool
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
)
==
0
;
}
bool
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
)
==
0
;
}
bool
taosMkDir
(
char
*
dirname
)
{
bool
taosMkDir
(
c
onst
c
har
*
dirname
)
{
int32_t
code
=
mkdir
(
dirname
,
0755
);
int32_t
code
=
mkdir
(
dirname
,
0755
);
if
(
code
<
0
&&
errno
==
EEXIST
)
{
if
(
code
<
0
&&
errno
==
EEXIST
)
{
return
true
;
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录