From e0e9f088c4e9daf3709c1fb3ffc1a44db4cb3ac6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 9 Feb 2022 15:02:38 +0000 Subject: [PATCH] more TDB --- source/dnode/vnode/src/meta/metaTDBImpl.c | 23 ++++++++++++++++++++--- source/libs/tdb/inc/tdb.h | 1 + source/libs/tdb/src/db/tdbEnv.c | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTDBImpl.c b/source/dnode/vnode/src/meta/metaTDBImpl.c index 61c84740af..56dbc9efc3 100644 --- a/source/dnode/vnode/src/meta/metaTDBImpl.c +++ b/source/dnode/vnode/src/meta/metaTDBImpl.c @@ -13,16 +13,33 @@ * along with this program. If not, see . */ -#include "meta.h" +#include "metaDef.h" #include "tdb.h" struct SMetaDB { - // TODO + TENV *pEnv; + TDB * pTbDB; + TDB * pSchemaDB; + TDB * pNameIdx; + TDB * pStbIdx; + TDB * pNtbIdx; + TDB * pCtbIdx; + // tag index hash table + // suid+colid --> TDB * + struct { + } tagIdxHt; }; int metaOpenDB(SMeta *pMeta) { - // TODO + SMetaDB *pDb; + + pDb = (SMetaDB *)calloc(1, sizeof(*pDb)); + if (pDb == NULL) { + return -1; + } + + pMeta->pDB = pDb; return 0; } diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index 63da7999c9..5bbaf2ac88 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -27,6 +27,7 @@ typedef struct STDbEnv TENV; typedef struct STDbCurosr TDBC; // TEVN +int tdbEnvCreate(TENV **ppEnv); int tdbEnvOpen(TENV **ppEnv); int tdbEnvClose(TENV *pEnv); diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 302c238927..03eb0f82ed 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -23,13 +23,22 @@ struct STDbEnv { SPgCache pgc; // page cache }; +static int tdbEnvDestroy(TENV *pEnv); + +int tdbEnvCreate(TENV **ppEnv) { + // TODO + return 0; +} + int tdbEnvOpen(TENV **ppEnv) { // TODO return 0; } int tdbEnvClose(TENV *pEnv) { - // TODO + if (pEnv == NULL) return 0; + /* TODO */ + tdbEnvDestroy(pEnv); return 0; } @@ -38,4 +47,9 @@ SPgFile *tdbEnvGetPageFile(TENV *pEnv, const uint8_t fileid[]) { return NULL; } -SPgCache *tdbEnvGetPgCache(TENV *pEnv) { return &(pEnv->pgc); } \ No newline at end of file +SPgCache *tdbEnvGetPgCache(TENV *pEnv) { return &(pEnv->pgc); } + +static int tdbEnvDestroy(TENV *pEnv) { + // TODO + return 0; +} \ No newline at end of file -- GitLab