From 36d3adc23fa9d258a7d2fbe05e1110ad8adc1e1a Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 2 Nov 2021 17:49:10 +0800 Subject: [PATCH] refact --- source/dnode/vnode/meta/inc/metaCache.h | 32 +++++++++++++++++++++++++ source/dnode/vnode/meta/inc/metaDB.h | 9 ------- source/dnode/vnode/meta/inc/metaDef.h | 13 ++++++---- source/dnode/vnode/meta/inc/metaIdx.h | 32 +++++++++++++++++++++++++ source/dnode/vnode/meta/src/metaCache.c | 26 ++++++++++++++++++++ source/dnode/vnode/meta/src/metaDB.c | 4 ++++ source/dnode/vnode/meta/src/metaIdx.c | 23 ++++++++++++++++++ 7 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 source/dnode/vnode/meta/inc/metaCache.h create mode 100644 source/dnode/vnode/meta/inc/metaIdx.h create mode 100644 source/dnode/vnode/meta/src/metaCache.c create mode 100644 source/dnode/vnode/meta/src/metaIdx.c diff --git a/source/dnode/vnode/meta/inc/metaCache.h b/source/dnode/vnode/meta/inc/metaCache.h new file mode 100644 index 0000000000..60cedce29c --- /dev/null +++ b/source/dnode/vnode/meta/inc/metaCache.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_META_CACHE_H_ +#define _TD_META_CACHE_H_ + +#include "meta.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int metaOpenCache(SMeta *pMeta); +void metaCloseCache(SMeta *pMeta); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_META_CACHE_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/meta/inc/metaDB.h b/source/dnode/vnode/meta/inc/metaDB.h index 7a9dcc9c34..2c075d751c 100644 --- a/source/dnode/vnode/meta/inc/metaDB.h +++ b/source/dnode/vnode/meta/inc/metaDB.h @@ -17,20 +17,11 @@ #define _TD_META_DB_H_ #include "meta.h" -// #include "tkv.h" - -#include "rocksdb/c.h" #ifdef __cplusplus extern "C" { #endif -typedef struct SMetaDB { - rocksdb_t * pDB; - rocksdb_t * pIdx; - rocksdb_cache_t *pCache; -} SMetaDB; - int metaOpenDB(SMeta *pMeta); void metaCloseDB(SMeta *pMeta); diff --git a/source/dnode/vnode/meta/inc/metaDef.h b/source/dnode/vnode/meta/inc/metaDef.h index b5976a943f..395ca7c7bd 100644 --- a/source/dnode/vnode/meta/inc/metaDef.h +++ b/source/dnode/vnode/meta/inc/metaDef.h @@ -16,7 +16,8 @@ #ifndef _TD_META_DEF_H_ #define _TD_META_DEF_H_ -#include "metaDB.h" +#include "rocksdb/c.h" + #include "metaTbUid.h" #ifdef __cplusplus @@ -24,10 +25,12 @@ extern "C" { #endif struct SMeta { - char* path; // path of current meta - SMetaOptions options; // meta option - SMetaDB metaDB; // meta DB for real storage engine - STbUidGenerator uidGnrt; // meta table UID generator + char * path; // path of current meta + SMetaOptions options; // meta option + rocksdb_t * pDB; + rocksdb_t * pIdx; + rocksdb_cache_t *pCache; + STbUidGenerator uidGnrt; // meta table UID generator }; #ifdef __cplusplus diff --git a/source/dnode/vnode/meta/inc/metaIdx.h b/source/dnode/vnode/meta/inc/metaIdx.h new file mode 100644 index 0000000000..ed1f6ac94c --- /dev/null +++ b/source/dnode/vnode/meta/inc/metaIdx.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_META_IDX_H_ +#define _TD_META_IDX_H_ + +#include "meta.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int metaOpenIdx(SMeta *pMeta); +void metaCloseIdx(SMeta *pMeta); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_META_IDX_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/meta/src/metaCache.c b/source/dnode/vnode/meta/src/metaCache.c new file mode 100644 index 0000000000..1e848d434e --- /dev/null +++ b/source/dnode/vnode/meta/src/metaCache.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#include "meta.h" +#include "metaDef.h" + +int metaOpenCache(SMeta *pMeta) { + // TODO + return 0; +} + +void metaCloseCache(SMeta *pMeta) { + // TODO +} \ No newline at end of file diff --git a/source/dnode/vnode/meta/src/metaDB.c b/source/dnode/vnode/meta/src/metaDB.c index 8c30c32d5d..5c3d9d0a02 100644 --- a/source/dnode/vnode/meta/src/metaDB.c +++ b/source/dnode/vnode/meta/src/metaDB.c @@ -17,6 +17,7 @@ #include "metaDef.h" int metaOpenDB(SMeta *pMeta) { +#if 0 char * err = NULL; rocksdb_options_t *dbOptions; rocksdb_options_t *idxOptions; @@ -69,10 +70,12 @@ int metaOpenDB(SMeta *pMeta) { rocksdb_options_destroy(idxOptions); +#endif return 0; } void metaCloseDB(SMeta *pMeta) { /* TODO */ +#if 0 // Close index DB if (pMeta->metaDB.pIdx) { rocksdb_close(pMeta->metaDB.pIdx); @@ -87,4 +90,5 @@ void metaCloseDB(SMeta *pMeta) { /* TODO */ if (pMeta->metaDB.pCache) { rocksdb_cache_destroy(pMeta->metaDB.pCache); } +#endif } \ No newline at end of file diff --git a/source/dnode/vnode/meta/src/metaIdx.c b/source/dnode/vnode/meta/src/metaIdx.c new file mode 100644 index 0000000000..f04489d21e --- /dev/null +++ b/source/dnode/vnode/meta/src/metaIdx.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#include "metaIdx.h" + +int metaOpenIdx(SMeta *pMeta) { + /* TODO */ + return 0; +} + +void metaCloseIdx(SMeta *pMeta) { /* TODO */ } \ No newline at end of file -- GitLab