From 433d9bbc6ebf69a03a421d04961391c0103c3507 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 6 Oct 2020 13:50:34 +0200 Subject: [PATCH] Use CompressionType::from_str rather than a custom function --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/bin/indexer.rs | 15 ++------------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e68e03bb1..897a9b5f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1203,7 +1203,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "oxidized-mtbl" version = "0.1.0" -source = "git+https://github.com/Kerollmops/oxidized-mtbl.git?rev=a2e13cb#a2e13cba5fb3ed606d2a18a43260c5487eb38746" +source = "git+https://github.com/Kerollmops/oxidized-mtbl.git?rev=45076a1#45076a16e91102d8153e63043fe0723abc4e1d18" dependencies = [ "byteorder", "crc32c", diff --git a/Cargo.toml b/Cargo.toml index b943dbae6..b2c8e3d3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ linked-hash-map = "0.5.3" memmap = "0.7.0" near-proximity = { git = "https://github.com/Kerollmops/plane-sweep-proximity", rev = "6608205" } once_cell = "1.4.0" -oxidized-mtbl = { git = "https://github.com/Kerollmops/oxidized-mtbl.git", rev = "a2e13cb" } +oxidized-mtbl = { git = "https://github.com/Kerollmops/oxidized-mtbl.git", rev = "45076a1" } rayon = "1.3.1" ringtail = "0.3.0" roaring = "0.6.1" diff --git a/src/bin/indexer.rs b/src/bin/indexer.rs index c550d3338..d9272d0db 100644 --- a/src/bin/indexer.rs +++ b/src/bin/indexer.rs @@ -100,24 +100,13 @@ struct IndexerOpt { /// /// Choosing a fast algorithm will make the indexing faster but may consume more memory. #[structopt(long, default_value = "snappy", possible_values = &["snappy", "zlib", "lz4", "lz4hc", "zstd"])] - chunk_compression_type: String, + chunk_compression_type: CompressionType, /// The level of compression of the chosen algorithm. #[structopt(long, requires = "chunk-compression-type")] chunk_compression_level: Option, } -fn compression_type_from_str(name: &str) -> CompressionType { - match name { - "snappy" => CompressionType::Snappy, - "zlib" => CompressionType::Zlib, - "lz4" => CompressionType::Lz4, - "lz4hc" => CompressionType::Lz4hc, - "zstd" => CompressionType::Zstd, - _ => panic!("invalid compression algorithm"), - } -} - fn format_count(n: usize) -> String { human_format::Formatter::new().with_decimals(1).with_separator("").format(n as f64) } @@ -747,7 +736,7 @@ fn main() -> anyhow::Result<()> { let linked_hash_map_size = opt.indexer.linked_hash_map_size; let max_nb_chunks = opt.indexer.max_nb_chunks; let max_memory = opt.indexer.max_memory; - let chunk_compression_type = compression_type_from_str(&opt.indexer.chunk_compression_type); + let chunk_compression_type = opt.indexer.chunk_compression_type; let chunk_compression_level = opt.indexer.chunk_compression_level; let log_every_n = opt.indexer.log_every_n;