diff --git a/source/dnode/vnode/meta/inc/metaTbUid.h b/source/dnode/vnode/meta/inc/metaTbUid.h index 86f4e26cec..07d1f6635b 100644 --- a/source/dnode/vnode/meta/inc/metaTbUid.h +++ b/source/dnode/vnode/meta/inc/metaTbUid.h @@ -27,13 +27,13 @@ typedef struct STbUidGenerator { tb_uid_t nextUid; } STbUidGenerator; +// STableUidGenerator +int metaOpenUidGnrt(SMeta *pMeta); +void metaCloseUidGnrt(SMeta *pMeta); + // tb_uid_t #define IVLD_TB_UID 0 -tb_uid_t generateUid(STbUidGenerator *); - -// STableUidGenerator -void tableUidGeneratorInit(STbUidGenerator *, tb_uid_t suid); -#define tableUidGeneratorClear(ug) +tb_uid_t metaGenerateUid(SMeta *pMeta); #ifdef __cplusplus } diff --git a/source/dnode/vnode/meta/src/metaMain.c b/source/dnode/vnode/meta/src/metaMain.c index 5f82ca4e87..5ffcfb86cb 100644 --- a/source/dnode/vnode/meta/src/metaMain.c +++ b/source/dnode/vnode/meta/src/metaMain.c @@ -44,25 +44,41 @@ SMeta *metaOpen(const char *path, const SMetaOptions *pMetaOptions) { return NULL; } - // Create META path + // Create META path (TODO) taosMkDir(path); - // Open the DBs needed - if (metaOpenDB(pMeta) < 0) { + // Open meta cache + if (metaOpenCache(pMeta) < 0) { // TODO: handle error - metaFree(pMeta); return NULL; } - tableUidGeneratorInit(&(pMeta->uidGnrt), IVLD_TB_UID); + // Open meta db + if (metaOpenDB(pMeta) < 0) { + // TODO: handle error + return NULL; + } + + // Open meta index + if (metaOpenIdx(pMeta) < 0) { + // TODO: handle error + return NULL; + } + + // Open meta table uid generator + if (metaOpenUidGnrt(pMeta) < 0) { + return NULL; + } return pMeta; } void metaClose(SMeta *pMeta) { if (pMeta) { - tableUidGeneratorClear(&pMeta->uidGnrt); + metaCloseUidGnrt(pMeta); + metaCloseIdx(pMeta); metaCloseDB(pMeta); + metaCloseCache(pMeta); metaFree(pMeta); } } @@ -81,6 +97,7 @@ static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions) { pMeta->path = strdup(path); if (pMeta->path == NULL) { + metaFree(pMeta); return NULL; } diff --git a/source/dnode/vnode/meta/src/metaTbUid.c b/source/dnode/vnode/meta/src/metaTbUid.c index 87b1199fd9..be85b45d95 100644 --- a/source/dnode/vnode/meta/src/metaTbUid.c +++ b/source/dnode/vnode/meta/src/metaTbUid.c @@ -13,14 +13,18 @@ * along with this program. If not, see . */ -#include "metaTbUid.h" +#include "meta.h" +#include "metaDef.h" -tb_uid_t generateUid(STbUidGenerator *pGen) { - // Generate a new table UID - return ++(pGen->nextUid); +int metaOpenUidGnrt(SMeta *pMeta) { + // Init a generator + pMeta->uidGnrt.nextUid = IVLD_TB_UID; + return 0; } -void tableUidGeneratorInit(STbUidGenerator *pGen, tb_uid_t suid) { - // Init a generator - pGen->nextUid = suid; +void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */ } + +tb_uid_t metaGenerateUid(SMeta *pMeta) { + // Generate a new table UID + return ++(pMeta->uidGnrt.nextUid); } \ No newline at end of file