diff --git a/source/dnode/vnode/meta/src/metaDB.c b/source/dnode/vnode/meta/src/metaDB.c index 2fcf424971..04c43d343e 100644 --- a/source/dnode/vnode/meta/src/metaDB.c +++ b/source/dnode/vnode/meta/src/metaDB.c @@ -17,10 +17,32 @@ #include "metaDef.h" int metaOpenDB(SMeta *pMeta) { - /* TODO */ + char dbDir[128]; + char * err = NULL; + rocksdb_options_t *options = rocksdb_options_create(); + + // TODO + sprintf(dbDir, "%s/db", pMeta->path); + + if (pMeta->pCache) { + rocksdb_options_set_row_cache(options, pMeta->pCache); + } + + pMeta->pDB = rocksdb_open(options, dbDir, &err); + if (pMeta->pDB == NULL) { + // TODO: handle error + rocksdb_options_destroy(options); + return -1; + } + + rocksdb_options_destroy(options); return 0; } -void metaCloseDB(SMeta *pMeta) { /* TODO */ +void metaCloseDB(SMeta *pMeta) { + if (pMeta->pDB) { + rocksdb_close(pMeta->pDB); + pMeta->pDB = NULL; + } } \ No newline at end of file