keep column list lexically sorted

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-29 22:07:57 +00:00
parent 35049c94de
commit 7638bbc49c

View file

@ -1,5 +1,5 @@
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{BTreeSet, HashMap},
fmt::Write, fmt::Write,
sync::{atomic::AtomicU32, Arc, Mutex, RwLock}, sync::{atomic::AtomicU32, Arc, Mutex, RwLock},
}; };
@ -23,7 +23,7 @@ pub struct Engine {
col_cache: RwLock<HashMap<String, Cache>>, col_cache: RwLock<HashMap<String, Cache>>,
opts: Options, opts: Options,
env: Env, env: Env,
cfs: Mutex<HashSet<String>>, cfs: Mutex<BTreeSet<String>>,
pub(crate) db: Db, pub(crate) db: Db,
corks: AtomicU32, corks: AtomicU32,
} }
@ -57,7 +57,10 @@ impl Engine {
} }
debug!("Listing column families in database"); debug!("Listing column families in database");
let cfs = Db::list_cf(&db_opts, &config.database_path).unwrap_or_default(); let cfs = Db::list_cf(&db_opts, &config.database_path)
.unwrap_or_default()
.into_iter()
.collect::<BTreeSet<_>>();
debug!("Opening {} column family descriptors in database", cfs.len()); debug!("Opening {} column family descriptors in database", cfs.len());
let cfds = cfs let cfds = cfs
@ -79,7 +82,6 @@ impl Engine {
load_time.elapsed() load_time.elapsed()
); );
let cfs = HashSet::<String>::from_iter(cfs);
Ok(Arc::new(Self { Ok(Arc::new(Self {
server: server.clone(), server: server.clone(),
row_cache, row_cache,