refact
This commit is contained in:
parent
45de6cfee0
commit
733506d432
|
@ -18,13 +18,8 @@
|
||||||
|
|
||||||
int metaOpenDB(SMeta *pMeta) {
|
int metaOpenDB(SMeta *pMeta) {
|
||||||
char * err = NULL;
|
char * err = NULL;
|
||||||
rocksdb_options_t *pOpts;
|
rocksdb_options_t *dbOptions;
|
||||||
|
rocksdb_options_t *idxOptions;
|
||||||
pOpts = rocksdb_options_create();
|
|
||||||
if (pOpts == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create LRU cache
|
// Create LRU cache
|
||||||
if (pMeta->options.lruCacheSize) {
|
if (pMeta->options.lruCacheSize) {
|
||||||
|
@ -33,25 +28,47 @@ int metaOpenDB(SMeta *pMeta) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb_options_set_row_cache(pOpts, pMeta->metaDB.pCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open raw data DB
|
// Open raw data DB ---------------------------
|
||||||
pMeta->metaDB.pDB = rocksdb_open(pOpts, "db", &err);
|
dbOptions = rocksdb_options_create();
|
||||||
|
if (dbOptions == NULL) {
|
||||||
|
// TODO: handle error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->metaDB.pCache) {
|
||||||
|
rocksdb_options_set_row_cache(dbOptions, pMeta->metaDB.pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
pMeta->metaDB.pDB = rocksdb_open(dbOptions, "db", &err);
|
||||||
if (pMeta->metaDB.pDB == NULL) {
|
if (pMeta->metaDB.pDB == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open index DB
|
rocksdb_options_destroy(dbOptions);
|
||||||
pMeta->metaDB.pIdx = rocksdb_open(pOpts, "index", &err);
|
|
||||||
|
// Open index DB ---------------------------
|
||||||
|
idxOptions = rocksdb_options_create();
|
||||||
|
if (idxOptions == NULL) {
|
||||||
|
// TODO: handle error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->metaDB.pCache) {
|
||||||
|
rocksdb_options_set_row_cache(dbOptions, pMeta->metaDB.pCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
pMeta->metaDB.pIdx = rocksdb_open(idxOptions, "index", &err);
|
||||||
if (pMeta->metaDB.pIdx == NULL) {
|
if (pMeta->metaDB.pIdx == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
rocksdb_close(pMeta->metaDB.pDB);
|
rocksdb_close(pMeta->metaDB.pDB);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rocksdb_options_destroy(idxOptions);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue