Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d9343722
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
d9343722
编写于
1月 10, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/tkv' of
https://github.com/taosdata/TDengine
into feature/vnode
上级
788ecf5e
dc98029b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
69 addition
and
184 deletion
+69
-184
include/libs/tkv/tkv.h
include/libs/tkv/tkv.h
+2
-0
include/os/osFile.h
include/os/osFile.h
+1
-1
source/libs/tkv/CMakeLists.txt
source/libs/tkv/CMakeLists.txt
+1
-7
source/libs/tkv/inc/tDiskMgr.h
source/libs/tkv/inc/tDiskMgr.h
+22
-1
source/libs/tkv/inc/tkvMacro.h
source/libs/tkv/inc/tkvMacro.h
+3
-3
source/libs/tkv/src/tDiskMgr.c
source/libs/tkv/src/tDiskMgr.c
+39
-0
source/libs/tkv/src/tkv.c
source/libs/tkv/src/tkv.c
+0
-171
source/os/src/osFile.c
source/os/src/osFile.c
+1
-1
未找到文件。
include/libs/tkv/tkv.h
浏览文件 @
d9343722
...
...
@@ -16,6 +16,7 @@
#ifndef _TD_TKV_H_
#define _TD_TKV_H_
#if 0
#include "os.h"
#ifdef __cplusplus
...
...
@@ -59,4 +60,5 @@ void tkvWriteOptsDestroy(STkvWriteOpts *);
}
#endif
#endif
#endif
/*_TD_TKV_H_*/
\ No newline at end of file
include/os/osFile.h
浏览文件 @
d9343722
...
...
@@ -54,7 +54,7 @@ int32_t taosFtruncateFile(FileFd fd, int64_t length);
int32_t
taosFsyncFile
(
FileFd
fd
);
int64_t
taosReadFile
(
FileFd
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosWriteFile
(
FileFd
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosWriteFile
(
FileFd
fd
,
const
void
*
buf
,
int64_t
count
);
void
taosCloseFile
(
FileFd
fd
);
...
...
source/libs/tkv/CMakeLists.txt
浏览文件 @
d9343722
...
...
@@ -8,10 +8,4 @@ target_include_directories(
target_link_libraries
(
tkv
PUBLIC os
)
if
(
${
BUILD_WITH_ROCKSDB
}
)
target_link_libraries
(
tkv
PUBLIC rocksdb
)
endif
(
${
BUILD_WITH_ROCKSDB
}
)
)
\ No newline at end of file
source/libs/tkv/
src/tkvRocksdb.c
→
source/libs/tkv/
inc/tDiskMgr.h
浏览文件 @
d9343722
...
...
@@ -11,4 +11,25 @@
*
* 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
*/
#ifndef _TD_TDISK_MGR_H_
#define _TD_TDISK_MGR_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include "os.h"
typedef
struct
SDiskMgr
SDiskMgr
;
int
tdmReadPage
(
SDiskMgr
*
pDiskMgr
,
int32_t
pgid
,
void
*
pData
);
int
tdmWritePage
(
SDiskMgr
*
pDiskMgr
,
int32_t
pgid
,
const
void
*
pData
);
int32_t
tdmAllocPage
(
SDiskMgr
*
pDiskMgr
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TDISK_MGR_H_*/
\ No newline at end of file
source/libs/tkv/inc/tkv
Rocksdb
.h
→
source/libs/tkv/inc/tkv
Macro
.h
浏览文件 @
d9343722
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_T
VK_ROCKSDB
_H_
#define _TD_T
VK_ROCKSDB
_H_
#ifndef _TD_T
KV_MACRO
_H_
#define _TD_T
KV_MACRO
_H_
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -24,4 +24,4 @@ extern "C" {
}
#endif
#endif
/*_TD_TVK_ROCKSDB_H_*/
\ No newline at end of file
#endif
/*_TD_TKV_MACRO_H_*/
\ No newline at end of file
source/libs/tkv/
inc/tkvDef.h
→
source/libs/tkv/
src/tDiskMgr.c
浏览文件 @
d9343722
...
...
@@ -13,46 +13,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TKV_DEF_H_
#define _TD_TKV_DEF_H_
#include "tDiskMgr.h"
#ifdef USE_ROCKSDB
#include <rocksdb/c.h>
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
struct
STkvDb
{
#ifdef USE_ROCKSDB
rocksdb_t
*
db
;
#endif
};
struct
STkvOpts
{
#ifdef USE_ROCKSDB
rocksdb_options_t
*
opts
;
#endif
};
struct
STkvCache
{
// TODO
struct
SDiskMgr
{
const
char
*
fname
;
uint16_t
pgsize
;
FileFd
fd
;
int32_t
npgid
;
};
struct
STkvReadOpts
{
#ifdef USE_ROCKSDB
rocksdb_readoptions_t
*
ropts
;
#endif
};
#define PAGE_OFFSET(PGID, PGSIZE) ((PGID) * (PGSIZE))
struct
STkvWriteOpts
{
#ifdef USE_ROCKSDB
rocksdb_writeoptions_t
*
wopts
;
#endif
}
;
int
tdmReadPage
(
SDiskMgr
*
pDiskMgr
,
int32_t
pgid
,
void
*
pData
)
{
taosLSeekFile
(
pDiskMgr
->
fd
,
PAGE_OFFSET
(
pgid
,
pDiskMgr
->
pgsize
),
SEEK_SET
);
taosReadFile
(
pDiskMgr
->
fd
,
pData
,
pDiskMgr
->
pgsize
)
;
return
0
;
}
#ifdef __cplusplus
int
tdmWritePage
(
SDiskMgr
*
pDiskMgr
,
int32_t
pgid
,
const
void
*
pData
)
{
taosLSeekFile
(
pDiskMgr
->
fd
,
PAGE_OFFSET
(
pgid
,
pDiskMgr
->
pgsize
),
SEEK_SET
);
taosWriteFile
(
pDiskMgr
->
fd
,
pData
,
pDiskMgr
->
pgsize
);
return
0
;
}
#endif
#endif
/*_TD_TKV_DEF_H_*/
\ No newline at end of file
int32_t
tdmAllocPage
(
SDiskMgr
*
pDiskMgr
)
{
return
pDiskMgr
->
npgid
++
;
}
\ No newline at end of file
source/libs/tkv/src/tkv.c
已删除
100644 → 0
浏览文件 @
788ecf5e
/*
* 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 "tkv.h"
#include "tkvDef.h"
static
pthread_once_t
isInit
=
PTHREAD_ONCE_INIT
;
static
STkvReadOpts
defaultReadOpts
;
static
STkvWriteOpts
defaultWriteOpts
;
static
void
tkvInit
();
STkvDb
*
tkvOpen
(
const
STkvOpts
*
options
,
const
char
*
path
)
{
pthread_once
(
&
isInit
,
tkvInit
);
STkvDb
*
pDb
=
NULL
;
pDb
=
(
STkvDb
*
)
malloc
(
sizeof
(
*
pDb
));
if
(
pDb
==
NULL
)
{
return
NULL
;
}
#ifdef USE_ROCKSDB
char
*
err
=
NULL
;
pDb
->
db
=
rocksdb_open
(
options
->
opts
,
path
,
&
err
);
// TODO: check err
#endif
return
pDb
;
}
void
tkvClose
(
STkvDb
*
pDb
)
{
if
(
pDb
)
{
#ifdef USE_ROCKSDB
rocksdb_close
(
pDb
->
db
);
#endif
free
(
pDb
);
}
}
void
tkvPut
(
STkvDb
*
pDb
,
const
STkvWriteOpts
*
pwopts
,
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
)
{
#ifdef USE_ROCKSDB
char
*
err
=
NULL
;
rocksdb_put
(
pDb
->
db
,
pwopts
?
pwopts
->
wopts
:
defaultWriteOpts
.
wopts
,
key
,
keylen
,
val
,
vallen
,
&
err
);
// TODO: check error
#endif
}
char
*
tkvGet
(
STkvDb
*
pDb
,
const
STkvReadOpts
*
propts
,
const
char
*
key
,
size_t
keylen
,
size_t
*
vallen
)
{
char
*
ret
=
NULL
;
#ifdef USE_ROCKSDB
char
*
err
=
NULL
;
ret
=
rocksdb_get
(
pDb
->
db
,
propts
?
propts
->
ropts
:
defaultReadOpts
.
ropts
,
key
,
keylen
,
vallen
,
&
err
);
// TODD: check error
#endif
return
ret
;
}
STkvOpts
*
tkvOptsCreate
()
{
STkvOpts
*
pOpts
=
NULL
;
pOpts
=
(
STkvOpts
*
)
malloc
(
sizeof
(
*
pOpts
));
if
(
pOpts
==
NULL
)
{
return
NULL
;
}
#ifdef USE_ROCKSDB
pOpts
->
opts
=
rocksdb_options_create
();
// TODO: check error
#endif
return
pOpts
;
}
void
tkvOptsDestroy
(
STkvOpts
*
pOpts
)
{
if
(
pOpts
)
{
#ifdef USE_ROCKSDB
rocksdb_options_destroy
(
pOpts
->
opts
);
#endif
free
(
pOpts
);
}
}
void
tkvOptionsSetCache
(
STkvOpts
*
popts
,
STkvCache
*
pCache
)
{
// TODO
}
void
tkvOptsSetCreateIfMissing
(
STkvOpts
*
pOpts
,
unsigned
char
c
)
{
#ifdef USE_ROCKSDB
rocksdb_options_set_create_if_missing
(
pOpts
->
opts
,
c
);
#endif
}
STkvReadOpts
*
tkvReadOptsCreate
()
{
STkvReadOpts
*
pReadOpts
=
NULL
;
pReadOpts
=
(
STkvReadOpts
*
)
malloc
(
sizeof
(
*
pReadOpts
));
if
(
pReadOpts
==
NULL
)
{
return
NULL
;
}
#ifdef USE_ROCKSDB
pReadOpts
->
ropts
=
rocksdb_readoptions_create
();
#endif
return
pReadOpts
;
}
void
tkvReadOptsDestroy
(
STkvReadOpts
*
pReadOpts
)
{
if
(
pReadOpts
)
{
#ifdef USE_ROCKSDB
rocksdb_readoptions_destroy
(
pReadOpts
->
ropts
);
#endif
free
(
pReadOpts
);
}
}
STkvWriteOpts
*
tkvWriteOptsCreate
()
{
STkvWriteOpts
*
pWriteOpts
=
NULL
;
pWriteOpts
=
(
STkvWriteOpts
*
)
malloc
(
sizeof
(
*
pWriteOpts
));
if
(
pWriteOpts
==
NULL
)
{
return
NULL
;
}
#ifdef USE_ROCKSDB
pWriteOpts
->
wopts
=
rocksdb_writeoptions_create
();
#endif
return
pWriteOpts
;
}
void
tkvWriteOptsDestroy
(
STkvWriteOpts
*
pWriteOpts
)
{
if
(
pWriteOpts
)
{
#ifdef USE_ROCKSDB
rocksdb_writeoptions_destroy
(
pWriteOpts
->
wopts
);
#endif
free
(
pWriteOpts
);
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static
void
tkvInit
()
{
#ifdef USE_ROCKSDB
defaultReadOpts
.
ropts
=
rocksdb_readoptions_create
();
defaultWriteOpts
.
wopts
=
rocksdb_writeoptions_create
();
rocksdb_writeoptions_disable_WAL
(
defaultWriteOpts
.
wopts
,
true
);
#endif
}
static
void
tkvClear
()
{
#ifdef USE_ROCKSDB
rocksdb_readoptions_destroy
(
defaultReadOpts
.
ropts
);
rocksdb_writeoptions_destroy
(
defaultWriteOpts
.
wopts
);
#endif
}
source/os/src/osFile.c
浏览文件 @
d9343722
...
...
@@ -120,7 +120,7 @@ int64_t taosReadFile(FileFd fd, void *buf, int64_t count) {
return
count
;
}
int64_t
taosWriteFile
(
FileFd
fd
,
void
*
buf
,
int64_t
n
)
{
int64_t
taosWriteFile
(
FileFd
fd
,
const
void
*
buf
,
int64_t
n
)
{
int64_t
nleft
=
n
;
int64_t
nwritten
=
0
;
char
*
tbuf
=
(
char
*
)
buf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录