From 55b170c65a23da33893542e4281b02d1c9854360 Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Wed, 17 Jan 2024 20:41:49 +0100 Subject: [PATCH] Allow to set LMDB map size in convert-db script --- src/garage/cli/convert_db.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/garage/cli/convert_db.rs b/src/garage/cli/convert_db.rs index 3c6ce69c..01f7003e 100644 --- a/src/garage/cli/convert_db.rs +++ b/src/garage/cli/convert_db.rs @@ -22,16 +22,20 @@ pub struct ConvertDbOpt { /// Output database engine #[structopt(short = "b")] output_engine: String, + + /// LMDB map size + #[structopt(long = "lmdb_map_size")] + lmdb_map_size: Option, } pub(crate) fn do_conversion(args: ConvertDbOpt) -> Result<()> { - let input = open_db(args.input_path, args.input_engine)?; - let output = open_db(args.output_path, args.output_engine)?; + let input = open_db(args.input_path, args.input_engine, args.lmdb_map_size)?; + let output = open_db(args.output_path, args.output_engine, args.lmdb_map_size)?; output.import(&input)?; Ok(()) } -fn open_db(path: PathBuf, engine: String) -> Result { +fn open_db(path: PathBuf, engine: String, lmdb_map_size: Option) -> Result { match engine.as_str() { #[cfg(feature = "sled")] "sled" => { @@ -51,7 +55,10 @@ fn open_db(path: PathBuf, engine: String) -> Result { Error(format!("Unable to create LMDB data directory: {}", e).into()) })?; - let map_size = lmdb_adapter::recommended_map_size(); + let map_size = match lmdb_map_size { + Some(map_size) => map_size, + None => lmdb_adapter::recommended_map_size(), + }; let mut env_builder = lmdb_adapter::heed::EnvOpenOptions::new(); env_builder.max_dbs(100);