Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9179423f
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看板
提交
9179423f
编写于
10月 12, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
fcd1de8f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
132 addition
and
31 deletion
+132
-31
CMakeLists.txt
CMakeLists.txt
+2
-1
include/libs/tkv/tkv.h
include/libs/tkv/tkv.h
+5
-4
source/libs/tkv/CMakeLists.txt
source/libs/tkv/CMakeLists.txt
+1
-1
source/libs/tkv/src/tkv.c
source/libs/tkv/src/tkv.c
+121
-23
source/server/vnode/meta/src/meta.c
source/server/vnode/meta/src/meta.c
+3
-2
未找到文件。
CMakeLists.txt
浏览文件 @
9179423f
...
...
@@ -42,9 +42,10 @@ if(${BUILD_WITH_LEVELDB})
endif
(
${
BUILD_WITH_LEVELDB
}
)
## rocksdb
option
(
BUILD_WITH_ROCKSDB
"If build with rocksdb"
O
FF
)
option
(
BUILD_WITH_ROCKSDB
"If build with rocksdb"
O
N
)
if
(
${
BUILD_WITH_ROCKSDB
}
)
cat
(
"
${
CMAKE_SUPPORT_DIR
}
/rocksdb_CMakeLists.txt.in"
${
DEPS_TMP_FILE
}
)
add_definitions
(
-DUSE_ROCKSDB
)
endif
(
${
BUILD_WITH_ROCKSDB
}
)
## download dependencies
...
...
include/libs/tkv/tkv.h
浏览文件 @
9179423f
...
...
@@ -32,13 +32,14 @@ typedef struct STkvWriteOpts STkvWriteOpts;
// DB operations
STkvDb
*
tkvOpen
(
const
STkvOpts
*
options
,
const
char
*
path
);
void
tkvClose
(
STkvDb
*
db
);
void
tkvPut
(
STkvDb
*
db
,
STkvWriteOpts
*
,
char
*
key
,
size_t
keylen
,
char
*
val
,
size_t
vallen
);
char
*
tkvGet
(
STkvDb
*
db
,
STkvReadOpts
*
,
char
*
key
,
size_t
keylen
,
size_t
*
vallen
);
void
tkvPut
(
STkvDb
*
db
,
const
STkvWriteOpts
*
,
const
char
*
key
,
size_t
keylen
,
const
char
*
val
,
size_t
vallen
);
char
*
tkvGet
(
STkvDb
*
db
,
const
STkvReadOpts
*
,
const
char
*
key
,
size_t
keylen
,
size_t
*
vallen
);
// DB options
STkvOpts
*
tkvOpt
ion
sCreate
();
void
tkvOpt
ion
sDestroy
(
STkvOpts
*
);
STkvOpts
*
tkvOptsCreate
();
void
tkvOptsDestroy
(
STkvOpts
*
);
void
tkvOptionsSetCache
(
STkvOpts
*
,
STkvCache
*
);
void
tkvOptsSetCreateIfMissing
(
STkvOpts
*
,
unsigned
char
);
// DB cache
typedef
enum
{
TKV_LRU_CACHE
=
0
,
TKV_LFU_CACHE
=
1
}
ETkvCacheType
;
...
...
source/libs/tkv/CMakeLists.txt
浏览文件 @
9179423f
aux_source_directory
(
src TKV_SRC
)
add_library
(
tkv
${
TKV_SRC
}
)
add_library
(
tkv
STATIC
${
TKV_SRC
}
)
target_include_directories
(
tkv
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/tkv"
...
...
source/libs/tkv/src/tkv.c
浏览文件 @
9179423f
...
...
@@ -13,69 +13,167 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_ROCKSDB
#include <rocksdb/c.h>
#endif
#include "tkv.h"
struct
STkvDb
{
// TODO
#ifdef USE_ROCKSDB
rocksdb_t
*
db
;
#endif
};
struct
STkvOpts
{
// TODO
#ifdef USE_ROCKSDB
rocksdb_options_t
*
opts
;
#endif
};
struct
STkvCache
{
// TODO
};
struct
STkvReadOpts
{
// TODO
#ifdef USE_ROCKSDB
rocksdb_readoptions_t
*
ropts
;
#endif
};
struct
STkvWriteOpts
{
// TODO
#ifdef USE_ROCKSDB
rocksdb_writeoptions_t
*
wopts
;
#endif
};
STkvDb
*
tkvOpen
(
const
STkvOpts
*
options
,
const
char
*
path
)
{
// TODO
return
NULL
;
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
*
db
)
{
// TODO
void
tkvClose
(
STkvDb
*
pDb
)
{
if
(
pDb
)
{
#ifdef USE_ROCKSDB
rocksdb_close
(
pDb
->
db
);
#endif
free
(
pDb
);
}
}
void
tkvPut
(
STkvDb
*
db
,
STkvWriteOpts
*
pwopts
,
char
*
key
,
size_t
keylen
,
char
*
val
,
size_t
vallen
)
{
// TODO
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
->
wopts
,
key
,
keylen
,
val
,
vallen
,
&
err
);
// TODO: check error
#endif
}
char
*
tkvGet
(
STkvDb
*
db
,
STkvReadOpts
*
propts
,
char
*
key
,
size_t
keylen
,
size_t
*
vallen
)
{
// TODO
return
NULL
;
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
->
ropts
,
key
,
keylen
,
vallen
,
&
err
);
// TODD: check error
#endif
return
ret
;
}
STkvOpts
*
tkvOptionsCreate
()
{
// TODO
return
NULL
;
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
tkvOptionsDestroy
(
STkvOpts
*
popts
)
{
// TODO
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
()
{
// TODO
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
*
propts
)
{
// TODO
void
tkvReadOptsDestroy
(
STkvReadOpts
*
pReadOpts
)
{
if
(
pReadOpts
)
{
#ifdef USE_ROCKSDB
rocksdb_readoptions_destroy
(
pReadOpts
->
ropts
);
#endif
free
(
pReadOpts
);
}
}
STkvWriteOpts
*
tkvWriteOptsCreate
()
{
// TODO
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
*
pwopts
)
{
void
tkvWriteOptsDestroy
(
STkvWriteOpts
*
pWriteOpts
)
{
if
(
pWriteOpts
)
{
#ifdef USE_ROCKSDB
rocksdb_writeoptions_destroy
(
pWriteOpts
->
wopts
);
#endif
free
(
pWriteOpts
);
}
// TODO
}
\ No newline at end of file
source/server/vnode/meta/src/meta.c
浏览文件 @
9179423f
...
...
@@ -73,7 +73,8 @@ SMeta *metaOpen(SMetaOpts *options) {
pMeta
->
stbList
=
tdListNew
(
sizeof
(
STableObj
*
));
// Options
STkvOpts
*
dbOptions
=
tkvOptionsCreate
();
STkvOpts
*
dbOptions
=
tkvOptsCreate
();
tkvOptsSetCreateIfMissing
(
dbOptions
,
1
);
taosMkDir
(
"meta"
);
...
...
@@ -89,7 +90,7 @@ SMeta *metaOpen(SMetaOpts *options) {
// Open tag index
pMeta
->
tagIdx
=
tkvOpen
(
dbOptions
,
"meta/tag_idx_db"
);
tkvOpt
ion
sDestroy
(
dbOptions
);
tkvOptsDestroy
(
dbOptions
);
return
pMeta
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录