Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1793f616
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看板
提交
1793f616
编写于
1月 19, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
e26710bc
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
33 addition
and
337 deletion
+33
-337
source/libs/tdb/CMakeLists.txt
source/libs/tdb/CMakeLists.txt
+2
-2
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+19
-19
source/libs/tdb/src/db/tdbDB.c
source/libs/tdb/src/db/tdbDB.c
+3
-1
source/libs/tdb/src/devinc/tdb_inc.h
source/libs/tdb/src/devinc/tdb_inc.h
+0
-27
source/libs/tdb/src/dmgr/tdbDiskMgr.c
source/libs/tdb/src/dmgr/tdbDiskMgr.c
+0
-74
source/libs/tdb/src/inc/tdbBtree.h
source/libs/tdb/src/inc/tdbBtree.h
+0
-35
source/libs/tdb/src/inc/tdbDB.h
source/libs/tdb/src/inc/tdbDB.h
+5
-7
source/libs/tdb/src/inc/tdbDiskMgr.h
source/libs/tdb/src/inc/tdbDiskMgr.h
+0
-40
source/libs/tdb/src/inc/tdbHash.h
source/libs/tdb/src/inc/tdbHash.h
+0
-35
source/libs/tdb/src/inc/tdbHeap.h
source/libs/tdb/src/inc/tdbHeap.h
+0
-35
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+0
-43
source/libs/tdb/src/inc/tdb_inc.h
source/libs/tdb/src/inc/tdb_inc.h
+3
-4
source/libs/tdb/src/inc/tdb_mpfile.h
source/libs/tdb/src/inc/tdb_mpfile.h
+0
-0
source/libs/tdb/src/inc/tdb_mpool.h
source/libs/tdb/src/inc/tdb_mpool.h
+1
-1
source/libs/tdb/src/mpool/tdb_mpool.c
source/libs/tdb/src/mpool/tdb_mpool.c
+0
-14
未找到文件。
source/libs/tdb/CMakeLists.txt
浏览文件 @
1793f616
set
(
TDB_SUBDIRS
"
btree"
"db"
"hash"
"mpool"
"dmgr
"
)
set
(
TDB_SUBDIRS
"
db
"
)
foreach
(
TDB_SUBDIR
${
TDB_SUBDIRS
}
)
foreach
(
TDB_SUBDIR
${
TDB_SUBDIRS
}
)
aux_source_directory
(
"src/
${
TDB_SUBDIR
}
"
TDB_SRC
)
aux_source_directory
(
"src/
${
TDB_SUBDIR
}
"
TDB_SRC
)
endforeach
()
endforeach
()
...
@@ -18,5 +18,5 @@ target_link_libraries(
...
@@ -18,5 +18,5 @@ target_link_libraries(
)
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
#
add_subdirectory(test)
endif
(
${
BUILD_TEST
}
)
endif
(
${
BUILD_TEST
}
)
source/libs/tdb/inc/tdb.h
浏览文件 @
1793f616
...
@@ -22,29 +22,29 @@
...
@@ -22,29 +22,29 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define TDB_EXTERN
//
#define TDB_EXTERN
#define TDB_PUBLIC
//
#define TDB_PUBLIC
#define TDB_STATIC static
//
#define TDB_STATIC static
typedef
enum
{
TDB_BTREE_T
=
0
,
TDB_HASH_T
=
1
,
TDB_HEAP_T
=
2
}
tdb_db_t
;
//
typedef enum { TDB_BTREE_T = 0, TDB_HASH_T = 1, TDB_HEAP_T = 2 } tdb_db_t;
// Forward declarations
//
//
Forward declarations
typedef
struct
TDB
TDB
;
//
typedef struct TDB TDB;
// typedef struct TDB_MPOOL TDB_MPOOL;
//
//
typedef struct TDB_MPOOL TDB_MPOOL;
// typedef struct TDB_MPFILE TDB_MPFILE;
//
//
typedef struct TDB_MPFILE TDB_MPFILE;
// typedef struct TDB_CURSOR TDB_CURSOR;
//
//
typedef struct TDB_CURSOR TDB_CURSOR;
typedef
struct
{
//
typedef struct {
void
*
bdata
;
//
void* bdata;
uint32_t
size
;
//
uint32_t size;
}
TDB_KEY
,
TDB_VALUE
;
//
} TDB_KEY, TDB_VALUE;
// TDB Operations
//
//
TDB Operations
int
tdbCreateDB
(
TDB
**
dbpp
,
tdb_db_t
type
);
//
int tdbCreateDB(TDB** dbpp, tdb_db_t type);
int
tdbOpenDB
(
TDB
*
dbp
,
const
char
*
fname
,
const
char
*
dbname
,
uint32_t
flags
);
//
int tdbOpenDB(TDB* dbp, const char* fname, const char* dbname, uint32_t flags);
int
tdbCloseDB
(
TDB
*
dbp
,
uint32_t
flags
);
//
int tdbCloseDB(TDB* dbp, uint32_t flags);
int
tdbPut
(
TDB
*
dbp
,
const
TDB_KEY
*
key
,
const
TDB_VALUE
*
value
,
uint32_t
flags
);
//
int tdbPut(TDB* dbp, const TDB_KEY* key, const TDB_VALUE* value, uint32_t flags);
int
tdbGet
(
TDB
*
dbp
,
const
TDB_KEY
*
key
,
TDB_VALUE
*
value
,
uint32_t
flags
);
//
int tdbGet(TDB* dbp, const TDB_KEY* key, TDB_VALUE* value, uint32_t flags);
// // TDB_MPOOL
// // TDB_MPOOL
// int tdbOpenMPool(TDB_MPOOL** mp);
// int tdbOpenMPool(TDB_MPOOL** mp);
...
...
source/libs/tdb/src/db/tdbDB.c
浏览文件 @
1793f616
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#if 0
#include "tdbDB.h"
#include "tdbDB.h"
#include "tdb.h"
#include "tdb.h"
...
@@ -84,3 +85,4 @@ TDB_EXTERN int tdbCloseDB(TDB* dbp, uint32_t flags) {
...
@@ -84,3 +85,4 @@ TDB_EXTERN int tdbCloseDB(TDB* dbp, uint32_t flags) {
// TODO
// TODO
return 0;
return 0;
}
}
#endif
\ No newline at end of file
source/libs/tdb/src/devinc/tdb_inc.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TDB_INC_H_
#define _TD_TDB_INC_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDB_INC_H_*/
source/libs/tdb/src/dmgr/tdbDiskMgr.c
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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/>.
*/
#include "tdbDiskMgr.h"
struct
STkvDiskMgr
{
char
*
fname
;
uint16_t
pgsize
;
FileFd
fd
;
pgid_t
npgid
;
};
#define PAGE_OFFSET(PGID, PGSIZE) ((PGID) * (PGSIZE))
int
tdmOpen
(
STkvDiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
)
{
STkvDiskMgr
*
pDiskMgr
;
pDiskMgr
=
malloc
(
sizeof
(
*
pDiskMgr
));
if
(
pDiskMgr
==
NULL
)
{
return
-
1
;
}
pDiskMgr
->
fname
=
strdup
(
fname
);
if
(
pDiskMgr
->
fname
==
NULL
)
{
free
(
pDiskMgr
);
return
-
1
;
}
pDiskMgr
->
pgsize
=
pgsize
;
pDiskMgr
->
fd
=
open
(
fname
,
O_CREAT
|
O_RDWR
,
0755
);
if
(
pDiskMgr
->
fd
<
0
)
{
free
(
pDiskMgr
->
fname
);
free
(
pDiskMgr
);
return
-
1
;
}
*
ppDiskMgr
=
pDiskMgr
;
return
0
;
}
int
tdmClose
(
STkvDiskMgr
*
pDiskMgr
)
{
close
(
pDiskMgr
->
fd
);
free
(
pDiskMgr
->
fname
);
free
(
pDiskMgr
);
return
0
;
}
int
tdmReadPage
(
STkvDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
void
*
pData
)
{
taosLSeekFile
(
pDiskMgr
->
fd
,
PAGE_OFFSET
(
pgid
,
pDiskMgr
->
pgsize
),
SEEK_SET
);
taosReadFile
(
pDiskMgr
->
fd
,
pData
,
pDiskMgr
->
pgsize
);
return
0
;
}
int
tdmWritePage
(
STkvDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
const
void
*
pData
)
{
taosLSeekFile
(
pDiskMgr
->
fd
,
PAGE_OFFSET
(
pgid
,
pDiskMgr
->
pgsize
),
SEEK_SET
);
taosWriteFile
(
pDiskMgr
->
fd
,
pData
,
pDiskMgr
->
pgsize
);
return
0
;
}
int
tdmFlush
(
STkvDiskMgr
*
pDiskMgr
)
{
return
taosFsyncFile
(
pDiskMgr
->
fd
);
}
int32_t
tdmAllocPage
(
STkvDiskMgr
*
pDiskMgr
)
{
return
pDiskMgr
->
npgid
++
;
}
\ No newline at end of file
source/libs/tdb/src/inc/tdbBtree.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TDB_BTREE_H_
#define _TD_TDB_BTREE_H_
#include "tdbDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
pgid_t
root
;
// root page number
}
TDB_BTREE
;
TDB_PUBLIC
int
tdbInitBtreeDB
(
TDB
*
dbp
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDB_BTREE_H_*/
\ No newline at end of file
source/libs/tdb/src/inc/tdbDB.h
浏览文件 @
1793f616
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
#include "tdb.h"
#include "tdb.h"
#include "tdbBtree.h"
#include "tdbBtree.h"
#include "tdbHash.h"
#include "tdbHeap.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -34,11 +32,11 @@ struct TDB {
...
@@ -34,11 +32,11 @@ struct TDB {
tdb_db_t
type
;
tdb_db_t
type
;
char
*
fname
;
char
*
fname
;
char
*
dbname
;
char
*
dbname
;
union
{
//
union {
TDB_BTREE
*
btree
;
//
TDB_BTREE *btree;
TDB_HASH
*
hash
;
//
TDB_HASH * hash;
TDB_HEAP
*
heap
;
//
TDB_HEAP * heap;
}
dbam
;
// db access method
//
} dbam; // db access method
// TDB_FH * fhp; // The backup file handle
// TDB_FH * fhp; // The backup file handle
// TDB_MPOOL *mph; // The memory pool handle
// TDB_MPOOL *mph; // The memory pool handle
...
...
source/libs/tdb/src/inc/tdbDiskMgr.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TDISK_MGR_H_
#define _TD_TDISK_MGR_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include "os.h"
#include "tdbDef.h"
typedef
struct
STkvDiskMgr
STkvDiskMgr
;
int
tdmOpen
(
STkvDiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
);
int
tdmClose
(
STkvDiskMgr
*
pDiskMgr
);
int
tdmReadPage
(
STkvDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
void
*
pData
);
int
tdmWritePage
(
STkvDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
const
void
*
pData
);
int
tdmFlush
(
STkvDiskMgr
*
pDiskMgr
);
pgid_t
tdmAllocPage
(
STkvDiskMgr
*
pDiskMgr
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDISK_MGR_H_*/
\ No newline at end of file
source/libs/tdb/src/inc/tdbHash.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TDB_HASH_H_
#define _TD_TDB_HASH_H_
#include "tdbDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
// TODO
}
TDB_HASH
;
TDB_PUBLIC
int
tdbInitHashDB
(
TDB
*
dbp
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDB_HASH_H_*/
\ No newline at end of file
source/libs/tdb/src/inc/tdbHeap.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TDB_HEAP_H_
#define _TD_TDB_HEAP_H_
#include "tdbDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
// TODO
}
TDB_HEAP
;
TDB_PUBLIC
int
tdbInitHeapDB
(
TDB
*
dbp
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDB_HEAP_H_*/
\ No newline at end of file
source/libs/tdb/src/inc/tdbPage.h
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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_TKV_PAGE_H_
#define _TD_TKV_PAGE_H_
#include "os.h"
#include "tdbDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
pgid_t
pgid
;
int32_t
pinCount
;
bool
idDirty
;
char
*
pData
;
}
STdbPage
;
typedef
struct
{
uint16_t
dbver
;
uint16_t
pgsize
;
uint32_t
cksm
;
}
STdbPgHdr
;
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TKV_PAGE_H_*/
\ No newline at end of file
source/libs/tdb/src/inc/tdb
Def
.h
→
source/libs/tdb/src/inc/tdb
_inc
.h
浏览文件 @
1793f616
...
@@ -13,11 +13,10 @@
...
@@ -13,11 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef _TD_TDB_
DEF
_H_
#ifndef _TD_TDB_
INC
_H_
#define _TD_TDB_
DEF
_H_
#define _TD_TDB_
INC
_H_
#include "os.h"
#include "os.h"
#include "tlist.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -41,4 +40,4 @@ typedef int32_t pgsize_t;
...
@@ -41,4 +40,4 @@ typedef int32_t pgsize_t;
}
}
#endif
#endif
#endif
/*_TD_TDB_DEF_H_*/
#endif
/*_TD_TDB_INC_H_*/
\ No newline at end of file
source/libs/tdb/src/
dev
inc/tdb_mpfile.h
→
source/libs/tdb/src/inc/tdb_mpfile.h
浏览文件 @
1793f616
文件已移动
source/libs/tdb/src/
dev
inc/tdb_mpool.h
→
source/libs/tdb/src/inc/tdb_mpool.h
浏览文件 @
1793f616
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#ifndef _TD_TDB_MPOOL_H_
#ifndef _TD_TDB_MPOOL_H_
#define _TD_TDB_MPOOL_H_
#define _TD_TDB_MPOOL_H_
#include "tdb
Def
.h"
#include "tdb
_inc
.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
source/libs/tdb/src/mpool/tdb_mpool.c
已删除
100644 → 0
浏览文件 @
e26710bc
/*
* 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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录