diff --git a/Cargo.lock b/Cargo.lock index d513d8eb..f9f5770b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,7 +194,7 @@ dependencies = [ "lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitives 0.1.0", - "rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)", + "rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb?branch=bloom)", "serialization 0.1.0", "test-data 0.1.0", ] @@ -800,16 +800,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rocksdb" version = "0.4.5" -source = "git+https://github.com/ethcore/rust-rocksdb#64c63ccbe1f62c2e2b39262486f9ba813793af58" +source = "git+https://github.com/ethcore/rust-rocksdb?branch=bloom#23533a08acaca376307824f39f224432be326244" dependencies = [ "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)", + "rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb?branch=bloom)", ] [[package]] name = "rocksdb-sys" version = "0.3.0" -source = "git+https://github.com/ethcore/rust-rocksdb#64c63ccbe1f62c2e2b39262486f9ba813793af58" +source = "git+https://github.com/ethcore/rust-rocksdb?branch=bloom#23533a08acaca376307824f39f224432be326244" dependencies = [ "gcc 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1305,8 +1305,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b6a6e05e0e6b703e9f2ad266eb63f3712e693a17a2702b95a23de14ce8defa9" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)" = "" -"checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb)" = "" +"checksum rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb?branch=bloom)" = "" +"checksum rocksdb-sys 0.3.0 (git+https://github.com/ethcore/rust-rocksdb?branch=bloom)" = "" "checksum rotor 0.6.3 (git+https://github.com/ethcore/rotor)" = "" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" diff --git a/db/Cargo.toml b/db/Cargo.toml index ea2e88ba..413c3d66 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Nikolay Volf "] [dependencies] elastic-array = { git = "https://github.com/ethcore/elastic-array" } -rocksdb = { git = "https://github.com/ethcore/rust-rocksdb" } +rocksdb = { git = "https://github.com/ethcore/rust-rocksdb", branch = "bloom" } ethcore-devtools = { path = "../devtools" } primitives = { path = "../primitives" } byteorder = "0.5" diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index 64cc74c9..02bbc3b7 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -151,6 +151,8 @@ pub struct DatabaseConfig { pub max_open_files: i32, /// Cache sizes (in MiB) for specific columns. pub cache_sizes: HashMap, usize>, + /// Specific number of bloom filter bits, if any + pub bloom_filters: HashMap, u8>, /// Compaction profile pub compaction: CompactionProfile, /// Set number of columns @@ -178,6 +180,7 @@ impl Default for DatabaseConfig { fn default() -> DatabaseConfig { DatabaseConfig { cache_sizes: HashMap::new(), + bloom_filters: HashMap::new(), max_open_files: 512, compaction: CompactionProfile::default(), columns: None, @@ -260,8 +263,11 @@ impl Database { let col_opt = config.columns.map(|_| col); { - let cache_size = config.cache_sizes.get(&col_opt).cloned().unwrap_or(DEFAULT_CACHE); let mut block_opts = BlockBasedOptions::new(); + let cache_size = config.cache_sizes.get(&col_opt).cloned().unwrap_or(DEFAULT_CACHE); + if let Some(bloom_bits) = config.bloom_filters.get(&col_opt) { + block_opts.set_filter(bloom_bits.clone() as i32); + } // all goes to read cache. block_opts.set_cache(Cache::new(cache_size * 1024 * 1024)); opts.set_block_based_table_factory(&block_opts); diff --git a/db/src/storage.rs b/db/src/storage.rs index fbd0bde5..78781825 100644 --- a/db/src/storage.rs +++ b/db/src/storage.rs @@ -126,6 +126,8 @@ impl Storage { cfg.set_cache(Some(COL_BLOCK_TRANSACTIONS), total_cache / 12); cfg.set_cache(Some(COL_BLOCK_NUMBERS), total_cache / 12); + cfg.bloom_filters.insert(Some(COL_TRANSACTIONS_META), 16); + let db = try!(Database::open(&cfg, &*path.as_ref().to_string_lossy())); let storage = Storage {