Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c9cd5fce
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看板
提交
c9cd5fce
编写于
2月 15, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more TDB
上级
f77d33dc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
28 deletion
+32
-28
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+6
-3
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+1
-0
source/libs/tdb/src/db/tdbPgFile.c
source/libs/tdb/src/db/tdbPgFile.c
+20
-18
source/libs/tdb/src/inc/tdbPgFile.h
source/libs/tdb/src/inc/tdbPgFile.h
+5
-7
未找到文件。
source/libs/tdb/src/db/tdb.c
浏览文件 @
c9cd5fce
...
...
@@ -87,17 +87,20 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
pDb
->
dbname
[
dbNameLen
]
=
'\0'
;
// open pPgFile or get from the env
pPgFile
=
NULL
;
snprintf
(
dbfname
,
128
,
"%s/%s"
,
tdbEnvGetRootDir
(
pEnv
),
fname
);
fileExist
=
(
tdbCheckFileAccess
(
fname
,
TDB_F_OK
)
==
0
);
if
(
fileExist
)
{
// TODO
}
else
{
tdbGnrtFileID
(
dbfname
,
fileid
,
false
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
}
if
(
pPgFile
==
NULL
)
{
ret
=
pgFileOpen
(
&
pPgFile
,
dbfname
,
pEnv
);
if
(
ret
!=
0
)
{
// TODO: handle error
return
-
1
;
}
// Create and open the page file
}
#if 0
...
...
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
c9cd5fce
...
...
@@ -47,6 +47,7 @@ int tdbEnvCreate(TENV **ppEnv, const char *rootDir) {
pEnv
->
cacheSize
=
TDB_DEFAULT_CACHE_SIZE
;
memcpy
(
pEnv
->
rootDir
,
rootDir
,
slen
);
pEnv
->
rootDir
[
slen
]
=
'\0'
;
TD_DLIST_INIT
(
&
(
pEnv
->
dbList
));
TD_DLIST_INIT
(
&
(
pEnv
->
pgfList
));
...
...
source/libs/tdb/src/db/tdbPgFile.c
浏览文件 @
c9cd5fce
...
...
@@ -20,38 +20,35 @@ static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData);
int
pgFileOpen
(
SPgFile
**
ppPgFile
,
const
char
*
fname
,
TENV
*
pEnv
)
{
SPgFile
*
pPgFile
;
SPgCache
*
pPgCache
;
size_t
fnameLen
;
*
ppPgFile
=
NULL
;
pPgFile
=
(
SPgFile
*
)
calloc
(
1
,
sizeof
(
*
pPgFile
));
// create the handle
fnameLen
=
strlen
(
fname
);
pPgFile
=
(
SPgFile
*
)
calloc
(
1
,
sizeof
(
*
pPgFile
)
+
fnameLen
+
1
);
if
(
pPgFile
==
NULL
)
{
return
-
1
;
}
pPgFile
->
fd
=
-
1
;
pPgFile
->
fname
=
strdup
(
fname
);
if
(
pPgFile
->
fname
==
NULL
)
{
pgFileClose
(
pPgFile
);
return
-
1
;
}
ASSERT
(
pEnv
!=
NULL
);
pPgFile
->
pPgCache
=
pPgCache
;
// pPgFile->pgSize = ; (TODO)
// init the handle
pPgFile
->
pEnv
=
pEnv
;
pPgFile
->
fname
=
(
char
*
)(
&
(
pPgFile
[
1
]));
memcpy
(
pPgFile
->
fname
,
fname
,
fnameLen
);
pPgFile
->
fname
[
fnameLen
]
=
'\0'
;
pPgFile
->
fd
=
-
1
;
pPgFile
->
fd
=
open
(
fname
,
O_RDWR
,
0755
);
pPgFile
->
fd
=
open
(
fname
,
O_
CREAT
|
O_
RDWR
,
0755
);
if
(
pPgFile
->
fd
<
0
)
{
pgFileClose
(
pPgFile
);
// TODO: handle error
return
-
1
;
}
if
(
tdbGnrtFileID
(
fname
,
pPgFile
->
fileid
,
false
)
<
0
)
{
pgFileClose
(
pPgFile
);
return
-
1
;
}
tdbGnrtFileID
(
fname
,
pPgFile
->
fileid
,
false
);
// TODO: get file size
pPgFile
->
pgFileSize
=
0
;
/* TODO */
*
ppPgFile
=
pPgFile
;
return
0
;
...
...
@@ -75,6 +72,7 @@ SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) {
SPage
*
pPage
;
pgid_t
pgid
;
#if 0
pPgCache = pPgFile->pPgCache;
pPage = NULL;
memcpy(pgid.fileid, pPgFile->fileid, TDB_FILE_ID_LEN);
...
...
@@ -94,6 +92,7 @@ SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) {
return pPage;
}
}
#endif
return
pPage
;
}
...
...
@@ -114,6 +113,8 @@ static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData) {
uint8_t
*
pTData
;
size_t
szToRead
;
#if 0
// pgSize = ; (TODO)
pTData = pData;
szToRead = pgSize;
...
...
@@ -132,6 +133,7 @@ static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData) {
szToRead -= rsize;
pTData += rsize;
}
#endif
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/inc/tdbPgFile.h
浏览文件 @
c9cd5fce
...
...
@@ -33,13 +33,11 @@ typedef struct __attribute__((__packed__)) {
TDB_STATIC_ASSERT
(
sizeof
(
SPgFileHdr
)
==
TDB_PG_FILE_HDR_SIZE
,
"Page file header size if not 128"
);
struct
SPgFile
{
char
*
fname
;
// backend file name
uint8_t
fileid
[
TDB_FILE_ID_LEN
];
// file id
SPgCache
*
pPgCache
;
// page cache underline
pgsz_t
pgSize
;
int
fd
;
pgno_t
pgFileSize
;
TDB
*
pDb
;
// For a SPgFile for multiple databases, this is the <dbname, pgno> mapping DB.
TENV
*
pEnv
;
// env containing this page file
char
*
fname
;
// backend file name
uint8_t
fileid
[
TDB_FILE_ID_LEN
];
// file id
int
fd
;
// TDB * pDb; // For a SPgFile for multiple databases, this is the <dbname, pgno> mapping DB.
};
int
pgFileOpen
(
SPgFile
**
ppPgFile
,
const
char
*
fname
,
TENV
*
pEnv
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录