From 9db86f13f379e880ce3eba20285511dad3232d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 19 Sep 2019 12:02:34 +0200 Subject: [PATCH] fix: Only create the Column Family when it doesn't already exist --- meilidb-data/src/cf_tree.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/meilidb-data/src/cf_tree.rs b/meilidb-data/src/cf_tree.rs index c15bbbcbb..bb938ff13 100644 --- a/meilidb-data/src/cf_tree.rs +++ b/meilidb-data/src/cf_tree.rs @@ -17,9 +17,12 @@ struct CfTreeInner { impl CfTree { pub fn create(db: Arc, name: String) -> RocksDbResult { let mut options = rocksdb::Options::default(); - options.create_missing_column_families(true); + options.create_missing_column_families(true); // this doesn't work + + if db.cf_handle(&name).is_none() { + let _cf = db.create_cf(&name, &options)?; + } - let _cf = db.create_cf(&name, &options)?; let index = Arc::new(CfTreeInner { db, name }); Ok(CfTree { index, sender: None }) @@ -31,9 +34,12 @@ impl CfTree { ) -> RocksDbResult<(CfTree, Receiver<()>)> { let mut options = rocksdb::Options::default(); - options.create_missing_column_families(true); + options.create_missing_column_families(true); // this doesn't work + + if db.cf_handle(&name).is_none() { + let _cf = db.create_cf(&name, &options)?; + } - let _cf = db.create_cf(&name, &options)?; let index = Arc::new(CfTreeInner { db, name }); let (sender, receiver) = unbounded();