This commit is contained in:
Hongze Cheng 2021-11-03 10:41:07 +08:00
parent 15b8a7f55a
commit 5f0e19747f
1 changed files with 24 additions and 2 deletions

View File

@ -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;
}
}