aboutsummaryrefslogtreecommitdiff
path: root/src/db/bin
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-10-10 13:57:21 +0200
committerAlex Auvolat <alex@adnab.me>2023-10-10 13:57:21 +0200
commitd4932c31ea7d2430749ef5f37b9e47b36c1fafa8 (patch)
tree4dee7df1689c298a163798b47c524717d2872f7d /src/db/bin
parent0c431b0c035f4de8ea9d1d9bd0b419bfc74ceabf (diff)
parente75fe2157d0973eb4320bbc87be5e54a1cb91a63 (diff)
downloadgarage-d4932c31ea7d2430749ef5f37b9e47b36c1fafa8.tar.gz
garage-d4932c31ea7d2430749ef5f37b9e47b36c1fafa8.zip
Merge branch 'main' into next
Diffstat (limited to 'src/db/bin')
-rw-r--r--src/db/bin/convert.rs73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/db/bin/convert.rs b/src/db/bin/convert.rs
deleted file mode 100644
index 957deedf..00000000
--- a/src/db/bin/convert.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use std::path::PathBuf;
-
-use garage_db::*;
-
-use clap::Parser;
-
-/// K2V command line interface
-#[derive(Parser, Debug)]
-#[clap(author, version, about, long_about = None)]
-struct Args {
- /// Input DB path
- #[clap(short = 'i')]
- input_path: PathBuf,
- /// Input DB engine
- #[clap(short = 'a')]
- input_engine: String,
-
- /// Output DB path
- #[clap(short = 'o')]
- output_path: PathBuf,
- /// Output DB engine
- #[clap(short = 'b')]
- output_engine: String,
-}
-
-fn main() {
- let args = Args::parse();
- pretty_env_logger::init();
-
- match do_conversion(args) {
- Ok(()) => println!("Success!"),
- Err(e) => eprintln!("Error: {}", e),
- }
-}
-
-fn do_conversion(args: Args) -> Result<()> {
- let input = open_db(args.input_path, args.input_engine)?;
- let output = open_db(args.output_path, args.output_engine)?;
- output.import(&input)?;
- Ok(())
-}
-
-fn open_db(path: PathBuf, engine: String) -> Result<Db> {
- match engine.as_str() {
- "sled" => {
- let db = sled_adapter::sled::Config::default().path(&path).open()?;
- Ok(sled_adapter::SledDb::init(db))
- }
- "sqlite" | "sqlite3" | "rusqlite" => {
- let db = sqlite_adapter::rusqlite::Connection::open(&path)?;
- db.pragma_update(None, "journal_mode", &"WAL")?;
- db.pragma_update(None, "synchronous", &"NORMAL")?;
- Ok(sqlite_adapter::SqliteDb::init(db))
- }
- "lmdb" | "heed" => {
- std::fs::create_dir_all(&path).map_err(|e| {
- Error(format!("Unable to create LMDB data directory: {}", e).into())
- })?;
-
- let map_size = lmdb_adapter::recommended_map_size();
-
- let mut env_builder = lmdb_adapter::heed::EnvOpenOptions::new();
- env_builder.max_dbs(100);
- env_builder.map_size(map_size);
- unsafe {
- env_builder.flag(heed::flags::Flags::MdbNoMetaSync);
- }
- let db = env_builder.open(&path)?;
- Ok(lmdb_adapter::LmdbDb::init(db))
- }
- e => Err(Error(format!("Invalid DB engine: {}", e).into())),
- }
-}