Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9e34770d
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看板
提交
9e34770d
编写于
2月 16, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
87dfa6ce
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
96 deletion
+22
-96
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+7
-5
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+13
-19
source/libs/tdb/src/db/tdbJournal.c
source/libs/tdb/src/db/tdbJournal.c
+0
-34
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+2
-2
source/libs/tdb/src/inc/tdbJournal.h
source/libs/tdb/src/inc/tdbJournal.h
+0
-36
未找到文件。
source/libs/tdb/src/db/tdb.c
浏览文件 @
9e34770d
...
...
@@ -104,17 +104,19 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
}
}
// TODO: open the database (an existing or a new one)
if
(
0
)
{
// Search the page file master DB to check if the db exists
// If exists, run this branch (TODO)
}
else
{
// TODO: get the root page number from the master DB of the page file
// tdbGet(&dbRootPgno);
if
(
dbRootPgno
==
0
)
{
// DB not exist, create one
ret
=
pgFileAllocatePage
(
pPgFile
,
&
dbRootPgno
);
if
(
ret
!=
0
)
{
// TODO: handle error
}
// tdbInsert(pPgFile->pMasterDB, dbname, strlen(dbname), &dbRootPgno, sizeof(dbRootPgno));
}
ASSERT
(
dbRootPgno
>
1
);
// pDb->pBt->root = dbRootPgno;
// register
...
...
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
9e34770d
...
...
@@ -17,6 +17,8 @@
struct
STDbEnv
{
char
*
rootDir
;
// root directory of the environment
char
*
jname
;
// journal file name
int
jfd
;
// journal file fd
pgsz_t
pgSize
;
// page size
cachesz_t
cacheSize
;
// total cache size
STDbList
dbList
;
// TDB List
...
...
@@ -26,7 +28,6 @@ struct STDbEnv {
#define TDB_ENV_PGF_HASH_BUCKETS 17
SPgFileList
buckets
[
TDB_ENV_PGF_HASH_BUCKETS
];
}
pgfht
;
// page file hash table;
SJournal
*
pJournal
;
};
#define TDB_ENV_PGF_HASH(fileid) \
...
...
@@ -40,22 +41,27 @@ static int tdbEnvDestroy(TENV *pEnv);
int
tdbEnvCreate
(
TENV
**
ppEnv
,
const
char
*
rootDir
)
{
TENV
*
pEnv
;
size_t
slen
;
size_t
jlen
;
ASSERT
(
rootDir
!=
NULL
);
*
ppEnv
=
NULL
;
slen
=
strlen
(
rootDir
);
pEnv
=
(
TENV
*
)
calloc
(
1
,
sizeof
(
*
pEnv
)
+
sizeof
(
SJournal
)
+
slen
+
1
);
jlen
=
slen
+
strlen
(
TDB_JOURNAL_NAME
)
+
1
;
pEnv
=
(
TENV
*
)
calloc
(
1
,
sizeof
(
*
pEnv
)
+
slen
+
1
+
jlen
+
1
);
if
(
pEnv
==
NULL
)
{
return
-
1
;
}
pEnv
->
rootDir
=
(
char
*
)(
&
pEnv
[
1
])
+
sizeof
(
SJournal
);
pEnv
->
rootDir
=
(
char
*
)(
&
pEnv
[
1
]);
pEnv
->
jname
=
pEnv
->
rootDir
+
slen
+
1
;
pEnv
->
jfd
=
-
1
;
pEnv
->
pgSize
=
TDB_DEFAULT_PGSIZE
;
pEnv
->
cacheSize
=
TDB_DEFAULT_CACHE_SIZE
;
memcpy
(
pEnv
->
rootDir
,
rootDir
,
slen
);
pEnv
->
rootDir
[
slen
]
=
'\0'
;
sprintf
(
pEnv
->
jname
,
"%s/%s"
,
rootDir
,
TDB_JOURNAL_NAME
);
TD_DLIST_INIT
(
&
(
pEnv
->
dbList
));
TD_DLIST_INIT
(
&
(
pEnv
->
pgfList
));
...
...
@@ -133,30 +139,18 @@ static int tdbEnvDestroy(TENV *pEnv) {
}
int
tdbEnvBeginTxn
(
TENV
*
pEnv
)
{
SJournal
*
pJournal
;
int
ret
;
ASSERT
(
pEnv
->
pJournal
==
NULL
);
pJournal
=
(
SJournal
*
)(
&
(
pEnv
[
1
]));
ret
=
tdbOpenJournal
(
pJournal
);
if
(
ret
<
0
)
{
// TODO: handle error
pEnv
->
jfd
=
open
(
pEnv
->
jname
,
O_CREAT
|
O_RDWR
,
0755
);
if
(
pEnv
->
jfd
<
0
)
{
return
-
1
;
}
pEnv
->
pJournal
=
pJournal
;
return
0
;
}
int
tdbEnvCommit
(
TENV
*
pEnv
)
{
SJournal
*
pJournal
;
ASSERT
(
pEnv
->
pJournal
!=
NULL
);
pJournal
=
pEnv
->
pJournal
;
tdbCloseJournal
(
pJournal
);
/* TODO */
close
(
pEnv
->
jfd
);
pEnv
->
jfd
=
-
1
;
return
0
;
}
...
...
source/libs/tdb/src/db/tdbJournal.c
已删除
100644 → 0
浏览文件 @
87dfa6ce
/*
* 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 "tdbInt.h"
int
tdbOpenJournal
(
SJournal
*
pJournal
)
{
TENV
*
pEnv
;
char
*
jname
;
pJournal
->
fd
=
open
(
jname
,
O_CREAT
|
O_RDWR
,
0755
);
if
(
pJournal
->
fd
<
0
)
{
// TODO: handle error
return
-
1
;
}
return
0
;
}
int
tdbCloseJournal
(
SJournal
*
pJournal
)
{
// TODO
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
9e34770d
...
...
@@ -115,6 +115,8 @@ typedef TD_DLIST_NODE(SPgFile) SPgFileListNode;
/* TODO */
\
} while (0)
#define TDB_JOURNAL_NAME "tdb.journal"
#include "tdbUtil.h"
#include "tdbBtree.h"
...
...
@@ -123,8 +125,6 @@ typedef TD_DLIST_NODE(SPgFile) SPgFileListNode;
#include "tdbPgFile.h"
#include "tdbJournal.h"
#include "tdbEnv.h"
#ifdef __cplusplus
...
...
source/libs/tdb/src/inc/tdbJournal.h
已删除
100644 → 0
浏览文件 @
87dfa6ce
/*
* 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 _TDB_JOURNAL_H_
#define _TDB_JOURNAL_H_
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SJournal
SJournal
;
struct
SJournal
{
char
jname
[
64
];
int
fd
;
};
int
tdbOpenJournal
(
SJournal
*
pJournal
);
int
tdbCloseJournal
(
SJournal
*
pJournal
);
#ifdef __cplusplus
}
#endif
#endif
/*_TDB_JOURNAL_H_*/
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录