Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dca02a85
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
dca02a85
编写于
1月 10, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tkv
上级
358b5641
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
128 addition
and
23 deletion
+128
-23
source/libs/tkv/CMakeLists.txt
source/libs/tkv/CMakeLists.txt
+1
-0
source/libs/tkv/inc/tkvBufPool.h
source/libs/tkv/inc/tkvBufPool.h
+39
-0
source/libs/tkv/inc/tkvDef.h
source/libs/tkv/inc/tkvDef.h
+3
-0
source/libs/tkv/inc/tkvDiskMgr.h
source/libs/tkv/inc/tkvDiskMgr.h
+8
-8
source/libs/tkv/inc/tkvPage.h
source/libs/tkv/inc/tkvPage.h
+14
-6
source/libs/tkv/src/tDiskMgr.c
source/libs/tkv/src/tDiskMgr.c
+9
-9
source/libs/tkv/src/tkvBufPool.c
source/libs/tkv/src/tkvBufPool.c
+54
-0
未找到文件。
source/libs/tkv/CMakeLists.txt
浏览文件 @
dca02a85
...
...
@@ -8,4 +8,5 @@ target_include_directories(
target_link_libraries
(
tkv
PUBLIC os
PUBLIC util
)
\ No newline at end of file
source/libs/tkv/inc/tkvBufPool.h
0 → 100644
浏览文件 @
dca02a85
/*
* 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_BUF_POOL_H_
#define _TD_TKV_BUF_POOL_H_
#include "tkvPage.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
STkvBufPool
STkvBufPool
;
int
tbpOpen
(
STkvBufPool
**
ppTkvBufPool
);
int
tbpClose
(
STkvBufPool
*
pTkvBufPool
);
STkvPage
*
tbpNewPage
(
STkvBufPool
*
pTkvBufPool
);
int
tbpDelPage
(
STkvBufPool
*
pTkvBufPool
);
STkvPage
*
tbpFetchPage
(
STkvBufPool
*
pTkvBufPool
,
pgid_t
pgid
);
int
tbpUnpinPage
(
STkvBufPool
*
pTkvBufPool
,
pgid_t
pgid
);
void
tbpFlushPages
(
STkvBufPool
*
pTkvBufPool
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TKV_BUF_POOL_H_*/
\ No newline at end of file
source/libs/tkv/inc/tkvDef.h
浏览文件 @
dca02a85
...
...
@@ -26,6 +26,9 @@ extern "C" {
typedef
int32_t
pgid_t
;
#define TKV_IVLD_PGID ((pgid_t)-1)
// framd_id_t
typedef
int32_t
frame_id_t
;
#ifdef __cplusplus
}
#endif
...
...
source/libs/tkv/inc/tDiskMgr.h
→
source/libs/tkv/inc/t
kv
DiskMgr.h
浏览文件 @
dca02a85
...
...
@@ -24,14 +24,14 @@ extern "C" {
#include "tkvDef.h"
typedef
struct
S
DiskMgr
S
DiskMgr
;
int
tdmOpen
(
SDiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
);
int
tdmClose
(
SDiskMgr
*
pDiskMgr
);
int
tdmReadPage
(
SDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
void
*
pData
);
int
tdmWritePage
(
SDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
const
void
*
pData
);
int
tdmFlush
(
SDiskMgr
*
pDiskMgr
);
pgid_t
tdmAllocPage
(
SDiskMgr
*
pDiskMgr
);
typedef
struct
S
TkvDiskMgr
STkv
DiskMgr
;
int
tdmOpen
(
S
Tkv
DiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
);
int
tdmClose
(
S
Tkv
DiskMgr
*
pDiskMgr
);
int
tdmReadPage
(
S
Tkv
DiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
void
*
pData
);
int
tdmWritePage
(
S
Tkv
DiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
const
void
*
pData
);
int
tdmFlush
(
S
Tkv
DiskMgr
*
pDiskMgr
);
pgid_t
tdmAllocPage
(
S
Tkv
DiskMgr
*
pDiskMgr
);
#ifdef __cplusplus
}
...
...
source/libs/tkv/inc/tPage.h
→
source/libs/tkv/inc/t
kv
Page.h
浏览文件 @
dca02a85
...
...
@@ -17,22 +17,30 @@
#define _TD_TKV_PAGE_H_
#include "os.h"
#include "tkvDef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
STkvPage
{
pgid_t
pgid
;
int32_t
pinCount
;
bool
idDirty
;
char
*
pData
;
}
STkvPage
;
typedef
struct
{
uint16_t
dbver
;
uint16_t
pgsize
;
uint32_t
cksm
;
}
SPgHdr
;
}
S
Tkv
PgHdr
;
typedef
struct
{
SPgHdr
chdr
;
uint16_t
used
;
// number of used slots
uint16_t
loffset
;
// the offset of the starting location of the last slot used
}
SSlottedPgHdr
;
//
typedef struct {
//
SPgHdr chdr;
//
uint16_t used; // number of used slots
//
uint16_t loffset; // the offset of the starting location of the last slot used
//
} SSlottedPgHdr;
#ifdef __cplusplus
}
...
...
source/libs/tkv/src/tDiskMgr.c
浏览文件 @
dca02a85
...
...
@@ -13,9 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tDiskMgr.h"
#include "t
kv
DiskMgr.h"
struct
SDiskMgr
{
struct
S
Tkv
DiskMgr
{
char
*
fname
;
uint16_t
pgsize
;
FileFd
fd
;
...
...
@@ -24,8 +24,8 @@ struct SDiskMgr {
#define PAGE_OFFSET(PGID, PGSIZE) ((PGID) * (PGSIZE))
int
tdmOpen
(
SDiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
)
{
SDiskMgr
*
pDiskMgr
;
int
tdmOpen
(
S
Tkv
DiskMgr
**
ppDiskMgr
,
const
char
*
fname
,
uint16_t
pgsize
)
{
S
Tkv
DiskMgr
*
pDiskMgr
;
pDiskMgr
=
malloc
(
sizeof
(
*
pDiskMgr
));
if
(
pDiskMgr
==
NULL
)
{
...
...
@@ -50,25 +50,25 @@ int tdmOpen(SDiskMgr **ppDiskMgr, const char *fname, uint16_t pgsize) {
return
0
;
}
int
tdmClose
(
SDiskMgr
*
pDiskMgr
)
{
int
tdmClose
(
S
Tkv
DiskMgr
*
pDiskMgr
)
{
close
(
pDiskMgr
->
fd
);
free
(
pDiskMgr
->
fname
);
free
(
pDiskMgr
);
return
0
;
}
int
tdmReadPage
(
SDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
void
*
pData
)
{
int
tdmReadPage
(
S
Tkv
DiskMgr
*
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
(
SDiskMgr
*
pDiskMgr
,
pgid_t
pgid
,
const
void
*
pData
)
{
int
tdmWritePage
(
S
Tkv
DiskMgr
*
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
(
SDiskMgr
*
pDiskMgr
)
{
return
taosFsyncFile
(
pDiskMgr
->
fd
);
}
int
tdmFlush
(
S
Tkv
DiskMgr
*
pDiskMgr
)
{
return
taosFsyncFile
(
pDiskMgr
->
fd
);
}
int32_t
tdmAllocPage
(
SDiskMgr
*
pDiskMgr
)
{
return
pDiskMgr
->
npgid
++
;
}
\ No newline at end of file
int32_t
tdmAllocPage
(
STkvDiskMgr
*
pDiskMgr
)
{
return
pDiskMgr
->
npgid
++
;
}
\ No newline at end of file
source/libs/tkv/src/tkvBufPool.c
0 → 100644
浏览文件 @
dca02a85
/*
* 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 "thash.h"
#include "tlist.h"
#include "tkvBufPool.h"
#include "tkvDiskMgr.h"
#include "tkvPage.h"
struct
SFrameIdWrapper
{
TD_SLIST_NODE
(
SFrameIdWrapper
);
frame_id_t
id
;
};
struct
STkvBufPool
{
STkvPage
*
pages
;
STkvDiskMgr
*
pDiskMgr
;
SHashObj
*
pgTb
;
// page_id_t --> frame_id_t
TD_SLIST
(
SFrameIdWrapper
)
freeList
;
pthread_mutex_t
mutex
;
};
typedef
struct
STkvLRUReplacer
{
}
STkvLRUReplacer
;
typedef
struct
STkvLFUReplacer
{
}
STkvLFUReplacer
;
typedef
struct
STkvCLKReplacer
{
}
STkvCLKReplacer
;
typedef
enum
{
TKV_LRU_REPLACER
=
0
,
TKV_LFU_REPLACER
,
TVK_CLK_REPLACER
}
tkv_replacer_t
;
typedef
struct
STkvReplacer
{
tkv_replacer_t
type
;
union
{
STkvLRUReplacer
lruRep
;
STkvLFUReplacer
lfuRep
;
STkvCLKReplacer
clkRep
;
};
}
STkvReplacer
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录