diff --git a/Cargo.lock b/Cargo.lock index 148cbfacc..6e5cc968d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,6 +65,11 @@ name = "elapsed" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fst" version = "0.3.0" @@ -219,6 +224,7 @@ name = "raptor" version = "0.1.0" dependencies = [ "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "fst 0.3.0 (git+https://github.com/Kerollmops/fst.git?branch=always-match-clone)", "group-by 0.1.0 (git+https://github.com/Kerollmops/group-by.git)", "levenshtein_automata 0.1.1 (git+https://github.com/Kerollmops/levenshtein-automata.git?branch=custom-fst)", @@ -364,6 +370,7 @@ dependencies = [ "checksum cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "704fbf3bb5149daab0afb255dbea24a1f08d2f4099cedb9baab6d470d4c5eefb" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum elapsed 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4e5af126dafd0741c2ad62d47f68b28602550102e5f0dd45c8a97fc8b49c29" +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fst 0.3.0 (git+https://github.com/Kerollmops/fst.git?branch=always-match-clone)" = "" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" diff --git a/raptor/Cargo.toml b/raptor/Cargo.toml index 63c39c66f..006bb4a29 100644 --- a/raptor/Cargo.toml +++ b/raptor/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Kerollmops "] [dependencies] byteorder = "1.2" +fnv = "1.0" [dependencies.fst] git = "https://github.com/Kerollmops/fst.git" diff --git a/raptor/src/lib.rs b/raptor/src/lib.rs index ed37b5464..39bf59f2a 100644 --- a/raptor/src/lib.rs +++ b/raptor/src/lib.rs @@ -1,4 +1,5 @@ extern crate fst; +extern crate fnv; extern crate group_by; extern crate levenshtein_automata; extern crate byteorder; diff --git a/raptor/src/rank/mod.rs b/raptor/src/rank/mod.rs index 0d2a250c1..9faf3cc27 100644 --- a/raptor/src/rank/mod.rs +++ b/raptor/src/rank/mod.rs @@ -6,9 +6,9 @@ mod sum_of_words_position; mod exact; use std::cmp::Ordering; -use std::collections::HashMap; use std::{mem, vec}; use fst; +use fnv::FnvHashMap; use levenshtein::Levenshtein; use metadata::{DocIndexes, OpWithStateBuilder, UnionWithState}; use {Match, DocumentId}; @@ -59,7 +59,7 @@ impl Pool { } // TODO remove the matches HashMap, not proud of it - pub fn extend(&mut self, matches: &mut HashMap>) { + pub fn extend(&mut self, matches: &mut FnvHashMap>) { for doc in self.documents.iter_mut() { if let Some(matches) = matches.remove(&doc.document_id) { doc.matches.extend(matches); @@ -149,7 +149,7 @@ impl<'m, 'v, 'a> fst::Streamer<'a> for RankedStream<'m, 'v> { type Item = Document; fn next(&'a mut self) -> Option { - let mut matches = HashMap::new(); + let mut matches = FnvHashMap::default(); loop { // TODO remove that when NLL are here !