diff --git a/Cargo.lock b/Cargo.lock index 330588564..884bc19d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "heed" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2740ccbbfb2a6e6ff0c43e0fc14981ed668fb45be5a4e7b2bc03fc8cca3d3e" +checksum = "cddc0d0d20adfc803b3e57c2d84447e134cad636202e68e275c65e3cbe63c616" dependencies = [ "byteorder", "heed-traits", diff --git a/Cargo.toml b/Cargo.toml index 2510cb245..b77cf4a44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ flate2 = "1.0.17" fst = "0.4.4" fxhash = "0.2.1" grenad = { git = "https://github.com/Kerollmops/grenad.git", rev = "3eb7ad9" } -heed = { version = "0.10.3", default-features = false, features = ["lmdb", "sync-read-txn"] } +heed = { version = "0.10.4", default-features = false, features = ["lmdb", "sync-read-txn"] } human_format = "1.0.3" jemallocator = "0.3.2" levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] } diff --git a/http-ui/Cargo.toml b/http-ui/Cargo.toml index e8d30a5ce..b30fb95c2 100644 --- a/http-ui/Cargo.toml +++ b/http-ui/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] anyhow = "1.0.28" grenad = { git = "https://github.com/Kerollmops/grenad.git", rev = "3eb7ad9" } -heed = "0.10.3" +heed = "0.10.4" memmap = "0.7.0" milli = { path = ".." } once_cell = "1.4.1" diff --git a/src/search.rs b/src/search.rs index e6fcefc62..3a781847f 100644 --- a/src/search.rs +++ b/src/search.rs @@ -280,8 +280,11 @@ impl<'a> Search<'a> { Unbounded => Unbounded, }; let right_bound = Included((field_id, level, T::max_value(), T::max_value())); - let db = self.index.facet_field_id_value_docids.remap_key_type::(); - let iter = db + // We also make sure that we don't decode the data before we are sure we must return it. + let iter = self.index + .facet_field_id_value_docids + .remap_key_type::() + .lazily_decode_data() .range(self.rtxn, &(left_bound, right_bound))? .take_while(|r| r.as_ref().map_or(true, |((.., r), _)| { match right { @@ -289,13 +292,14 @@ impl<'a> Search<'a> { Excluded(right) => *r < right, Unbounded => true, } - })); + })) + .map(|r| r.and_then(|(key, lazy)| lazy.decode().map(|data| (key, data)))); debug!("Iterating between {:?} and {:?} (level {})", left, right, level); for (i, result) in iter.enumerate() { - let ((_fid, _level, l, r), docids) = result?; - debug!("{:?} to {:?} (level {}) found {} documents", l, r, _level, docids.len()); + let ((_fid, level, l, r), docids) = result?; + debug!("{:?} to {:?} (level {}) found {} documents", l, r, level, docids.len()); output.union_with(&docids); // We save the leftest and rightest bounds we actually found at this level. if i == 0 { left_found = Some(l); }