diff --git a/source/dnode/vnode/meta/inc/metaDef.h b/source/dnode/vnode/meta/inc/metaDef.h index aaae07d6f4..71ba42b985 100644 --- a/source/dnode/vnode/meta/inc/metaDef.h +++ b/source/dnode/vnode/meta/inc/metaDef.h @@ -26,8 +26,8 @@ extern "C" { struct SMeta { char* path; // path of current meta SMetaOptions options; // meta option - SMetaDB* pMetaDB; // meta DB for real storage engine - STbUidGenerator uidGenerator; // meta table UID generator + SMetaDB metaDB; // meta DB for real storage engine + STbUidGenerator uidGnrt; // meta table UID generator }; #ifdef __cplusplus diff --git a/source/dnode/vnode/meta/src/metaDB.c b/source/dnode/vnode/meta/src/metaDB.c index 6dea4a4e57..73d54d7682 100644 --- a/source/dnode/vnode/meta/src/metaDB.c +++ b/source/dnode/vnode/meta/src/metaDB.c @@ -11,4 +11,41 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - */ \ No newline at end of file + */ + +#include "meta.h" +#include "metaDef.h" + +int metaOpenDB(SMeta *pMeta) { + /* TODO */ + pMeta->metaDB.pDB = tkvOpen(NULL, "db"); + if (pMeta->metaDB.pDB == NULL) { + // TODO + return -1; + } + + pMeta->metaDB.pIdx = tkvOpen(NULL, "index"); + if (pMeta->metaDB.pIdx == NULL) { + /* TODO */ + return -1; + } + + { /* TODO: for cache*/ + } + + return 0; +} + +void metaCloseDB(SMeta *pMeta) { /* TODO */ + { + // TODO: clear cache + } + + if (pMeta->metaDB.pIdx) { + tkvClose(pMeta->metaDB.pIdx); + } + + if (pMeta->metaDB.pDB) { + tkvClose(pMeta->metaDB.pIdx); + } +} \ No newline at end of file diff --git a/source/dnode/vnode/meta/src/metaMain.c b/source/dnode/vnode/meta/src/metaMain.c index c0fcf6898a..d30c938989 100644 --- a/source/dnode/vnode/meta/src/metaMain.c +++ b/source/dnode/vnode/meta/src/metaMain.c @@ -57,14 +57,14 @@ SMeta *metaOpen(const char *path, const SMetaOptions *pMetaOptions) { return NULL; } - tableUidGeneratorInit(&(pMeta->uidGenerator), IVLD_TB_UID); + tableUidGeneratorInit(&(pMeta->uidGnrt), IVLD_TB_UID); return pMeta; } void metaClose(SMeta *pMeta) { if (pMeta) { - tableUidGeneratorClear(&pMeta->uidGenerator); + tableUidGeneratorClear(&pMeta->uidGnrt); metaCloseDB(pMeta); free(pMeta); }