diff --git a/meilidb-data/Cargo.toml b/meilidb-data/Cargo.toml index 0c5ff9f5e..751ee7fde 100644 --- a/meilidb-data/Cargo.toml +++ b/meilidb-data/Cargo.toml @@ -28,5 +28,9 @@ rev = "40b3d48" git = "https://github.com/Kerollmops/fst.git" branch = "arc-byte-slice" +[features] +default = [] +compression = ["sled/compression"] + [dev-dependencies] tempfile = "3.0.7" diff --git a/meilidb-data/src/database/mod.rs b/meilidb-data/src/database/mod.rs index dcdc13bd2..9a2306ae7 100644 --- a/meilidb-data/src/database/mod.rs +++ b/meilidb-data/src/database/mod.rs @@ -41,6 +41,18 @@ impl Database { Ok(Database { cache, inner }) } + pub fn start_with_compression>(path: P, factor: i32) -> Result { + let config = sled::ConfigBuilder::default() + .use_compression(true) + .compression_factor(factor) + .path(path) + .build(); + + let cache = RwLock::new(HashMap::new()); + let inner = sled::Db::start(config)?; + Ok(Database { cache, inner }) + } + pub fn indexes(&self) -> Result>, Error> { let bytes = match self.inner.get("indexes")? { Some(bytes) => bytes,