From 20e55a871bbe3533731313b522b6248ec1ca1b9b Mon Sep 17 00:00:00 2001 From: hanbings Date: Wed, 3 Jul 2024 17:06:14 -0400 Subject: [PATCH 1/3] Make milli use edition 2021 --- milli/Cargo.toml | 2 +- milli/src/snapshot_tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/milli/Cargo.toml b/milli/Cargo.toml index fd7bde99b..b2cebb95d 100644 --- a/milli/Cargo.toml +++ b/milli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "milli" -edition = "2018" +edition = "2021" publish = false version.workspace = true diff --git a/milli/src/snapshot_tests.rs b/milli/src/snapshot_tests.rs index d79003747..6635ab2f4 100644 --- a/milli/src/snapshot_tests.rs +++ b/milli/src/snapshot_tests.rs @@ -535,7 +535,7 @@ pub fn convert_snap_to_hash_if_needed<'snap>( #[macro_export] macro_rules! make_db_snap_from_iter { - ($index:ident, $name:ident, |$vars:pat| $push:block) => {{ + ($index:ident, $name:ident, |$vars:pat_param| $push:block) => {{ let rtxn = $index.read_txn().unwrap(); let iter = $index.$name.iter(&rtxn).unwrap(); let mut snap = String::new(); From ecda7af89f72e3a028f5b2ecc22833bb9d42fc97 Mon Sep 17 00:00:00 2001 From: hanbings Date: Thu, 4 Jul 2024 07:57:56 -0400 Subject: [PATCH 2/3] Add lifetime annotations to milli. --- milli/src/documents/enriched.rs | 2 +- milli/src/documents/mod.rs | 6 +- milli/src/documents/primary_key.rs | 2 +- milli/src/documents/reader.rs | 4 +- milli/src/documents/serde_impl.rs | 2 +- milli/src/external_documents_ids.rs | 10 +- milli/src/facet/facet_type.rs | 4 +- milli/src/heed_codec/beu16_str_codec.rs | 2 +- milli/src/heed_codec/beu32_str_codec.rs | 2 +- .../facet/field_doc_id_facet_codec.rs | 2 +- .../src/heed_codec/facet/ordered_f64_codec.rs | 2 +- .../heed_codec/field_id_word_count_codec.rs | 2 +- milli/src/heed_codec/obkv_codec.rs | 2 +- .../roaring_bitmap/bo_roaring_bitmap_codec.rs | 2 +- .../cbo_roaring_bitmap_codec.rs | 2 +- .../roaring_bitmap/roaring_bitmap_codec.rs | 2 +- milli/src/heed_codec/script_language_codec.rs | 2 +- milli/src/heed_codec/str_beu32_codec.rs | 4 +- milli/src/heed_codec/str_str_u8_codec.rs | 4 +- milli/src/index.rs | 240 +++++++++--------- milli/src/lib.rs | 4 +- milli/src/search/facet/facet_distribution.rs | 4 +- milli/src/search/facet/filter.rs | 8 +- milli/src/search/facet/mod.rs | 8 +- milli/src/search/mod.rs | 4 +- milli/src/search/new/db_cache.rs | 6 +- milli/src/search/new/distinct.rs | 10 +- milli/src/search/new/geo_sort.rs | 6 +- .../search/new/graph_based_ranking_rule.rs | 2 +- milli/src/search/new/logger/mod.rs | 12 +- milli/src/search/new/logger/visual.rs | 10 +- .../src/search/new/matches/matching_words.rs | 8 +- milli/src/search/new/matches/mod.rs | 6 +- milli/src/search/new/mod.rs | 22 +- milli/src/search/new/query_graph.rs | 10 +- .../new/query_term/compute_derivations.rs | 18 +- milli/src/search/new/query_term/mod.rs | 20 +- .../src/search/new/query_term/parse_query.rs | 10 +- milli/src/search/new/query_term/phrase.rs | 4 +- .../search/new/ranking_rule_graph/build.rs | 2 +- .../new/ranking_rule_graph/cheapest_paths.rs | 14 +- .../condition_docids_cache.rs | 2 +- .../new/ranking_rule_graph/exactness/mod.rs | 6 +- .../search/new/ranking_rule_graph/fid/mod.rs | 4 +- .../src/search/new/ranking_rule_graph/mod.rs | 4 +- .../new/ranking_rule_graph/position/mod.rs | 4 +- .../new/ranking_rule_graph/proximity/build.rs | 2 +- .../proximity/compute_docids.rs | 10 +- .../new/ranking_rule_graph/proximity/mod.rs | 4 +- .../search/new/ranking_rule_graph/typo/mod.rs | 4 +- .../new/ranking_rule_graph/words/mod.rs | 4 +- milli/src/search/new/resolve_query_graph.rs | 10 +- milli/src/search/new/sort.rs | 6 +- milli/src/search/new/tests/distinct.rs | 2 +- milli/src/search/new/tests/mod.rs | 2 +- milli/src/search/new/vector_sort.rs | 2 +- milli/src/update/del_add.rs | 10 +- milli/src/update/facet/bulk.rs | 14 +- milli/src/update/facet/incremental.rs | 20 +- milli/src/update/facet/mod.rs | 14 +- milli/src/update/index_documents/enrich.rs | 6 +- .../extract/extract_docid_word_positions.rs | 10 +- .../extract/extract_geo_points.rs | 2 +- .../index_documents/helpers/grenad_helpers.rs | 2 +- .../helpers/merge_functions.rs | 4 +- milli/src/update/index_documents/mod.rs | 2 +- milli/src/update/index_documents/transform.rs | 24 +- .../src/update/index_documents/typed_chunk.rs | 8 +- milli/src/update/settings.rs | 12 +- milli/src/vector/mod.rs | 2 +- milli/src/vector/parsed_vectors.rs | 8 +- 71 files changed, 345 insertions(+), 345 deletions(-) diff --git a/milli/src/documents/enriched.rs b/milli/src/documents/enriched.rs index 4e1320c6c..609765068 100644 --- a/milli/src/documents/enriched.rs +++ b/milli/src/documents/enriched.rs @@ -95,7 +95,7 @@ impl EnrichedDocumentsBatchCursor { /// `next_document` advance the document reader until all the documents have been read. pub fn next_enriched_document( &mut self, - ) -> Result, DocumentsBatchCursorError> { + ) -> Result>, DocumentsBatchCursorError> { let document = self.documents.next_document()?; let document_id = match self.external_ids.move_on_next()? { Some((_, bytes)) => serde_json::from_slice(bytes).map(Some)?, diff --git a/milli/src/documents/mod.rs b/milli/src/documents/mod.rs index 76be61275..f4509256d 100644 --- a/milli/src/documents/mod.rs +++ b/milli/src/documents/mod.rs @@ -27,7 +27,7 @@ use crate::{FieldId, Object, Result}; const DOCUMENTS_BATCH_INDEX_KEY: [u8; 8] = u64::MAX.to_be_bytes(); /// Helper function to convert an obkv reader into a JSON object. -pub fn obkv_to_object(obkv: &KvReader, index: &DocumentsBatchIndex) -> Result { +pub fn obkv_to_object(obkv: &KvReader<'_, FieldId>, index: &DocumentsBatchIndex) -> Result { obkv.iter() .map(|(field_id, value)| { let field_name = index @@ -64,7 +64,7 @@ impl DocumentsBatchIndex { self.0.len() } - pub fn iter(&self) -> bimap::hash::Iter { + pub fn iter(&self) -> bimap::hash::Iter<'_, FieldId, String> { self.0.iter() } @@ -76,7 +76,7 @@ impl DocumentsBatchIndex { self.0.get_by_right(name).cloned() } - pub fn recreate_json(&self, document: &obkv::KvReaderU16) -> Result { + pub fn recreate_json(&self, document: &obkv::KvReaderU16<'_>) -> Result { let mut map = Object::new(); for (k, v) in document.iter() { diff --git a/milli/src/documents/primary_key.rs b/milli/src/documents/primary_key.rs index 22918f8fc..64131af40 100644 --- a/milli/src/documents/primary_key.rs +++ b/milli/src/documents/primary_key.rs @@ -52,7 +52,7 @@ impl<'a> PrimaryKey<'a> { pub fn document_id( &self, - document: &obkv::KvReader, + document: &obkv::KvReader<'_, FieldId>, fields: &impl FieldIdMapper, ) -> Result> { match self { diff --git a/milli/src/documents/reader.rs b/milli/src/documents/reader.rs index d5eda69d4..c7c125c80 100644 --- a/milli/src/documents/reader.rs +++ b/milli/src/documents/reader.rs @@ -76,7 +76,7 @@ impl DocumentsBatchCursor { /// `next_document` advance the document reader until all the documents have been read. pub fn next_document( &mut self, - ) -> Result>, DocumentsBatchCursorError> { + ) -> Result>, DocumentsBatchCursorError> { match self.cursor.move_on_next()? { Some((key, value)) if key != DOCUMENTS_BATCH_INDEX_KEY => { Ok(Some(KvReader::new(value))) @@ -108,7 +108,7 @@ impl From for DocumentsBatchCursorError { impl error::Error for DocumentsBatchCursorError {} impl fmt::Display for DocumentsBatchCursorError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { DocumentsBatchCursorError::Grenad(e) => e.fmt(f), DocumentsBatchCursorError::SerdeJson(e) => e.fmt(f), diff --git a/milli/src/documents/serde_impl.rs b/milli/src/documents/serde_impl.rs index d4abdc844..e9fc541e5 100644 --- a/milli/src/documents/serde_impl.rs +++ b/milli/src/documents/serde_impl.rs @@ -56,7 +56,7 @@ impl<'a, 'de, W: Write> Visitor<'de> for &mut DocumentVisitor<'a, W> { Ok(Ok(())) } - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "a documents, or a sequence of documents.") } } diff --git a/milli/src/external_documents_ids.rs b/milli/src/external_documents_ids.rs index 361617826..2c63087f0 100644 --- a/milli/src/external_documents_ids.rs +++ b/milli/src/external_documents_ids.rs @@ -24,17 +24,17 @@ impl ExternalDocumentsIds { } /// Returns `true` if hard and soft external documents lists are empty. - pub fn is_empty(&self, rtxn: &RoTxn) -> heed::Result { + pub fn is_empty(&self, rtxn: &RoTxn<'_>) -> heed::Result { self.0.is_empty(rtxn).map_err(Into::into) } - pub fn get>(&self, rtxn: &RoTxn, external_id: A) -> heed::Result> { + pub fn get>(&self, rtxn: &RoTxn<'_>, external_id: A) -> heed::Result> { self.0.get(rtxn, external_id.as_ref()) } /// An helper function to debug this type, returns an `HashMap` of both, /// soft and hard fst maps, combined. - pub fn to_hash_map(&self, rtxn: &RoTxn) -> heed::Result> { + pub fn to_hash_map(&self, rtxn: &RoTxn<'_>) -> heed::Result> { let mut map = HashMap::default(); for result in self.0.iter(rtxn)? { let (external, internal) = result?; @@ -51,7 +51,7 @@ impl ExternalDocumentsIds { /// /// - If attempting to delete a document that doesn't exist /// - If attempting to create a document that already exists - pub fn apply(&self, wtxn: &mut RwTxn, operations: Vec) -> heed::Result<()> { + pub fn apply(&self, wtxn: &mut RwTxn<'_>, operations: Vec) -> heed::Result<()> { for DocumentOperation { external_id, internal_id, kind } in operations { match kind { DocumentOperationKind::Create => { @@ -69,7 +69,7 @@ impl ExternalDocumentsIds { } /// Returns an iterator over all the external ids. - pub fn iter<'t>(&self, rtxn: &'t RoTxn) -> heed::Result> { + pub fn iter<'t>(&self, rtxn: &'t RoTxn<'_>) -> heed::Result> { self.0.iter(rtxn) } } diff --git a/milli/src/facet/facet_type.rs b/milli/src/facet/facet_type.rs index 51dd448e2..4d3ff8df9 100644 --- a/milli/src/facet/facet_type.rs +++ b/milli/src/facet/facet_type.rs @@ -11,7 +11,7 @@ pub enum FacetType { } impl fmt::Display for FacetType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { FacetType::String => f.write_str("string"), FacetType::Number => f.write_str("number"), @@ -37,7 +37,7 @@ impl FromStr for FacetType { pub struct InvalidFacetType; impl fmt::Display for InvalidFacetType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(r#"Invalid facet type, must be "string" or "number""#) } } diff --git a/milli/src/heed_codec/beu16_str_codec.rs b/milli/src/heed_codec/beu16_str_codec.rs index ba04f0900..753c60fea 100644 --- a/milli/src/heed_codec/beu16_str_codec.rs +++ b/milli/src/heed_codec/beu16_str_codec.rs @@ -20,7 +20,7 @@ impl<'a> heed::BytesDecode<'a> for BEU16StrCodec { impl<'a> heed::BytesEncode<'a> for BEU16StrCodec { type EItem = (u16, &'a str); - fn bytes_encode((n, s): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((n, s): &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(s.len() + 2); bytes.extend_from_slice(&n.to_be_bytes()); bytes.extend_from_slice(s.as_bytes()); diff --git a/milli/src/heed_codec/beu32_str_codec.rs b/milli/src/heed_codec/beu32_str_codec.rs index 762e31ca4..c7686c863 100644 --- a/milli/src/heed_codec/beu32_str_codec.rs +++ b/milli/src/heed_codec/beu32_str_codec.rs @@ -20,7 +20,7 @@ impl<'a> heed::BytesDecode<'a> for BEU32StrCodec { impl<'a> heed::BytesEncode<'a> for BEU32StrCodec { type EItem = (u32, &'a str); - fn bytes_encode((n, s): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((n, s): &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(s.len() + 4); bytes.extend_from_slice(&n.to_be_bytes()); bytes.extend_from_slice(s.as_bytes()); diff --git a/milli/src/heed_codec/facet/field_doc_id_facet_codec.rs b/milli/src/heed_codec/facet/field_doc_id_facet_codec.rs index 7e281adfa..28bf932a5 100644 --- a/milli/src/heed_codec/facet/field_doc_id_facet_codec.rs +++ b/milli/src/heed_codec/facet/field_doc_id_facet_codec.rs @@ -35,7 +35,7 @@ where fn bytes_encode( (field_id, document_id, value): &'a Self::EItem, - ) -> Result, BoxedError> { + ) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(32); bytes.extend_from_slice(&field_id.to_be_bytes()); // 2 bytes bytes.extend_from_slice(&document_id.to_be_bytes()); // 4 bytes diff --git a/milli/src/heed_codec/facet/ordered_f64_codec.rs b/milli/src/heed_codec/facet/ordered_f64_codec.rs index b692b2363..4eccdb68b 100644 --- a/milli/src/heed_codec/facet/ordered_f64_codec.rs +++ b/milli/src/heed_codec/facet/ordered_f64_codec.rs @@ -24,7 +24,7 @@ impl<'a> BytesDecode<'a> for OrderedF64Codec { impl heed::BytesEncode<'_> for OrderedF64Codec { type EItem = f64; - fn bytes_encode(f: &Self::EItem) -> Result, BoxedError> { + fn bytes_encode(f: &Self::EItem) -> Result, BoxedError> { let mut buffer = [0u8; 16]; // write the globally ordered float diff --git a/milli/src/heed_codec/field_id_word_count_codec.rs b/milli/src/heed_codec/field_id_word_count_codec.rs index 19d8d63c6..39dee3b4a 100644 --- a/milli/src/heed_codec/field_id_word_count_codec.rs +++ b/milli/src/heed_codec/field_id_word_count_codec.rs @@ -21,7 +21,7 @@ impl<'a> heed::BytesDecode<'a> for FieldIdWordCountCodec { impl<'a> heed::BytesEncode<'a> for FieldIdWordCountCodec { type EItem = (FieldId, u8); - fn bytes_encode((field_id, word_count): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((field_id, word_count): &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(2 + 1); bytes.extend_from_slice(&field_id.to_be_bytes()); bytes.push(*word_count); diff --git a/milli/src/heed_codec/obkv_codec.rs b/milli/src/heed_codec/obkv_codec.rs index d2408c87d..390a57af3 100644 --- a/milli/src/heed_codec/obkv_codec.rs +++ b/milli/src/heed_codec/obkv_codec.rs @@ -16,7 +16,7 @@ impl<'a> heed::BytesDecode<'a> for ObkvCodec { impl heed::BytesEncode<'_> for ObkvCodec { type EItem = KvWriterU16>; - fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { + fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { item.clone().into_inner().map(Cow::Owned).map_err(Into::into) } } diff --git a/milli/src/heed_codec/roaring_bitmap/bo_roaring_bitmap_codec.rs b/milli/src/heed_codec/roaring_bitmap/bo_roaring_bitmap_codec.rs index c5e7e3e89..a89b35fa6 100644 --- a/milli/src/heed_codec/roaring_bitmap/bo_roaring_bitmap_codec.rs +++ b/milli/src/heed_codec/roaring_bitmap/bo_roaring_bitmap_codec.rs @@ -42,7 +42,7 @@ impl BytesDecodeOwned for BoRoaringBitmapCodec { impl heed::BytesEncode<'_> for BoRoaringBitmapCodec { type EItem = RoaringBitmap; - fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { + fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { let mut out = Vec::new(); BoRoaringBitmapCodec::serialize_into(item, &mut out); Ok(Cow::Owned(out)) diff --git a/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs b/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs index a04698019..fa65d5217 100644 --- a/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs +++ b/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs @@ -167,7 +167,7 @@ impl BytesDecodeOwned for CboRoaringBitmapCodec { impl heed::BytesEncode<'_> for CboRoaringBitmapCodec { type EItem = RoaringBitmap; - fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { + fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { let mut vec = Vec::with_capacity(Self::serialized_size(item)); Self::serialize_into(item, &mut vec); Ok(Cow::Owned(vec)) diff --git a/milli/src/heed_codec/roaring_bitmap/roaring_bitmap_codec.rs b/milli/src/heed_codec/roaring_bitmap/roaring_bitmap_codec.rs index aa532ffdd..764e10cd6 100644 --- a/milli/src/heed_codec/roaring_bitmap/roaring_bitmap_codec.rs +++ b/milli/src/heed_codec/roaring_bitmap/roaring_bitmap_codec.rs @@ -26,7 +26,7 @@ impl BytesDecodeOwned for RoaringBitmapCodec { impl heed::BytesEncode<'_> for RoaringBitmapCodec { type EItem = RoaringBitmap; - fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { + fn bytes_encode(item: &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(item.serialized_size()); item.serialize_into(&mut bytes)?; Ok(Cow::Owned(bytes)) diff --git a/milli/src/heed_codec/script_language_codec.rs b/milli/src/heed_codec/script_language_codec.rs index ef2ad4bec..35f7af3c7 100644 --- a/milli/src/heed_codec/script_language_codec.rs +++ b/milli/src/heed_codec/script_language_codec.rs @@ -25,7 +25,7 @@ impl<'a> heed::BytesDecode<'a> for ScriptLanguageCodec { impl<'a> heed::BytesEncode<'a> for ScriptLanguageCodec { type EItem = (Script, Language); - fn bytes_encode((script, lan): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((script, lan): &Self::EItem) -> Result, BoxedError> { let script_name = script.name().as_bytes(); let lan_name = lan.name().as_bytes(); diff --git a/milli/src/heed_codec/str_beu32_codec.rs b/milli/src/heed_codec/str_beu32_codec.rs index e3ffddcd6..4e305cae7 100644 --- a/milli/src/heed_codec/str_beu32_codec.rs +++ b/milli/src/heed_codec/str_beu32_codec.rs @@ -30,7 +30,7 @@ impl<'a> heed::BytesDecode<'a> for StrBEU32Codec { impl<'a> heed::BytesEncode<'a> for StrBEU32Codec { type EItem = (&'a str, u32); - fn bytes_encode((word, pos): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((word, pos): &Self::EItem) -> Result, BoxedError> { let pos = pos.to_be_bytes(); let mut bytes = Vec::with_capacity(word.len() + pos.len()); @@ -66,7 +66,7 @@ impl<'a> heed::BytesDecode<'a> for StrBEU16Codec { impl<'a> heed::BytesEncode<'a> for StrBEU16Codec { type EItem = (&'a str, u16); - fn bytes_encode((word, pos): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((word, pos): &Self::EItem) -> Result, BoxedError> { let pos = pos.to_be_bytes(); let mut bytes = Vec::with_capacity(word.len() + 1 + pos.len()); diff --git a/milli/src/heed_codec/str_str_u8_codec.rs b/milli/src/heed_codec/str_str_u8_codec.rs index 0aedf0c94..53b853765 100644 --- a/milli/src/heed_codec/str_str_u8_codec.rs +++ b/milli/src/heed_codec/str_str_u8_codec.rs @@ -24,7 +24,7 @@ impl<'a> heed::BytesDecode<'a> for U8StrStrCodec { impl<'a> heed::BytesEncode<'a> for U8StrStrCodec { type EItem = (u8, &'a str, &'a str); - fn bytes_encode((n, s1, s2): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((n, s1, s2): &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(s1.len() + s2.len() + 1); bytes.push(*n); bytes.extend_from_slice(s1.as_bytes()); @@ -51,7 +51,7 @@ impl<'a> heed::BytesDecode<'a> for UncheckedU8StrStrCodec { impl<'a> heed::BytesEncode<'a> for UncheckedU8StrStrCodec { type EItem = (u8, &'a [u8], &'a [u8]); - fn bytes_encode((n, s1, s2): &Self::EItem) -> Result, BoxedError> { + fn bytes_encode((n, s1, s2): &Self::EItem) -> Result, BoxedError> { let mut bytes = Vec::with_capacity(s1.len() + s2.len() + 1); bytes.push(*n); bytes.extend_from_slice(s1); diff --git a/milli/src/index.rs b/milli/src/index.rs index 0a7a20ce0..d9fc07b54 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -287,12 +287,12 @@ impl Index { } /// Create a write transaction to be able to write into the index. - pub fn write_txn(&self) -> heed::Result { + pub fn write_txn(&self) -> heed::Result> { self.env.write_txn() } /// Create a read transaction to be able to read the index. - pub fn read_txn(&self) -> heed::Result { + pub fn read_txn(&self) -> heed::Result> { self.env.read_txn() } @@ -344,7 +344,7 @@ impl Index { /// Writes the documents ids that corresponds to the user-ids-documents-ids FST. pub(crate) fn put_documents_ids( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, docids: &RoaringBitmap, ) -> heed::Result<()> { self.main.remap_types::().put( @@ -355,7 +355,7 @@ impl Index { } /// Returns the internal documents ids. - pub fn documents_ids(&self, rtxn: &RoTxn) -> heed::Result { + pub fn documents_ids(&self, rtxn: &RoTxn<'_>) -> heed::Result { Ok(self .main .remap_types::() @@ -364,7 +364,7 @@ impl Index { } /// Returns the number of documents indexed in the database. - pub fn number_of_documents(&self, rtxn: &RoTxn) -> Result { + pub fn number_of_documents(&self, rtxn: &RoTxn<'_>) -> Result { let count = self .main .remap_types::() @@ -375,18 +375,18 @@ impl Index { /* primary key */ /// Writes the documents primary key, this is the field name that is used to store the id. - pub(crate) fn put_primary_key(&self, wtxn: &mut RwTxn, primary_key: &str) -> heed::Result<()> { + pub(crate) fn put_primary_key(&self, wtxn: &mut RwTxn<'_>, primary_key: &str) -> heed::Result<()> { self.set_updated_at(wtxn, &OffsetDateTime::now_utc())?; self.main.remap_types::().put(wtxn, main_key::PRIMARY_KEY_KEY, primary_key) } /// Deletes the primary key of the documents, this can be done to reset indexes settings. - pub(crate) fn delete_primary_key(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_primary_key(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::PRIMARY_KEY_KEY) } /// Returns the documents primary key, `None` if it hasn't been defined. - pub fn primary_key<'t>(&self, rtxn: &'t RoTxn) -> heed::Result> { + pub fn primary_key<'t>(&self, rtxn: &'t RoTxn<'_>) -> heed::Result> { self.main.remap_types::().get(rtxn, main_key::PRIMARY_KEY_KEY) } @@ -404,7 +404,7 @@ impl Index { /// (i.e. `u8`), this field id is used to identify fields in the obkv documents. pub(crate) fn put_fields_ids_map( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, map: &FieldsIdsMap, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -416,7 +416,7 @@ impl Index { /// Returns the fields ids map which associate the documents keys with an internal field id /// (i.e. `u8`), this field id is used to identify fields in the obkv documents. - pub fn fields_ids_map(&self, rtxn: &RoTxn) -> heed::Result { + pub fn fields_ids_map(&self, rtxn: &RoTxn<'_>) -> heed::Result { Ok(self .main .remap_types::>() @@ -431,7 +431,7 @@ impl Index { /// Writes the fieldids weights map which associates the field ids to their weights pub(crate) fn put_fieldids_weights_map( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, map: &FieldidsWeightsMap, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -442,7 +442,7 @@ impl Index { } /// Get the fieldids weights map which associates the field ids to their weights - pub fn fieldids_weights_map(&self, rtxn: &RoTxn) -> heed::Result { + pub fn fieldids_weights_map(&self, rtxn: &RoTxn<'_>) -> heed::Result { self.main .remap_types::>() .get(rtxn, main_key::FIELDIDS_WEIGHTS_MAP_KEY)? @@ -455,13 +455,13 @@ impl Index { } /// Delete the fieldsids weights map - pub fn delete_fieldids_weights_map(&self, wtxn: &mut RwTxn) -> heed::Result { + pub fn delete_fieldids_weights_map(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::FIELDIDS_WEIGHTS_MAP_KEY) } pub fn searchable_fields_and_weights<'a>( &self, - rtxn: &'a RoTxn, + rtxn: &'a RoTxn<'a>, ) -> Result, FieldId, Weight)>> { let fid_map = self.fields_ids_map(rtxn)?; let weight_map = self.fieldids_weights_map(rtxn)?; @@ -488,7 +488,7 @@ impl Index { /// Writes the provided `rtree` which associates coordinates to documents ids. pub(crate) fn put_geo_rtree( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, rtree: &RTree, ) -> heed::Result<()> { self.main.remap_types::>>().put( @@ -499,12 +499,12 @@ impl Index { } /// Delete the `rtree` which associates coordinates to documents ids. - pub(crate) fn delete_geo_rtree(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_geo_rtree(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::GEO_RTREE_KEY) } /// Returns the `rtree` which associates coordinates to documents ids. - pub fn geo_rtree(&self, rtxn: &RoTxn) -> Result>> { + pub fn geo_rtree(&self, rtxn: &RoTxn<'_>) -> Result>> { match self .main .remap_types::>>() @@ -520,7 +520,7 @@ impl Index { /// Writes the documents ids that are faceted with a _geo field. pub(crate) fn put_geo_faceted_documents_ids( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, docids: &RoaringBitmap, ) -> heed::Result<()> { self.main.remap_types::().put( @@ -531,12 +531,12 @@ impl Index { } /// Delete the documents ids that are faceted with a _geo field. - pub(crate) fn delete_geo_faceted_documents_ids(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_geo_faceted_documents_ids(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::GEO_FACETED_DOCUMENTS_IDS_KEY) } /// Retrieve all the documents ids that are faceted with a _geo field. - pub fn geo_faceted_documents_ids(&self, rtxn: &RoTxn) -> heed::Result { + pub fn geo_faceted_documents_ids(&self, rtxn: &RoTxn<'_>) -> heed::Result { match self .main .remap_types::() @@ -552,7 +552,7 @@ impl Index { /// the number of times it occurs in the documents. pub(crate) fn put_field_distribution( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, distribution: &FieldDistribution, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -564,7 +564,7 @@ impl Index { /// Returns the field distribution which associates every field name with /// the number of times it occurs in the documents. - pub fn field_distribution(&self, rtxn: &RoTxn) -> heed::Result { + pub fn field_distribution(&self, rtxn: &RoTxn<'_>) -> heed::Result { Ok(self .main .remap_types::>() @@ -578,7 +578,7 @@ impl Index { /// There must be not be any duplicate field id. pub(crate) fn put_displayed_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fields: &[&str], ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -590,20 +590,20 @@ impl Index { /// Deletes the displayed fields ids, this will make the engine to display /// all the documents attributes in the order of the `FieldsIdsMap`. - pub(crate) fn delete_displayed_fields(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_displayed_fields(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::DISPLAYED_FIELDS_KEY) } /// Returns the displayed fields in the order they were set by the user. If it returns /// `None` it means that all the attributes are set as displayed in the order of the `FieldsIdsMap`. - pub fn displayed_fields<'t>(&self, rtxn: &'t RoTxn) -> heed::Result>> { + pub fn displayed_fields<'t>(&self, rtxn: &'t RoTxn<'_>) -> heed::Result>> { self.main .remap_types::>>() .get(rtxn, main_key::DISPLAYED_FIELDS_KEY) } /// Identical to `displayed_fields`, but returns the ids instead. - pub fn displayed_fields_ids(&self, rtxn: &RoTxn) -> Result>> { + pub fn displayed_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result>> { match self.displayed_fields(rtxn)? { Some(fields) => { let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -622,7 +622,7 @@ impl Index { /* remove hidden fields */ pub fn remove_hidden_fields( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, fields: impl IntoIterator>, ) -> Result<(BTreeSet, bool)> { let mut valid_fields = @@ -644,7 +644,7 @@ impl Index { /// Write the user defined searchable fields and generate the real searchable fields from the specified fields ids map. pub(crate) fn put_all_searchable_fields_from_fields_ids_map( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, user_fields: &[&str], non_searchable_fields_ids: &[FieldId], fields_ids_map: &FieldsIdsMap, @@ -681,7 +681,7 @@ impl Index { Ok(()) } - pub(crate) fn delete_all_searchable_fields(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_all_searchable_fields(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { let did_delete_searchable = self.delete_searchable_fields(wtxn)?; let did_delete_user_defined = self.delete_user_defined_searchable_fields(wtxn)?; self.delete_fieldids_weights_map(wtxn)?; @@ -689,7 +689,7 @@ impl Index { } /// Writes the searchable fields, when this list is specified, only these are indexed. - fn put_searchable_fields(&self, wtxn: &mut RwTxn, fields: &[&str]) -> heed::Result<()> { + fn put_searchable_fields(&self, wtxn: &mut RwTxn<'_>, fields: &[&str]) -> heed::Result<()> { self.main.remap_types::>().put( wtxn, main_key::SEARCHABLE_FIELDS_KEY, @@ -698,12 +698,12 @@ impl Index { } /// Deletes the searchable fields, when no fields are specified, all fields are indexed. - fn delete_searchable_fields(&self, wtxn: &mut RwTxn) -> heed::Result { + fn delete_searchable_fields(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::SEARCHABLE_FIELDS_KEY) } /// Returns the searchable fields, those are the fields that are indexed, - pub fn searchable_fields<'t>(&self, rtxn: &'t RoTxn) -> heed::Result>> { + pub fn searchable_fields<'t>(&self, rtxn: &'t RoTxn<'_>) -> heed::Result>> { self.main .remap_types::>>() .get(rtxn, main_key::SEARCHABLE_FIELDS_KEY)? @@ -719,7 +719,7 @@ impl Index { } /// Identical to `searchable_fields`, but returns the ids instead. - pub fn searchable_fields_ids(&self, rtxn: &RoTxn) -> Result> { + pub fn searchable_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result> { let fields = self.searchable_fields(rtxn)?; let fields_ids_map = self.fields_ids_map(rtxn)?; let mut fields_ids = Vec::new(); @@ -734,7 +734,7 @@ impl Index { /// Writes the searchable fields, when this list is specified, only these are indexed. pub(crate) fn put_user_defined_searchable_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fields: &[&str], ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -747,7 +747,7 @@ impl Index { /// Deletes the searchable fields, when no fields are specified, all fields are indexed. pub(crate) fn delete_user_defined_searchable_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, ) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::USER_DEFINED_SEARCHABLE_FIELDS_KEY) } @@ -755,7 +755,7 @@ impl Index { /// Returns the user defined searchable fields. pub fn user_defined_searchable_fields<'t>( &self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, ) -> heed::Result>> { self.main .remap_types::>>() @@ -763,7 +763,7 @@ impl Index { } /// Identical to `user_defined_searchable_fields`, but returns ids instead. - pub fn user_defined_searchable_fields_ids(&self, rtxn: &RoTxn) -> Result>> { + pub fn user_defined_searchable_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result>> { match self.user_defined_searchable_fields(rtxn)? { Some(fields) => { let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -784,7 +784,7 @@ impl Index { /// Writes the filterable fields names in the database. pub(crate) fn put_filterable_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fields: &HashSet, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -795,12 +795,12 @@ impl Index { } /// Deletes the filterable fields ids in the database. - pub(crate) fn delete_filterable_fields(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_filterable_fields(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::FILTERABLE_FIELDS_KEY) } /// Returns the filterable fields names. - pub fn filterable_fields(&self, rtxn: &RoTxn) -> heed::Result> { + pub fn filterable_fields(&self, rtxn: &RoTxn<'_>) -> heed::Result> { Ok(self .main .remap_types::>() @@ -809,7 +809,7 @@ impl Index { } /// Identical to `filterable_fields`, but returns ids instead. - pub fn filterable_fields_ids(&self, rtxn: &RoTxn) -> Result> { + pub fn filterable_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result> { let fields = self.filterable_fields(rtxn)?; let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -828,7 +828,7 @@ impl Index { /// Writes the sortable fields names in the database. pub(crate) fn put_sortable_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fields: &HashSet, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -839,12 +839,12 @@ impl Index { } /// Deletes the sortable fields ids in the database. - pub(crate) fn delete_sortable_fields(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_sortable_fields(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::SORTABLE_FIELDS_KEY) } /// Returns the sortable fields names. - pub fn sortable_fields(&self, rtxn: &RoTxn) -> heed::Result> { + pub fn sortable_fields(&self, rtxn: &RoTxn<'_>) -> heed::Result> { Ok(self .main .remap_types::>() @@ -853,7 +853,7 @@ impl Index { } /// Identical to `sortable_fields`, but returns ids instead. - pub fn sortable_fields_ids(&self, rtxn: &RoTxn) -> Result> { + pub fn sortable_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result> { let fields = self.sortable_fields(rtxn)?; let fields_ids_map = self.fields_ids_map(rtxn)?; Ok(fields.into_iter().filter_map(|name| fields_ids_map.id(&name)).collect()) @@ -864,7 +864,7 @@ impl Index { /// Writes the faceted fields in the database. pub(crate) fn put_faceted_fields( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fields: &HashSet, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -875,7 +875,7 @@ impl Index { } /// Returns the faceted fields names. - pub fn faceted_fields(&self, rtxn: &RoTxn) -> heed::Result> { + pub fn faceted_fields(&self, rtxn: &RoTxn<'_>) -> heed::Result> { Ok(self .main .remap_types::>() @@ -884,7 +884,7 @@ impl Index { } /// Identical to `faceted_fields`, but returns ids instead. - pub fn faceted_fields_ids(&self, rtxn: &RoTxn) -> Result> { + pub fn faceted_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result> { let fields = self.faceted_fields(rtxn)?; let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -903,7 +903,7 @@ impl Index { /// Returns the user defined faceted fields names. /// /// The user faceted fields are the union of all the filterable, sortable, distinct, and Asc/Desc fields. - pub fn user_defined_faceted_fields(&self, rtxn: &RoTxn) -> Result> { + pub fn user_defined_faceted_fields(&self, rtxn: &RoTxn<'_>) -> Result> { let filterable_fields = self.filterable_fields(rtxn)?; let sortable_fields = self.sortable_fields(rtxn)?; let distinct_field = self.distinct_field(rtxn)?; @@ -924,7 +924,7 @@ impl Index { } /// Identical to `user_defined_faceted_fields`, but returns ids instead. - pub fn user_defined_faceted_fields_ids(&self, rtxn: &RoTxn) -> Result> { + pub fn user_defined_faceted_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result> { let fields = self.user_defined_faceted_fields(rtxn)?; let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -943,7 +943,7 @@ impl Index { /// Retrieve all the documents which contain this field id set as null pub fn null_faceted_documents_ids( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, field_id: FieldId, ) -> heed::Result { match self.facet_id_is_null_docids.get(rtxn, &field_id)? { @@ -955,7 +955,7 @@ impl Index { /// Retrieve all the documents which contain this field id and that is considered empty pub fn empty_faceted_documents_ids( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, field_id: FieldId, ) -> heed::Result { match self.facet_id_is_empty_docids.get(rtxn, &field_id)? { @@ -967,7 +967,7 @@ impl Index { /// Retrieve all the documents which contain this field id pub fn exists_faceted_documents_ids( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, field_id: FieldId, ) -> heed::Result { match self.facet_id_exists_docids.get(rtxn, &field_id)? { @@ -980,17 +980,17 @@ impl Index { pub(crate) fn put_distinct_field( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, distinct_field: &str, ) -> heed::Result<()> { self.main.remap_types::().put(wtxn, main_key::DISTINCT_FIELD_KEY, distinct_field) } - pub fn distinct_field<'a>(&self, rtxn: &'a RoTxn) -> heed::Result> { + pub fn distinct_field<'a>(&self, rtxn: &'a RoTxn<'_>) -> heed::Result> { self.main.remap_types::().get(rtxn, main_key::DISTINCT_FIELD_KEY) } - pub(crate) fn delete_distinct_field(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_distinct_field(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::DISTINCT_FIELD_KEY) } @@ -998,7 +998,7 @@ impl Index { pub(crate) fn put_criteria( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, criteria: &[Criterion], ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -1008,11 +1008,11 @@ impl Index { ) } - pub(crate) fn delete_criteria(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_criteria(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::CRITERIA_KEY) } - pub fn criteria(&self, rtxn: &RoTxn) -> heed::Result> { + pub fn criteria(&self, rtxn: &RoTxn<'_>) -> heed::Result> { match self .main .remap_types::>>() @@ -1028,7 +1028,7 @@ impl Index { /// Writes the FST which is the words dictionary of the engine. pub(crate) fn put_words_fst>( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fst: &fst::Set, ) -> heed::Result<()> { self.main.remap_types::().put( @@ -1039,7 +1039,7 @@ impl Index { } /// Returns the FST which is the words dictionary of the engine. - pub fn words_fst<'t>(&self, rtxn: &'t RoTxn) -> Result>> { + pub fn words_fst<'t>(&self, rtxn: &'t RoTxn<'_>) -> Result>> { match self.main.remap_types::().get(rtxn, main_key::WORDS_FST_KEY)? { Some(bytes) => Ok(fst::Set::new(bytes)?.map_data(Cow::Borrowed)?), None => Ok(fst::Set::default().map_data(Cow::Owned)?), @@ -1050,7 +1050,7 @@ impl Index { pub(crate) fn put_stop_words>( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fst: &fst::Set, ) -> heed::Result<()> { self.main.remap_types::().put( @@ -1060,11 +1060,11 @@ impl Index { ) } - pub(crate) fn delete_stop_words(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_stop_words(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::STOP_WORDS_KEY) } - pub fn stop_words<'t>(&self, rtxn: &'t RoTxn) -> Result>> { + pub fn stop_words<'t>(&self, rtxn: &'t RoTxn<'t>) -> Result>> { match self.main.remap_types::().get(rtxn, main_key::STOP_WORDS_KEY)? { Some(bytes) => Ok(Some(fst::Set::new(bytes)?)), None => Ok(None), @@ -1075,7 +1075,7 @@ impl Index { pub(crate) fn put_non_separator_tokens( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, set: &BTreeSet, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -1085,11 +1085,11 @@ impl Index { ) } - pub(crate) fn delete_non_separator_tokens(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_non_separator_tokens(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::NON_SEPARATOR_TOKENS_KEY) } - pub fn non_separator_tokens(&self, rtxn: &RoTxn) -> Result>> { + pub fn non_separator_tokens(&self, rtxn: &RoTxn<'_>) -> Result>> { Ok(self .main .remap_types::>>() @@ -1100,7 +1100,7 @@ impl Index { pub(crate) fn put_separator_tokens( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, set: &BTreeSet, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -1110,11 +1110,11 @@ impl Index { ) } - pub(crate) fn delete_separator_tokens(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_separator_tokens(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::SEPARATOR_TOKENS_KEY) } - pub fn separator_tokens(&self, rtxn: &RoTxn) -> Result>> { + pub fn separator_tokens(&self, rtxn: &RoTxn<'_>) -> Result>> { Ok(self .main .remap_types::>>() @@ -1123,7 +1123,7 @@ impl Index { /* separators easing method */ - pub fn allowed_separators(&self, rtxn: &RoTxn) -> Result>> { + pub fn allowed_separators(&self, rtxn: &RoTxn<'_>) -> Result>> { let default_separators = charabia::separators::DEFAULT_SEPARATORS.iter().map(|s| s.to_string()); let mut separators: Option> = None; @@ -1145,17 +1145,17 @@ impl Index { pub(crate) fn put_dictionary( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, set: &BTreeSet, ) -> heed::Result<()> { self.main.remap_types::>().put(wtxn, main_key::DICTIONARY_KEY, set) } - pub(crate) fn delete_dictionary(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_dictionary(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::DICTIONARY_KEY) } - pub fn dictionary(&self, rtxn: &RoTxn) -> Result>> { + pub fn dictionary(&self, rtxn: &RoTxn<'_>) -> Result>> { Ok(self .main .remap_types::>>() @@ -1166,7 +1166,7 @@ impl Index { pub(crate) fn put_synonyms( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, synonyms: &HashMap, Vec>>, user_defined_synonyms: &BTreeMap>, ) -> heed::Result<()> { @@ -1182,14 +1182,14 @@ impl Index { ) } - pub(crate) fn delete_synonyms(&self, wtxn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_synonyms(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::SYNONYMS_KEY)?; self.main.remap_key_type::().delete(wtxn, main_key::USER_DEFINED_SYNONYMS_KEY) } pub fn user_defined_synonyms( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, ) -> heed::Result>> { Ok(self .main @@ -1198,7 +1198,7 @@ impl Index { .unwrap_or_default()) } - pub fn synonyms(&self, rtxn: &RoTxn) -> heed::Result, Vec>>> { + pub fn synonyms(&self, rtxn: &RoTxn<'_>) -> heed::Result, Vec>>> { Ok(self .main .remap_types::>() @@ -1208,7 +1208,7 @@ impl Index { pub fn words_synonyms>( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, words: &[S], ) -> heed::Result>>> { let words: Vec<_> = words.iter().map(|s| s.as_ref().to_owned()).collect(); @@ -1220,7 +1220,7 @@ impl Index { /// Writes the FST which is the words prefixes dictionary of the engine. pub(crate) fn put_words_prefixes_fst>( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, fst: &fst::Set, ) -> heed::Result<()> { self.main.remap_types::().put( @@ -1231,7 +1231,7 @@ impl Index { } /// Returns the FST which is the words prefixes dictionary of the engine. - pub fn words_prefixes_fst<'t>(&self, rtxn: &'t RoTxn) -> Result>> { + pub fn words_prefixes_fst<'t>(&self, rtxn: &'t RoTxn<'t>) -> Result>> { match self.main.remap_types::().get(rtxn, main_key::WORDS_PREFIXES_FST_KEY)? { Some(bytes) => Ok(fst::Set::new(bytes)?.map_data(Cow::Borrowed)?), None => Ok(fst::Set::default().map_data(Cow::Owned)?), @@ -1242,7 +1242,7 @@ impl Index { /// Returns the number of documents ids associated with the given word, /// it is much faster than deserializing the bitmap and getting the length of it. - pub fn word_documents_count(&self, rtxn: &RoTxn, word: &str) -> heed::Result> { + pub fn word_documents_count(&self, rtxn: &RoTxn<'_>, word: &str) -> heed::Result> { self.word_docids.remap_data_type::().get(rtxn, word) } @@ -1251,7 +1251,7 @@ impl Index { /// Returns an iterator over the requested documents. The next item will be an error if a document is missing. pub fn iter_documents<'a, 't: 'a>( &'a self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, ids: impl IntoIterator + 'a, ) -> Result)>> + 'a> { Ok(ids.into_iter().map(move |id| { @@ -1266,7 +1266,7 @@ impl Index { /// Returns a [`Vec`] of the requested documents. Returns an error if a document is missing. pub fn documents<'t>( &self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, ids: impl IntoIterator, ) -> Result)>> { self.iter_documents(rtxn, ids)?.collect() @@ -1275,14 +1275,14 @@ impl Index { /// Returns an iterator over all the documents in the index. pub fn all_documents<'a, 't: 'a>( &'a self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, ) -> Result)>> + 'a> { self.iter_documents(rtxn, self.documents_ids(rtxn)?) } pub fn external_id_of<'a, 't: 'a>( &'a self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, ids: impl IntoIterator + 'a, ) -> Result> + 'a> { let fields = self.fields_ids_map(rtxn)?; @@ -1310,16 +1310,16 @@ impl Index { })) } - pub fn facets_distribution<'a>(&'a self, rtxn: &'a RoTxn) -> FacetDistribution<'a> { + pub fn facets_distribution<'a>(&'a self, rtxn: &'a RoTxn<'a>) -> FacetDistribution<'a> { FacetDistribution::new(rtxn, self) } - pub fn search<'a>(&'a self, rtxn: &'a RoTxn) -> Search<'a> { + pub fn search<'a>(&'a self, rtxn: &'a RoTxn<'a>) -> Search<'a> { Search::new(rtxn, self) } /// Returns the index creation time. - pub fn created_at(&self, rtxn: &RoTxn) -> Result { + pub fn created_at(&self, rtxn: &RoTxn<'_>) -> Result { Ok(self .main .remap_types::>() @@ -1331,7 +1331,7 @@ impl Index { } /// Returns the index last updated time. - pub fn updated_at(&self, rtxn: &RoTxn) -> Result { + pub fn updated_at(&self, rtxn: &RoTxn<'_>) -> Result { Ok(self .main .remap_types::>() @@ -1344,7 +1344,7 @@ impl Index { pub(crate) fn set_updated_at( &self, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, time: &OffsetDateTime, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -1354,7 +1354,7 @@ impl Index { ) } - pub fn authorize_typos(&self, txn: &RoTxn) -> heed::Result { + pub fn authorize_typos(&self, txn: &RoTxn<'_>) -> heed::Result { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1364,7 +1364,7 @@ impl Index { } } - pub(crate) fn put_authorize_typos(&self, txn: &mut RwTxn, flag: bool) -> heed::Result<()> { + pub(crate) fn put_authorize_typos(&self, txn: &mut RwTxn<'_>, flag: bool) -> heed::Result<()> { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1373,7 +1373,7 @@ impl Index { Ok(()) } - pub fn min_word_len_one_typo(&self, txn: &RoTxn) -> heed::Result { + pub fn min_word_len_one_typo(&self, txn: &RoTxn<'_>) -> heed::Result { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1384,7 +1384,7 @@ impl Index { .unwrap_or(DEFAULT_MIN_WORD_LEN_ONE_TYPO)) } - pub(crate) fn put_min_word_len_one_typo(&self, txn: &mut RwTxn, val: u8) -> heed::Result<()> { + pub(crate) fn put_min_word_len_one_typo(&self, txn: &mut RwTxn<'_>, val: u8) -> heed::Result<()> { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1392,7 +1392,7 @@ impl Index { Ok(()) } - pub fn min_word_len_two_typos(&self, txn: &RoTxn) -> heed::Result { + pub fn min_word_len_two_typos(&self, txn: &RoTxn<'_>) -> heed::Result { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1403,7 +1403,7 @@ impl Index { .unwrap_or(DEFAULT_MIN_WORD_LEN_TWO_TYPOS)) } - pub(crate) fn put_min_word_len_two_typos(&self, txn: &mut RwTxn, val: u8) -> heed::Result<()> { + pub(crate) fn put_min_word_len_two_typos(&self, txn: &mut RwTxn<'_>, val: u8) -> heed::Result<()> { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1412,7 +1412,7 @@ impl Index { } /// List the words on which typo are not allowed - pub fn exact_words<'t>(&self, txn: &'t RoTxn) -> Result>>> { + pub fn exact_words<'t>(&self, txn: &'t RoTxn<'t>) -> Result>>> { match self.main.remap_types::().get(txn, main_key::EXACT_WORDS)? { Some(bytes) => Ok(Some(fst::Set::new(bytes)?.map_data(Cow::Borrowed)?)), None => Ok(None), @@ -1421,7 +1421,7 @@ impl Index { pub(crate) fn put_exact_words>( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, words: &fst::Set, ) -> Result<()> { self.main.remap_types::().put( @@ -1433,7 +1433,7 @@ impl Index { } /// Returns the exact attributes: attributes for which typo is disallowed. - pub fn exact_attributes<'t>(&self, txn: &'t RoTxn) -> Result> { + pub fn exact_attributes<'t>(&self, txn: &'t RoTxn<'t>) -> Result> { Ok(self .main .remap_types::>>() @@ -1442,14 +1442,14 @@ impl Index { } /// Returns the list of exact attributes field ids. - pub fn exact_attributes_ids(&self, txn: &RoTxn) -> Result> { + pub fn exact_attributes_ids(&self, txn: &RoTxn<'_>) -> Result> { let attrs = self.exact_attributes(txn)?; let fid_map = self.fields_ids_map(txn)?; Ok(attrs.iter().filter_map(|attr| fid_map.id(attr)).collect()) } /// Writes the exact attributes to the database. - pub(crate) fn put_exact_attributes(&self, txn: &mut RwTxn, attrs: &[&str]) -> Result<()> { + pub(crate) fn put_exact_attributes(&self, txn: &mut RwTxn<'_>, attrs: &[&str]) -> Result<()> { self.main.remap_types::>().put( txn, main_key::EXACT_ATTRIBUTES, @@ -1459,23 +1459,23 @@ impl Index { } /// Clears the exact attributes from the store. - pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::EXACT_ATTRIBUTES) } - pub fn max_values_per_facet(&self, txn: &RoTxn) -> heed::Result> { + pub fn max_values_per_facet(&self, txn: &RoTxn<'_>) -> heed::Result> { self.main.remap_types::().get(txn, main_key::MAX_VALUES_PER_FACET) } - pub(crate) fn put_max_values_per_facet(&self, txn: &mut RwTxn, val: u64) -> heed::Result<()> { + pub(crate) fn put_max_values_per_facet(&self, txn: &mut RwTxn<'_>, val: u64) -> heed::Result<()> { self.main.remap_types::().put(txn, main_key::MAX_VALUES_PER_FACET, &val) } - pub(crate) fn delete_max_values_per_facet(&self, txn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_max_values_per_facet(&self, txn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::MAX_VALUES_PER_FACET) } - pub fn sort_facet_values_by(&self, txn: &RoTxn) -> heed::Result { + pub fn sort_facet_values_by(&self, txn: &RoTxn<'_>) -> heed::Result { let orders = self .main .remap_types::>() @@ -1486,33 +1486,33 @@ impl Index { pub(crate) fn put_sort_facet_values_by( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, val: &OrderByMap, ) -> heed::Result<()> { self.main.remap_types::>().put(txn, main_key::SORT_FACET_VALUES_BY, &val) } - pub(crate) fn delete_sort_facet_values_by(&self, txn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_sort_facet_values_by(&self, txn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::SORT_FACET_VALUES_BY) } - pub fn pagination_max_total_hits(&self, txn: &RoTxn) -> heed::Result> { + pub fn pagination_max_total_hits(&self, txn: &RoTxn<'_>) -> heed::Result> { self.main.remap_types::().get(txn, main_key::PAGINATION_MAX_TOTAL_HITS) } pub(crate) fn put_pagination_max_total_hits( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, val: u64, ) -> heed::Result<()> { self.main.remap_types::().put(txn, main_key::PAGINATION_MAX_TOTAL_HITS, &val) } - pub(crate) fn delete_pagination_max_total_hits(&self, txn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_pagination_max_total_hits(&self, txn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::PAGINATION_MAX_TOTAL_HITS) } - pub fn proximity_precision(&self, txn: &RoTxn) -> heed::Result> { + pub fn proximity_precision(&self, txn: &RoTxn<'_>) -> heed::Result> { self.main .remap_types::>() .get(txn, main_key::PROXIMITY_PRECISION) @@ -1520,7 +1520,7 @@ impl Index { pub(crate) fn put_proximity_precision( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, val: ProximityPrecision, ) -> heed::Result<()> { self.main.remap_types::>().put( @@ -1530,7 +1530,7 @@ impl Index { ) } - pub(crate) fn delete_proximity_precision(&self, txn: &mut RwTxn) -> heed::Result { + pub(crate) fn delete_proximity_precision(&self, txn: &mut RwTxn<'_>) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::PROXIMITY_PRECISION) } @@ -1538,13 +1538,13 @@ impl Index { /// Retrieve all the documents ids that correspond with (Script, Language) key, `None` if it is any. pub fn script_language_documents_ids( &self, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, key: &(Script, Language), ) -> heed::Result> { self.script_language_docids.get(rtxn, key) } - pub fn script_language(&self, rtxn: &RoTxn) -> heed::Result>> { + pub fn script_language(&self, rtxn: &RoTxn<'_>) -> heed::Result>> { let mut script_language: HashMap> = HashMap::new(); let mut script_language_doc_count: Vec<(Script, Language, u64)> = Vec::new(); let mut total = 0; @@ -1605,7 +1605,7 @@ impl Index { &'a self, rtxn: &'a RoTxn<'a>, embedder_id: u8, - ) -> impl Iterator>> + 'a { + ) -> impl Iterator>> + 'a { crate::vector::arroy_db_range_for_embedder(embedder_id).map_while(move |k| { arroy::Reader::open(rtxn, k, self.vector_arroy) .map(Some) @@ -1763,7 +1763,7 @@ pub(crate) mod tests { pub fn update_settings( &self, - update: impl Fn(&mut Settings), + update: impl Fn(&mut Settings<'_, '_, '_>), ) -> Result<(), crate::error::Error> { let mut wtxn = self.write_txn().unwrap(); self.update_settings_using_wtxn(&mut wtxn, update)?; @@ -1773,7 +1773,7 @@ pub(crate) mod tests { pub fn update_settings_using_wtxn<'t>( &'t self, wtxn: &mut RwTxn<'t>, - update: impl Fn(&mut Settings), + update: impl Fn(&mut Settings<'_, '_, '_>), ) -> Result<(), crate::error::Error> { let mut builder = update::Settings::new(wtxn, &self.inner, &self.indexer_config); update(&mut builder); diff --git a/milli/src/lib.rs b/milli/src/lib.rs index 095fe1b94..adce740a8 100644 --- a/milli/src/lib.rs +++ b/milli/src/lib.rs @@ -211,7 +211,7 @@ pub fn bucketed_position(relative: u16) -> u16 { pub fn obkv_to_json( displayed_fields: &[FieldId], fields_ids_map: &FieldsIdsMap, - obkv: obkv::KvReaderU16, + obkv: obkv::KvReaderU16<'_>, ) -> Result { displayed_fields .iter() @@ -229,7 +229,7 @@ pub fn obkv_to_json( } /// Transform every field of a raw obkv store into a JSON Object. -pub fn all_obkv_to_json(obkv: obkv::KvReaderU16, fields_ids_map: &FieldsIdsMap) -> Result { +pub fn all_obkv_to_json(obkv: obkv::KvReaderU16<'_>, fields_ids_map: &FieldsIdsMap) -> Result { let all_keys = obkv.iter().map(|(k, _v)| k).collect::>(); obkv_to_json(all_keys.as_slice(), fields_ids_map, obkv) } diff --git a/milli/src/search/facet/facet_distribution.rs b/milli/src/search/facet/facet_distribution.rs index 09ef5d4ee..62ae05740 100644 --- a/milli/src/search/facet/facet_distribution.rs +++ b/milli/src/search/facet/facet_distribution.rs @@ -47,7 +47,7 @@ pub struct FacetDistribution<'a> { } impl<'a> FacetDistribution<'a> { - pub fn new(rtxn: &'a heed::RoTxn, index: &'a Index) -> FacetDistribution<'a> { + pub fn new(rtxn: &'a heed::RoTxn<'a>, index: &'a Index) -> FacetDistribution<'a> { FacetDistribution { facets: None, candidates: None, @@ -374,7 +374,7 @@ impl<'a> FacetDistribution<'a> { } impl fmt::Debug for FacetDistribution<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let FacetDistribution { facets, candidates, diff --git a/milli/src/search/facet/filter.rs b/milli/src/search/facet/filter.rs index c08abc8e0..2fa3dae98 100644 --- a/milli/src/search/facet/filter.rs +++ b/milli/src/search/facet/filter.rs @@ -221,14 +221,14 @@ impl<'a> Filter<'a> { } impl<'a> Filter<'a> { - pub fn evaluate(&self, rtxn: &heed::RoTxn, index: &Index) -> Result { + pub fn evaluate(&self, rtxn: &heed::RoTxn<'_>, index: &Index) -> Result { // to avoid doing this for each recursive call we're going to do it ONCE ahead of time let filterable_fields = index.filterable_fields(rtxn)?; self.inner_evaluate(rtxn, index, &filterable_fields, None) } fn evaluate_operator( - rtxn: &heed::RoTxn, + rtxn: &heed::RoTxn<'_>, index: &Index, field_id: FieldId, universe: Option<&RoaringBitmap>, @@ -313,7 +313,7 @@ impl<'a> Filter<'a> { /// Aggregates the documents ids that are part of the specified range automatically /// going deeper through the levels. fn explore_facet_number_levels( - rtxn: &heed::RoTxn, + rtxn: &heed::RoTxn<'_>, db: heed::Database, FacetGroupValueCodec>, field_id: FieldId, left: Bound, @@ -338,7 +338,7 @@ impl<'a> Filter<'a> { fn inner_evaluate( &self, - rtxn: &heed::RoTxn, + rtxn: &heed::RoTxn<'_>, index: &Index, filterable_fields: &HashSet, universe: Option<&RoaringBitmap>, diff --git a/milli/src/search/facet/mod.rs b/milli/src/search/facet/mod.rs index 858028bb5..a5e65c95d 100644 --- a/milli/src/search/facet/mod.rs +++ b/milli/src/search/facet/mod.rs @@ -33,7 +33,7 @@ fn facet_extreme_value<'t>( pub fn facet_min_value<'t>( index: &'t Index, - rtxn: &'t heed::RoTxn, + rtxn: &'t heed::RoTxn<'t>, field_id: u16, candidates: RoaringBitmap, ) -> Result> { @@ -44,7 +44,7 @@ pub fn facet_min_value<'t>( pub fn facet_max_value<'t>( index: &'t Index, - rtxn: &'t heed::RoTxn, + rtxn: &'t heed::RoTxn<'t>, field_id: u16, candidates: RoaringBitmap, ) -> Result> { @@ -55,7 +55,7 @@ pub fn facet_max_value<'t>( /// Get the first facet value in the facet database pub(crate) fn get_first_facet_value<'t, BoundCodec, DC>( - txn: &'t RoTxn, + txn: &'t RoTxn<'t>, db: heed::Database, DC>, field_id: u16, ) -> heed::Result> @@ -79,7 +79,7 @@ where /// Get the last facet value in the facet database pub(crate) fn get_last_facet_value<'t, BoundCodec, DC>( - txn: &'t RoTxn, + txn: &'t RoTxn<'t>, db: heed::Database, DC>, field_id: u16, ) -> heed::Result> diff --git a/milli/src/search/mod.rs b/milli/src/search/mod.rs index 8ae1ebb0f..2b2afa607 100644 --- a/milli/src/search/mod.rs +++ b/milli/src/search/mod.rs @@ -55,7 +55,7 @@ pub struct Search<'a> { } impl<'a> Search<'a> { - pub fn new(rtxn: &'a heed::RoTxn, index: &'a Index) -> Search<'a> { + pub fn new(rtxn: &'a heed::RoTxn<'a>, index: &'a Index) -> Search<'a> { Search { query: None, filter: None, @@ -253,7 +253,7 @@ impl<'a> Search<'a> { } impl fmt::Debug for Search<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let Search { query, filter, diff --git a/milli/src/search/new/db_cache.rs b/milli/src/search/new/db_cache.rs index 4fa0765e0..95f8e7557 100644 --- a/milli/src/search/new/db_cache.rs +++ b/milli/src/search/new/db_cache.rs @@ -47,7 +47,7 @@ pub struct DatabaseCache<'ctx> { } impl<'ctx> DatabaseCache<'ctx> { fn get_value<'v, K1, KC, DC>( - txn: &'ctx RoTxn, + txn: &'ctx RoTxn<'_>, cache_key: K1, db_key: &'v KC::EItem, cache: &mut FxHashMap>>, @@ -77,7 +77,7 @@ impl<'ctx> DatabaseCache<'ctx> { } fn get_value_from_keys<'v, K1, KC, DC>( - txn: &'ctx RoTxn, + txn: &'ctx RoTxn<'_>, cache_key: K1, db_keys: &'v [KC::EItem], cache: &mut FxHashMap>>, @@ -99,7 +99,7 @@ impl<'ctx> DatabaseCache<'ctx> { .iter() .filter_map(|key| db.get(txn, key).transpose()) .map(|v| v.map(Cow::Borrowed)) - .collect::>, _>>()?; + .collect::>, _>>()?; if bitmaps.is_empty() { None diff --git a/milli/src/search/new/distinct.rs b/milli/src/search/new/distinct.rs index 25ea0b0a3..d2ace6ffb 100644 --- a/milli/src/search/new/distinct.rs +++ b/milli/src/search/new/distinct.rs @@ -23,7 +23,7 @@ pub struct DistinctOutput { /// - `excluded`: the set of document ids that contain a value for the given field that occurs /// in the given candidates. pub fn apply_distinct_rule( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, field_id: u16, candidates: &RoaringBitmap, ) -> Result { @@ -42,7 +42,7 @@ pub fn apply_distinct_rule( /// Apply the distinct rule defined by [`apply_distinct_rule`] for a single document id. pub fn distinct_single_docid( index: &Index, - txn: &RoTxn, + txn: &RoTxn<'_>, field_id: u16, docid: u32, excluded: &mut RoaringBitmap, @@ -72,7 +72,7 @@ pub fn distinct_single_docid( /// Return all the docids containing the given value in the given field fn facet_value_docids( database: Database, FacetGroupValueCodec>, - txn: &RoTxn, + txn: &RoTxn<'_>, field_id: u16, facet_value: &[u8], ) -> heed::Result> { @@ -86,7 +86,7 @@ fn facet_number_values<'a>( docid: u32, field_id: u16, index: &Index, - txn: &'a RoTxn, + txn: &'a RoTxn<'a>, ) -> Result, Unit>> { let key = facet_values_prefix_key(field_id, docid); @@ -104,7 +104,7 @@ pub fn facet_string_values<'a>( docid: u32, field_id: u16, index: &Index, - txn: &'a RoTxn, + txn: &'a RoTxn<'a>, ) -> Result, Str>> { let key = facet_values_prefix_key(field_id, docid); diff --git a/milli/src/search/new/geo_sort.rs b/milli/src/search/new/geo_sort.rs index dc09ede99..789eaaafc 100644 --- a/milli/src/search/new/geo_sort.rs +++ b/milli/src/search/new/geo_sort.rs @@ -28,7 +28,7 @@ fn facet_number_values<'a>( docid: u32, field_id: u16, index: &Index, - txn: &'a RoTxn, + txn: &'a RoTxn<'a>, ) -> Result, Unit>> { let key = facet_values_prefix_key(field_id, docid); @@ -109,7 +109,7 @@ impl GeoSort { /// Drop the rtree if we don't need it anymore. fn fill_buffer( &mut self, - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, geo_candidates: &RoaringBitmap, ) -> Result<()> { debug_assert!(self.field_ids.is_some(), "fill_buffer can't be called without the lat&lng"); @@ -182,7 +182,7 @@ fn geo_value( field_lat: u16, field_lng: u16, index: &Index, - rtxn: &RoTxn, + rtxn: &RoTxn<'_>, ) -> Result<[f64; 2]> { let extract_geo = |geo_field: u16| -> Result { match facet_number_values(docid, geo_field, index, rtxn)?.next() { diff --git a/milli/src/search/new/graph_based_ranking_rule.rs b/milli/src/search/new/graph_based_ranking_rule.rs index fabfd1fdf..67ac92e2c 100644 --- a/milli/src/search/new/graph_based_ranking_rule.rs +++ b/milli/src/search/new/graph_based_ranking_rule.rs @@ -375,7 +375,7 @@ impl<'ctx, G: RankingRuleGraphTrait> RankingRule<'ctx, QueryGraph> for GraphBase /// docids and the previous path docids is empty. #[allow(clippy::too_many_arguments)] fn visit_path_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, graph: &mut RankingRuleGraph, universe: &RoaringBitmap, dead_ends_cache: &mut DeadEndsCache, diff --git a/milli/src/search/new/logger/mod.rs b/milli/src/search/new/logger/mod.rs index d516a5db9..7ec5a51b0 100644 --- a/milli/src/search/new/logger/mod.rs +++ b/milli/src/search/new/logger/mod.rs @@ -20,13 +20,13 @@ pub trait SearchLogger { fn query_for_initial_universe(&mut self, _query: &Q); /// Logs the ranking rules used to perform the search query - fn ranking_rules(&mut self, _rr: &[BoxRankingRule]); + fn ranking_rules(&mut self, _rr: &[BoxRankingRule<'_, Q>]); /// Logs the start of a ranking rule's iteration. fn start_iteration_ranking_rule( &mut self, _ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, Q>, _query: &Q, _universe: &RoaringBitmap, ) { @@ -35,7 +35,7 @@ pub trait SearchLogger { fn next_bucket_ranking_rule( &mut self, _ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, Q>, _universe: &RoaringBitmap, _candidates: &RoaringBitmap, ) { @@ -44,7 +44,7 @@ pub trait SearchLogger { fn skip_bucket_ranking_rule( &mut self, _ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, Q>, _candidates: &RoaringBitmap, ) { } @@ -52,7 +52,7 @@ pub trait SearchLogger { fn end_iteration_ranking_rule( &mut self, _ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, Q>, _universe: &RoaringBitmap, ) { } @@ -73,7 +73,7 @@ impl SearchLogger for DefaultSearchLogger { fn query_for_initial_universe(&mut self, _query: &Q) {} - fn ranking_rules(&mut self, _rr: &[BoxRankingRule]) {} + fn ranking_rules(&mut self, _rr: &[BoxRankingRule<'_, Q>]) {} fn add_to_results(&mut self, _docids: &[u32]) {} diff --git a/milli/src/search/new/logger/visual.rs b/milli/src/search/new/logger/visual.rs index 2bffdd8d9..5b5a29b65 100644 --- a/milli/src/search/new/logger/visual.rs +++ b/milli/src/search/new/logger/visual.rs @@ -69,14 +69,14 @@ impl SearchLogger for VisualSearchLogger { fn initial_universe(&mut self, universe: &RoaringBitmap) { self.initial_universe = Some(universe.clone()); } - fn ranking_rules(&mut self, rr: &[BoxRankingRule]) { + fn ranking_rules(&mut self, rr: &[BoxRankingRule<'_, QueryGraph>]) { self.ranking_rules_ids = Some(rr.iter().map(|rr| rr.id()).collect()); } fn start_iteration_ranking_rule( &mut self, ranking_rule_idx: usize, - ranking_rule: &dyn RankingRule, + ranking_rule: &dyn RankingRule<'_, QueryGraph>, _query: &QueryGraph, universe: &RoaringBitmap, ) { @@ -97,7 +97,7 @@ impl SearchLogger for VisualSearchLogger { fn next_bucket_ranking_rule( &mut self, ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_,QueryGraph>, universe: &RoaringBitmap, bucket: &RoaringBitmap, ) { @@ -110,7 +110,7 @@ impl SearchLogger for VisualSearchLogger { fn skip_bucket_ranking_rule( &mut self, ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, QueryGraph>, bucket: &RoaringBitmap, ) { self.events.push(SearchEvents::RankingRuleSkipBucket { @@ -122,7 +122,7 @@ impl SearchLogger for VisualSearchLogger { fn end_iteration_ranking_rule( &mut self, ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule, + _ranking_rule: &dyn RankingRule<'_, QueryGraph>, _universe: &RoaringBitmap, ) { self.events.push(SearchEvents::RankingRuleEndIteration { ranking_rule_idx }); diff --git a/milli/src/search/new/matches/matching_words.rs b/milli/src/search/new/matches/matching_words.rs index 4db1c99c6..4ad5c37ec 100644 --- a/milli/src/search/new/matches/matching_words.rs +++ b/milli/src/search/new/matches/matching_words.rs @@ -32,7 +32,7 @@ pub struct MatchingWords { } impl MatchingWords { - pub fn new(ctx: SearchContext, located_terms: Vec) -> Self { + pub fn new(ctx: SearchContext<'_>, located_terms: Vec) -> Self { let mut phrases = Vec::new(); let mut words = Vec::new(); @@ -74,7 +74,7 @@ impl MatchingWords { } /// Try to match the token with one of the located_words. - fn match_unique_words<'a>(&'a self, token: &Token) -> Option> { + fn match_unique_words<'a>(&'a self, token: &Token<'_>) -> Option> { for located_words in &self.words { for word in &located_words.value { let word = self.word_interner.get(*word); @@ -166,7 +166,7 @@ impl<'a> PartialMatch<'a> { /// - None if the given token breaks the partial match /// - Partial if the given token matches the partial match but doesn't complete it /// - Full if the given token completes the partial match - pub fn match_token(self, token: &Token) -> Option> { + pub fn match_token(self, token: &Token<'_>) -> Option> { let Self { mut matching_words, ids, .. } = self; let is_matching = match matching_words.first()? { @@ -198,7 +198,7 @@ impl<'a> PartialMatch<'a> { } impl fmt::Debug for MatchingWords { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let MatchingWords { word_interner, phrase_interner, phrases, words } = self; let phrases: Vec<_> = phrases diff --git a/milli/src/search/new/matches/mod.rs b/milli/src/search/new/matches/mod.rs index 77ae5fcd5..a0cfdaa65 100644 --- a/milli/src/search/new/matches/mod.rs +++ b/milli/src/search/new/matches/mod.rs @@ -123,7 +123,7 @@ impl<'t> Matcher<'t, '_> { /// some words are counted as matches only if they are close together and in the good order, /// compute_partial_match peek into next words to validate if the match is complete. fn compute_partial_match<'a>( - mut partial: PartialMatch, + mut partial: PartialMatch<'a>, token_position: usize, word_position: usize, words_positions: &mut impl Iterator)>, @@ -244,7 +244,7 @@ impl<'t> Matcher<'t, '_> { } /// Returns the bounds in byte index of the crop window. - fn crop_bounds(&self, tokens: &[Token], matches: &[Match], crop_size: usize) -> (usize, usize) { + fn crop_bounds(&self, tokens: &[Token<'_>], matches: &[Match], crop_size: usize) -> (usize, usize) { // if there is no match, we start from the beginning of the string by default. let first_match_word_position = matches.first().map(|m| m.word_position).unwrap_or(0); let first_match_token_position = matches.first().map(|m| m.token_position).unwrap_or(0); @@ -505,7 +505,7 @@ mod tests { use crate::{execute_search, filtered_universe, SearchContext, TimeBudget}; impl<'a> MatcherBuilder<'a> { - fn new_test(rtxn: &'a heed::RoTxn, index: &'a TempIndex, query: &str) -> Self { + fn new_test(rtxn: &'a heed::RoTxn<'a>, index: &'a TempIndex, query: &str) -> Self { let mut ctx = SearchContext::new(index, rtxn).unwrap(); let universe = filtered_universe(ctx.index, ctx.txn, &None).unwrap(); let crate::search::PartialSearchResult { located_query_terms, .. } = execute_search( diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 4cecb19e5..2d0d63e0e 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -183,7 +183,7 @@ impl RestrictedFids { /// Apply the [`TermsMatchingStrategy`] to the query graph and resolve it. fn resolve_maximally_reduced_query_graph( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, universe: &RoaringBitmap, query_graph: &QueryGraph, matching_strategy: TermsMatchingStrategy, @@ -214,7 +214,7 @@ fn resolve_maximally_reduced_query_graph( #[tracing::instrument(level = "trace", skip_all, target = "search::universe")] fn resolve_universe( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, initial_universe: &RoaringBitmap, query_graph: &QueryGraph, matching_strategy: TermsMatchingStrategy, @@ -231,7 +231,7 @@ fn resolve_universe( #[tracing::instrument(level = "trace", skip_all, target = "search::query")] fn resolve_negative_words( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, negative_words: &[Word], ) -> Result { let mut negative_bitmap = RoaringBitmap::new(); @@ -245,7 +245,7 @@ fn resolve_negative_words( #[tracing::instrument(level = "trace", skip_all, target = "search::query")] fn resolve_negative_phrases( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, negative_phrases: &[LocatedQueryTerm], ) -> Result { let mut negative_bitmap = RoaringBitmap::new(); @@ -267,7 +267,7 @@ fn get_ranking_rules_for_placeholder_search<'ctx>( let mut sort = false; let mut sorted_fields = HashSet::new(); let mut geo_sorted = false; - let mut ranking_rules: Vec> = vec![]; + let mut ranking_rules: Vec> = vec![]; let settings_ranking_rules = ctx.index.criteria(ctx.txn)?; for rr in settings_ranking_rules { match rr { @@ -326,7 +326,7 @@ fn get_ranking_rules_for_vector<'ctx>( let mut geo_sorted = false; let mut vector = false; - let mut ranking_rules: Vec> = vec![]; + let mut ranking_rules: Vec> = vec![]; let settings_ranking_rules = ctx.index.criteria(ctx.txn)?; for rr in settings_ranking_rules { @@ -406,7 +406,7 @@ fn get_ranking_rules_for_query_graph_search<'ctx>( words = true; } - let mut ranking_rules: Vec> = vec![]; + let mut ranking_rules: Vec> = vec![]; let settings_ranking_rules = ctx.index.criteria(ctx.txn)?; for rr in settings_ranking_rules { // Add Words before any of: typo, proximity, attribute @@ -552,7 +552,7 @@ fn resolve_sort_criteria<'ctx, Query: RankingRuleQueryTrait>( pub fn filtered_universe( index: &Index, txn: &RoTxn<'_>, - filters: &Option, + filters: &Option>, ) -> Result { Ok(if let Some(filters) = filters { filters.evaluate(txn, index)? @@ -563,7 +563,7 @@ pub fn filtered_universe( #[allow(clippy::too_many_arguments)] pub fn execute_vector_search( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, vector: &[f32], scoring_strategy: ScoringStrategy, universe: RoaringBitmap, @@ -622,7 +622,7 @@ pub fn execute_vector_search( #[allow(clippy::too_many_arguments)] #[tracing::instrument(level = "trace", skip_all, target = "search::main")] pub fn execute_search( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, query: Option<&str>, terms_matching_strategy: TermsMatchingStrategy, scoring_strategy: ScoringStrategy, @@ -775,7 +775,7 @@ pub fn execute_search( }) } -fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec>) -> Result<()> { +fn check_sort_criteria(ctx: &SearchContext<'_>, sort_criteria: Option<&Vec>) -> Result<()> { let sort_criteria = if let Some(sort_criteria) = sort_criteria { sort_criteria } else { diff --git a/milli/src/search/new/query_graph.rs b/milli/src/search/new/query_graph.rs index cda767d75..9befb783d 100644 --- a/milli/src/search/new/query_graph.rs +++ b/milli/src/search/new/query_graph.rs @@ -93,7 +93,7 @@ impl QueryGraph { /// Build the query graph from the parsed user search query, return an updated list of the located query terms /// which contains ngrams. pub fn from_query( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, // The terms here must be consecutive terms: &[LocatedQueryTerm], ) -> Result<(QueryGraph, Vec)> { @@ -294,7 +294,7 @@ impl QueryGraph { pub fn removal_order_for_terms_matching_strategy_frequency( &self, - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, ) -> Result>> { // lookup frequency for each term let mut term_with_frequency: Vec<(u8, u64)> = { @@ -337,7 +337,7 @@ impl QueryGraph { pub fn removal_order_for_terms_matching_strategy_last( &self, - ctx: &SearchContext, + ctx: &SearchContext<'_>, ) -> Vec> { let (first_term_idx, last_term_idx) = { let mut first_term_idx = u8::MAX; @@ -370,7 +370,7 @@ impl QueryGraph { pub fn removal_order_for_terms_matching_strategy( &self, - ctx: &SearchContext, + ctx: &SearchContext<'_>, order: impl Fn(u8) -> u16, ) -> Vec> { let mut nodes_to_remove = BTreeMap::>::new(); @@ -398,7 +398,7 @@ impl QueryGraph { } /// Number of words in the phrases in this query graph - pub(crate) fn words_in_phrases_count(&self, ctx: &SearchContext) -> usize { + pub(crate) fn words_in_phrases_count(&self, ctx: &SearchContext<'_>) -> usize { let mut word_count = 0; for (_, node) in self.nodes.iter() { match &node.data { diff --git a/milli/src/search/new/query_term/compute_derivations.rs b/milli/src/search/new/query_term/compute_derivations.rs index 02754929a..c1783431c 100644 --- a/milli/src/search/new/query_term/compute_derivations.rs +++ b/milli/src/search/new/query_term/compute_derivations.rs @@ -27,7 +27,7 @@ pub enum ZeroOrOneTypo { } impl Interned { - pub fn compute_fully_if_needed(self, ctx: &mut SearchContext) -> Result<()> { + pub fn compute_fully_if_needed(self, ctx: &mut SearchContext<'_>) -> Result<()> { let s = ctx.term_interner.get_mut(self); if s.max_levenshtein_distance <= 1 && s.one_typo.is_uninit() { assert!(s.two_typo.is_uninit()); @@ -48,7 +48,7 @@ impl Interned { fn find_zero_typo_prefix_derivations( word_interned: Interned, - fst: fst::Set>, + fst: fst::Set>, word_interner: &mut DedupInterner, mut visit: impl FnMut(Interned) -> Result>, ) -> Result<()> { @@ -71,7 +71,7 @@ fn find_zero_typo_prefix_derivations( } fn find_zero_one_typo_derivations( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, word_interned: Interned, is_prefix: bool, mut visit: impl FnMut(Interned, ZeroOrOneTypo) -> Result>, @@ -114,7 +114,7 @@ fn find_zero_one_typo_derivations( fn find_zero_one_two_typo_derivations( word_interned: Interned, is_prefix: bool, - fst: fst::Set>, + fst: fst::Set>, word_interner: &mut DedupInterner, mut visit: impl FnMut(Interned, NumberOfTypos) -> Result>, ) -> Result<()> { @@ -172,7 +172,7 @@ fn find_zero_one_two_typo_derivations( } pub fn partially_initialized_term_from_word( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, word: &str, max_typo: u8, is_prefix: bool, @@ -265,7 +265,7 @@ pub fn partially_initialized_term_from_word( }) } -fn find_split_words(ctx: &mut SearchContext, word: &str) -> Result>> { +fn find_split_words(ctx: &mut SearchContext<'_>, word: &str) -> Result>> { if let Some((l, r)) = split_best_frequency(ctx, word)? { Ok(Some(ctx.phrase_interner.insert(Phrase { words: vec![Some(l), Some(r)] }))) } else { @@ -274,7 +274,7 @@ fn find_split_words(ctx: &mut SearchContext, word: &str) -> Result { - fn initialize_one_typo_subterm(self, ctx: &mut SearchContext) -> Result<()> { + fn initialize_one_typo_subterm(self, ctx: &mut SearchContext<'_>) -> Result<()> { let self_mut = ctx.term_interner.get_mut(self); let allows_split_words = self_mut.allows_split_words(); @@ -340,7 +340,7 @@ impl Interned { Ok(()) } - fn initialize_one_and_two_typo_subterm(self, ctx: &mut SearchContext) -> Result<()> { + fn initialize_one_and_two_typo_subterm(self, ctx: &mut SearchContext<'_>) -> Result<()> { let self_mut = ctx.term_interner.get_mut(self); let QueryTerm { original, @@ -406,7 +406,7 @@ impl Interned { /// /// Return `None` if the original word cannot be split. fn split_best_frequency( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, original: &str, ) -> Result, Interned)>> { let chars = original.char_indices().skip(1); diff --git a/milli/src/search/new/query_term/mod.rs b/milli/src/search/new/query_term/mod.rs index 70f1d3c4f..ba8964e34 100644 --- a/milli/src/search/new/query_term/mod.rs +++ b/milli/src/search/new/query_term/mod.rs @@ -128,7 +128,7 @@ impl QueryTermSubset { pub fn make_mandatory(&mut self) { self.mandatory = true; } - pub fn exact_term(&self, ctx: &SearchContext) -> Option { + pub fn exact_term(&self, ctx: &SearchContext<'_>) -> Option { let full_query_term = ctx.term_interner.get(self.original); if full_query_term.ngram_words.is_some() { return None; @@ -174,7 +174,7 @@ impl QueryTermSubset { self.two_typo_subset.intersect(&other.two_typo_subset); } - pub fn use_prefix_db(&self, ctx: &SearchContext) -> Option { + pub fn use_prefix_db(&self, ctx: &SearchContext<'_>) -> Option { let original = ctx.term_interner.get(self.original); let use_prefix_db = original.zero_typo.use_prefix_db?; let word = match &self.zero_typo_subset { @@ -198,7 +198,7 @@ impl QueryTermSubset { } pub fn all_single_words_except_prefix_db( &self, - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, ) -> Result> { let mut result = BTreeSet::default(); if !self.one_typo_subset.is_empty() || !self.two_typo_subset.is_empty() { @@ -290,7 +290,7 @@ impl QueryTermSubset { Ok(result) } - pub fn all_phrases(&self, ctx: &mut SearchContext) -> Result>> { + pub fn all_phrases(&self, ctx: &mut SearchContext<'_>) -> Result>> { let mut result = BTreeSet::default(); if !self.one_typo_subset.is_empty() { @@ -328,7 +328,7 @@ impl QueryTermSubset { Ok(result) } - pub fn original_phrase(&self, ctx: &SearchContext) -> Option> { + pub fn original_phrase(&self, ctx: &SearchContext<'_>) -> Option> { let t = ctx.term_interner.get(self.original); if let Some(p) = t.zero_typo.phrase { if self.zero_typo_subset.contains_phrase(p) { @@ -337,7 +337,7 @@ impl QueryTermSubset { } None } - pub fn max_typo_cost(&self, ctx: &SearchContext) -> u8 { + pub fn max_typo_cost(&self, ctx: &SearchContext<'_>) -> u8 { let t = ctx.term_interner.get(self.original); match t.max_levenshtein_distance { 0 => { @@ -368,7 +368,7 @@ impl QueryTermSubset { _ => panic!(), } } - pub fn keep_only_exact_term(&mut self, ctx: &SearchContext) { + pub fn keep_only_exact_term(&mut self, ctx: &SearchContext<'_>) { if let Some(term) = self.exact_term(ctx) { match term { ExactTerm::Phrase(p) => { @@ -399,7 +399,7 @@ impl QueryTermSubset { pub fn clear_two_typo_subset(&mut self) { self.two_typo_subset = NTypoTermSubset::Nothing; } - pub fn description(&self, ctx: &SearchContext) -> String { + pub fn description(&self, ctx: &SearchContext<'_>) -> String { let t = ctx.term_interner.get(self.original); ctx.word_interner.get(t.original).to_owned() } @@ -446,7 +446,7 @@ impl QueryTerm { impl Interned { /// Return the original word from the given query term - fn original_single_word(self, ctx: &SearchContext) -> Option> { + fn original_single_word(self, ctx: &SearchContext<'_>) -> Option> { let self_ = ctx.term_interner.get(self); if self_.ngram_words.is_some() { None @@ -477,7 +477,7 @@ impl QueryTerm { pub fn is_prefix(&self) -> bool { self.is_prefix } - pub fn original_word(&self, ctx: &SearchContext) -> String { + pub fn original_word(&self, ctx: &SearchContext<'_>) -> String { ctx.word_interner.get(self.original).clone() } diff --git a/milli/src/search/new/query_term/parse_query.rs b/milli/src/search/new/query_term/parse_query.rs index 74b2ed564..d7c279a27 100644 --- a/milli/src/search/new/query_term/parse_query.rs +++ b/milli/src/search/new/query_term/parse_query.rs @@ -23,8 +23,8 @@ pub struct ExtractedTokens { /// Convert the tokenised search query into a list of located query terms. #[tracing::instrument(level = "trace", skip_all, target = "search::query")] pub fn located_query_terms_from_tokens( - ctx: &mut SearchContext, - query: NormalizedTokenIter, + ctx: &mut SearchContext<'_>, + query: NormalizedTokenIter<'_, '_>, words_limit: Option, ) -> Result { let nbr_typos = number_of_typos_allowed(ctx)?; @@ -214,7 +214,7 @@ pub fn number_of_typos_allowed<'ctx>( } pub fn make_ngram( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, terms: &[LocatedQueryTerm], number_of_typos_allowed: &impl Fn(&str) -> u8, ) -> Result> { @@ -297,7 +297,7 @@ impl PhraseBuilder { } // precondition: token has kind Word or StopWord - fn push_word(&mut self, ctx: &mut SearchContext, token: &charabia::Token, position: u16) { + fn push_word(&mut self, ctx: &mut SearchContext<'_>, token: &charabia::Token<'_>, position: u16) { if self.is_empty() { self.start = position; } @@ -311,7 +311,7 @@ impl PhraseBuilder { } } - fn build(self, ctx: &mut SearchContext) -> Option { + fn build(self, ctx: &mut SearchContext<'_>) -> Option { if self.is_empty() { return None; } diff --git a/milli/src/search/new/query_term/phrase.rs b/milli/src/search/new/query_term/phrase.rs index 1d0b24196..cb98528ce 100644 --- a/milli/src/search/new/query_term/phrase.rs +++ b/milli/src/search/new/query_term/phrase.rs @@ -10,11 +10,11 @@ pub struct Phrase { pub words: Vec>>, } impl Interned { - pub fn description(self, ctx: &SearchContext) -> String { + pub fn description(self, ctx: &SearchContext<'_>) -> String { let p = ctx.phrase_interner.get(self); p.words.iter().flatten().map(|w| ctx.word_interner.get(*w)).join(" ") } - pub fn words(self, ctx: &SearchContext) -> Vec>> { + pub fn words(self, ctx: &SearchContext<'_>) -> Vec>> { let p = ctx.phrase_interner.get(self); p.words.clone() } diff --git a/milli/src/search/new/ranking_rule_graph/build.rs b/milli/src/search/new/ranking_rule_graph/build.rs index 4bacc5e5d..d4dbc23b6 100644 --- a/milli/src/search/new/ranking_rule_graph/build.rs +++ b/milli/src/search/new/ranking_rule_graph/build.rs @@ -10,7 +10,7 @@ use crate::Result; impl RankingRuleGraph { /// Build the ranking rule graph from the given query graph pub fn build( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, query_graph: QueryGraph, cost_of_ignoring_node: MappedInterner)>>, ) -> Result { diff --git a/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs b/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs index e93a91d29..cacdcfa9f 100644 --- a/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs +++ b/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs @@ -117,7 +117,7 @@ impl<'a, G: RankingRuleGraphTrait> PathVisitor<'a, G> { } /// See module documentation - pub fn visit_paths(mut self, visit: VisitFn) -> Result<()> { + pub fn visit_paths(mut self, visit: VisitFn<'_, G>) -> Result<()> { let _ = self.state.visit_node(self.ctx.graph.query_graph.root_node, visit, &mut self.ctx)?; Ok(()) @@ -132,8 +132,8 @@ impl VisitorState { fn visit_node( &mut self, from_node: Interned, - visit: VisitFn, - ctx: &mut VisitorContext, + visit: VisitFn<'_, G>, + ctx: &mut VisitorContext<'_, G>, ) -> Result> { // any valid path will be found from this point // if a valid path was found, then we know that the DeadEndsCache may have been updated, @@ -189,8 +189,8 @@ impl VisitorState { &mut self, dest_node: Interned, edge_new_nodes_to_skip: &SmallBitmap, - visit: VisitFn, - ctx: &mut VisitorContext, + visit: VisitFn<'_, G>, + ctx: &mut VisitorContext<'_, G>, ) -> Result> { if !ctx .all_costs_from_node @@ -228,8 +228,8 @@ impl VisitorState { condition: Interned, dest_node: Interned, edge_new_nodes_to_skip: &SmallBitmap, - visit: VisitFn, - ctx: &mut VisitorContext, + visit: VisitFn<'_, G>, + ctx: &mut VisitorContext<'_, G>, ) -> Result> { assert!(dest_node != ctx.graph.query_graph.end_node); diff --git a/milli/src/search/new/ranking_rule_graph/condition_docids_cache.rs b/milli/src/search/new/ranking_rule_graph/condition_docids_cache.rs index 5d199c82a..012597406 100644 --- a/milli/src/search/new/ranking_rule_graph/condition_docids_cache.rs +++ b/milli/src/search/new/ranking_rule_graph/condition_docids_cache.rs @@ -33,7 +33,7 @@ impl ConditionDocIdsCache { /// and inserted in the cache. pub fn get_computed_condition<'s>( &'s mut self, - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, interned_condition: Interned, graph: &mut RankingRuleGraph, universe: &RoaringBitmap, diff --git a/milli/src/search/new/ranking_rule_graph/exactness/mod.rs b/milli/src/search/new/ranking_rule_graph/exactness/mod.rs index e4cb335d7..d3fa040ee 100644 --- a/milli/src/search/new/ranking_rule_graph/exactness/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/exactness/mod.rs @@ -17,7 +17,7 @@ pub enum ExactnessCondition { pub enum ExactnessGraph {} fn compute_docids( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, dest_node: &LocatedQueryTermSubset, universe: &RoaringBitmap, ) -> Result { @@ -46,7 +46,7 @@ impl RankingRuleGraphTrait for ExactnessGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::exactness")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -74,7 +74,7 @@ impl RankingRuleGraphTrait for ExactnessGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::exactness")] fn build_edges( - _ctx: &mut SearchContext, + _ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, _source_node: Option<&LocatedQueryTermSubset>, dest_node: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/fid/mod.rs b/milli/src/search/new/ranking_rule_graph/fid/mod.rs index 9cd7e8ee4..2019eb380 100644 --- a/milli/src/search/new/ranking_rule_graph/fid/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/fid/mod.rs @@ -22,7 +22,7 @@ impl RankingRuleGraphTrait for FidGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::fid")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -47,7 +47,7 @@ impl RankingRuleGraphTrait for FidGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::fid")] fn build_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, _from: Option<&LocatedQueryTermSubset>, to_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/mod.rs b/milli/src/search/new/ranking_rule_graph/mod.rs index c1b8df1b7..670402bcb 100644 --- a/milli/src/search/new/ranking_rule_graph/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/mod.rs @@ -99,14 +99,14 @@ pub trait RankingRuleGraphTrait: Sized + 'static { /// Compute the document ids associated with the given edge condition, /// restricted to the given universe. fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result; /// Return the costs and conditions of the edges going from the source node to the destination node fn build_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, source_node: Option<&LocatedQueryTermSubset>, dest_node: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/position/mod.rs b/milli/src/search/new/ranking_rule_graph/position/mod.rs index daf227f31..567aad550 100644 --- a/milli/src/search/new/ranking_rule_graph/position/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/position/mod.rs @@ -22,7 +22,7 @@ impl RankingRuleGraphTrait for PositionGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::position")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -47,7 +47,7 @@ impl RankingRuleGraphTrait for PositionGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::position")] fn build_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, _from: Option<&LocatedQueryTermSubset>, to_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/proximity/build.rs b/milli/src/search/new/ranking_rule_graph/proximity/build.rs index d9d1a77ae..9b56b3f6a 100644 --- a/milli/src/search/new/ranking_rule_graph/proximity/build.rs +++ b/milli/src/search/new/ranking_rule_graph/proximity/build.rs @@ -8,7 +8,7 @@ use crate::search::new::SearchContext; use crate::Result; pub fn build_edges( - _ctx: &mut SearchContext, + _ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, left_term: Option<&LocatedQueryTermSubset>, right_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs b/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs index 29a1876b4..b348c682d 100644 --- a/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs +++ b/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs @@ -13,7 +13,7 @@ use crate::search::new::{SearchContext, Word}; use crate::Result; pub fn compute_docids( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &ProximityCondition, universe: &RoaringBitmap, ) -> Result { @@ -110,7 +110,7 @@ pub fn compute_docids( } fn compute_prefix_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, left_word: Interned, right_prefix: Interned, left_phrase: Option>, @@ -166,7 +166,7 @@ fn compute_prefix_edges( } fn compute_non_prefix_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, word1: Interned, word2: Interned, left_phrase: Option>, @@ -209,7 +209,7 @@ fn compute_non_prefix_edges( } fn last_words_of_term_derivations( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, t: &QueryTermSubset, ) -> Result>, Word)>> { let mut result = BTreeSet::new(); @@ -228,7 +228,7 @@ fn last_words_of_term_derivations( Ok(result) } fn first_word_of_term_iter( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, t: &QueryTermSubset, ) -> Result, Option>)>> { let mut result = BTreeSet::new(); diff --git a/milli/src/search/new/ranking_rule_graph/proximity/mod.rs b/milli/src/search/new/ranking_rule_graph/proximity/mod.rs index faa43a930..3a3d7d056 100644 --- a/milli/src/search/new/ranking_rule_graph/proximity/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/proximity/mod.rs @@ -23,7 +23,7 @@ impl RankingRuleGraphTrait for ProximityGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::proximity")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -32,7 +32,7 @@ impl RankingRuleGraphTrait for ProximityGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::proximity")] fn build_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, source_term: Option<&LocatedQueryTermSubset>, dest_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/typo/mod.rs b/milli/src/search/new/ranking_rule_graph/typo/mod.rs index 225782168..c1256f6a1 100644 --- a/milli/src/search/new/ranking_rule_graph/typo/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/typo/mod.rs @@ -21,7 +21,7 @@ impl RankingRuleGraphTrait for TypoGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::typo")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -40,7 +40,7 @@ impl RankingRuleGraphTrait for TypoGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::typo")] fn build_edges( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, _from: Option<&LocatedQueryTermSubset>, to_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/ranking_rule_graph/words/mod.rs b/milli/src/search/new/ranking_rule_graph/words/mod.rs index 43542c81e..bb6baf669 100644 --- a/milli/src/search/new/ranking_rule_graph/words/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/words/mod.rs @@ -20,7 +20,7 @@ impl RankingRuleGraphTrait for WordsGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::words")] fn resolve_condition( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, condition: &Self::Condition, universe: &RoaringBitmap, ) -> Result { @@ -39,7 +39,7 @@ impl RankingRuleGraphTrait for WordsGraph { #[tracing::instrument(level = "trace", skip_all, target = "search::words")] fn build_edges( - _ctx: &mut SearchContext, + _ctx: &mut SearchContext<'_>, conditions_interner: &mut DedupInterner, _from: Option<&LocatedQueryTermSubset>, to_term: &LocatedQueryTermSubset, diff --git a/milli/src/search/new/resolve_query_graph.rs b/milli/src/search/new/resolve_query_graph.rs index d992cd22f..8d89e8275 100644 --- a/milli/src/search/new/resolve_query_graph.rs +++ b/milli/src/search/new/resolve_query_graph.rs @@ -30,7 +30,7 @@ impl<'ctx> SearchContext<'ctx> { } } pub fn compute_query_term_subset_docids( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, term: &QueryTermSubset, ) -> Result { let mut docids = RoaringBitmap::new(); @@ -53,7 +53,7 @@ pub fn compute_query_term_subset_docids( } pub fn compute_query_term_subset_docids_within_field_id( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, term: &QueryTermSubset, fid: u16, ) -> Result { @@ -86,7 +86,7 @@ pub fn compute_query_term_subset_docids_within_field_id( } pub fn compute_query_term_subset_docids_within_position( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, term: &QueryTermSubset, position: u16, ) -> Result { @@ -121,7 +121,7 @@ pub fn compute_query_term_subset_docids_within_position( /// Returns the subset of the input universe that satisfies the contraints of the input query graph. pub fn compute_query_graph_docids( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, q: &QueryGraph, universe: &RoaringBitmap, ) -> Result { @@ -178,7 +178,7 @@ pub fn compute_query_graph_docids( } pub fn compute_phrase_docids( - ctx: &mut SearchContext, + ctx: &mut SearchContext<'_>, phrase: Interned, ) -> Result { let Phrase { words } = ctx.phrase_interner.get(phrase).clone(); diff --git a/milli/src/search/new/sort.rs b/milli/src/search/new/sort.rs index d95a899b7..2fce2d4b5 100644 --- a/milli/src/search/new/sort.rs +++ b/milli/src/search/new/sort.rs @@ -56,7 +56,7 @@ pub struct Sort<'ctx, Query> { impl<'ctx, Query> Sort<'ctx, Query> { pub fn new( index: &Index, - rtxn: &'ctx heed::RoTxn, + rtxn: &'ctx heed::RoTxn<'ctx>, field_name: String, is_ascending: bool, ) -> Result { @@ -74,7 +74,7 @@ impl<'ctx, Query> Sort<'ctx, Query> { }) } - fn must_redact(index: &Index, rtxn: &'ctx heed::RoTxn, field_name: &str) -> Result { + fn must_redact(index: &Index, rtxn: &'ctx heed::RoTxn<'ctx>, field_name: &str) -> Result { let Some(displayed_fields) = index.displayed_fields(rtxn)? else { return Ok(false); }; @@ -97,7 +97,7 @@ impl<'ctx, Query: RankingRuleQueryTrait> RankingRule<'ctx, Query> for Sort<'ctx, parent_candidates: &RoaringBitmap, parent_query: &Query, ) -> Result<()> { - let iter: RankingRuleOutputIterWrapper = match self.field_id { + let iter: RankingRuleOutputIterWrapper<'ctx, Query> = match self.field_id { Some(field_id) => { let number_db = ctx .index diff --git a/milli/src/search/new/tests/distinct.rs b/milli/src/search/new/tests/distinct.rs index 75c00da2a..dd27bfc8a 100644 --- a/milli/src/search/new/tests/distinct.rs +++ b/milli/src/search/new/tests/distinct.rs @@ -207,7 +207,7 @@ fn create_index() -> TempIndex { fn verify_distinct( index: &Index, - txn: &RoTxn, + txn: &RoTxn<'_>, distinct: Option<&str>, docids: &[u32], ) -> Vec { diff --git a/milli/src/search/new/tests/mod.rs b/milli/src/search/new/tests/mod.rs index 26199b79b..0faff9425 100644 --- a/milli/src/search/new/tests/mod.rs +++ b/milli/src/search/new/tests/mod.rs @@ -18,7 +18,7 @@ pub mod words_tms; fn collect_field_values( index: &crate::Index, - txn: &heed::RoTxn, + txn: &heed::RoTxn<'_>, fid: &str, docids: &[u32], ) -> Vec { diff --git a/milli/src/search/new/vector_sort.rs b/milli/src/search/new/vector_sort.rs index c227c7c3f..e56f3cbbe 100644 --- a/milli/src/search/new/vector_sort.rs +++ b/milli/src/search/new/vector_sort.rs @@ -20,7 +20,7 @@ pub struct VectorSort { impl VectorSort { pub fn new( - ctx: &SearchContext, + ctx: &SearchContext<'_>, target: Vec, vector_candidates: RoaringBitmap, limit: usize, diff --git a/milli/src/update/del_add.rs b/milli/src/update/del_add.rs index cb5e448f1..570d292ef 100644 --- a/milli/src/update/del_add.rs +++ b/milli/src/update/del_add.rs @@ -36,7 +36,7 @@ impl Key for DelAdd { /// Addition: put all the values under DelAdd::Addition, /// DeletionAndAddition: put all the values under DelAdd::Deletion and DelAdd::Addition, pub fn into_del_add_obkv( - reader: obkv::KvReader, + reader: obkv::KvReader<'_, K>, operation: DelAddOperation, buffer: &mut Vec, ) -> Result<(), std::io::Error> { @@ -46,7 +46,7 @@ pub fn into_del_add_obkv( /// Akin to the [into_del_add_obkv] function but lets you /// conditionally define the `DelAdd` variant based on the obkv key. pub fn into_del_add_obkv_conditional_operation( - reader: obkv::KvReader, + reader: obkv::KvReader<'_, K>, buffer: &mut Vec, operation: F, ) -> std::io::Result<()> @@ -86,8 +86,8 @@ pub enum DelAddOperation { /// putting each deletion obkv's keys under an DelAdd::Deletion /// and putting each addition obkv's keys under an DelAdd::Addition pub fn del_add_from_two_obkvs( - deletion: &obkv::KvReader, - addition: &obkv::KvReader, + deletion: &obkv::KvReader<'_, K>, + addition: &obkv::KvReader<'_, K>, buffer: &mut Vec, ) -> Result<(), std::io::Error> { use itertools::merge_join_by; @@ -121,7 +121,7 @@ pub fn del_add_from_two_obkvs( writer.finish() } -pub fn is_noop_del_add_obkv(del_add: KvReaderDelAdd) -> bool { +pub fn is_noop_del_add_obkv(del_add: KvReaderDelAdd<'_>) -> bool { del_add.get(DelAdd::Deletion) == del_add.get(DelAdd::Addition) } diff --git a/milli/src/update/facet/bulk.rs b/milli/src/update/facet/bulk.rs index 888b1c4eb..a63d59693 100644 --- a/milli/src/update/facet/bulk.rs +++ b/milli/src/update/facet/bulk.rs @@ -67,7 +67,7 @@ impl<'i> FacetsUpdateBulk<'i> { } #[tracing::instrument(level = "trace", skip_all, target = "indexing::facets::bulk")] - pub fn execute(self, wtxn: &mut heed::RwTxn) -> Result<()> { + pub fn execute(self, wtxn: &mut heed::RwTxn<'_>) -> Result<()> { let Self { index, field_ids, group_size, min_level_size, facet_type, delta_data } = self; let db = match facet_type { @@ -95,7 +95,7 @@ pub(crate) struct FacetsUpdateBulkInner { pub min_level_size: u8, } impl FacetsUpdateBulkInner { - pub fn update(mut self, wtxn: &mut RwTxn, field_ids: &[u16]) -> Result<()> { + pub fn update(mut self, wtxn: &mut RwTxn<'_>, field_ids: &[u16]) -> Result<()> { self.update_level0(wtxn)?; for &field_id in field_ids.iter() { self.clear_levels(wtxn, field_id)?; @@ -114,7 +114,7 @@ impl FacetsUpdateBulkInner { Ok(()) } - fn clear_levels(&self, wtxn: &mut heed::RwTxn, field_id: FieldId) -> Result<()> { + fn clear_levels(&self, wtxn: &mut heed::RwTxn<'_>, field_id: FieldId) -> Result<()> { let left = FacetGroupKey::<&[u8]> { field_id, level: 1, left_bound: &[] }; let right = FacetGroupKey::<&[u8]> { field_id, level: u8::MAX, left_bound: &[] }; let range = left..=right; @@ -122,7 +122,7 @@ impl FacetsUpdateBulkInner { Ok(()) } - fn update_level0(&mut self, wtxn: &mut RwTxn) -> Result<()> { + fn update_level0(&mut self, wtxn: &mut RwTxn<'_>) -> Result<()> { let delta_data = match self.delta_data.take() { Some(x) => x, None => return Ok(()), @@ -198,7 +198,7 @@ impl FacetsUpdateBulkInner { fn compute_levels_for_field_id( &self, field_id: FieldId, - txn: &RoTxn, + txn: &RoTxn<'_>, ) -> Result>>> { let subwriters = self.compute_higher_levels(txn, field_id, 32, &mut |_, _| Ok(()))?; @@ -207,7 +207,7 @@ impl FacetsUpdateBulkInner { #[allow(clippy::type_complexity)] fn read_level_0<'t>( &self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, field_id: u16, handle_group: &mut dyn FnMut(&[RoaringBitmap], &'t [u8]) -> Result<()>, ) -> Result<()> { @@ -261,7 +261,7 @@ impl FacetsUpdateBulkInner { #[allow(clippy::type_complexity)] fn compute_higher_levels<'t>( &self, - rtxn: &'t RoTxn, + rtxn: &'t RoTxn<'t>, field_id: u16, level: u8, handle_group: &mut dyn FnMut(&[RoaringBitmap], &'t [u8]) -> Result<()>, diff --git a/milli/src/update/facet/incremental.rs b/milli/src/update/facet/incremental.rs index f871eee31..0f0937855 100644 --- a/milli/src/update/facet/incremental.rs +++ b/milli/src/update/facet/incremental.rs @@ -88,7 +88,7 @@ impl FacetsUpdateIncremental { } #[tracing::instrument(level = "trace", skip_all, target = "indexing::facets::incremental")] - pub fn execute(self, wtxn: &mut RwTxn) -> crate::Result<()> { + pub fn execute(self, wtxn: &mut RwTxn<'_>) -> crate::Result<()> { let mut current_field_id = None; let mut facet_level_may_be_updated = false; let mut iter = self.delta_data.into_stream_merger_iter()?; @@ -172,7 +172,7 @@ impl FacetsUpdateIncrementalInner { field_id: u16, level: u8, facet_value: &[u8], - txn: &RoTxn, + txn: &RoTxn<'_>, ) -> Result<(FacetGroupKey>, FacetGroupValue)> { assert!(level > 0); match self.db.get_lower_than_or_equal_to( @@ -215,7 +215,7 @@ impl FacetsUpdateIncrementalInner { /// See documentation of `insert_in_level` fn modify_in_level_0( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, facet_value: &[u8], add_docids: Option<&RoaringBitmap>, @@ -277,7 +277,7 @@ impl FacetsUpdateIncrementalInner { /// Returns `ModificationResult::Insert` if the split is successful. fn split_group( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, level: u8, insertion_key: FacetGroupKey>, @@ -346,7 +346,7 @@ impl FacetsUpdateIncrementalInner { /// This process is needed to avoid removing docids from a group node where the docid is present in several sub-nodes. fn trim_del_docids<'a>( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, level: u8, insertion_key: &FacetGroupKey>, @@ -383,7 +383,7 @@ impl FacetsUpdateIncrementalInner { /// fn modify_in_level( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, level: u8, facet_value: &[u8], @@ -523,7 +523,7 @@ impl FacetsUpdateIncrementalInner { /// Otherwise returns `false` if the tree-nodes have been modified in place. pub fn modify( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, facet_value: &[u8], add_docids: Option<&RoaringBitmap>, @@ -558,7 +558,7 @@ impl FacetsUpdateIncrementalInner { /// If it has, we must build an addition level above it. /// Then check whether the highest level is under `min_level_size`. /// If it has, we must remove the complete level. - pub(crate) fn add_or_delete_level(&self, txn: &mut RwTxn, field_id: u16) -> Result<()> { + pub(crate) fn add_or_delete_level(&self, txn: &mut RwTxn<'_>, field_id: u16) -> Result<()> { let highest_level = get_highest_level(txn, self.db, field_id)?; let mut highest_level_prefix = vec![]; highest_level_prefix.extend_from_slice(&field_id.to_be_bytes()); @@ -577,7 +577,7 @@ impl FacetsUpdateIncrementalInner { } /// Delete a level. - fn delete_level(&self, txn: &mut RwTxn, highest_level_prefix: &[u8]) -> Result<()> { + fn delete_level(&self, txn: &mut RwTxn<'_>, highest_level_prefix: &[u8]) -> Result<()> { let mut to_delete = vec![]; let mut iter = self.db.remap_types::().prefix_iter(txn, highest_level_prefix)?; @@ -599,7 +599,7 @@ impl FacetsUpdateIncrementalInner { /// Build an additional level for the field id. fn add_level( &self, - txn: &mut RwTxn, + txn: &mut RwTxn<'_>, field_id: u16, highest_level: u8, highest_level_prefix: &[u8], diff --git a/milli/src/update/facet/mod.rs b/milli/src/update/facet/mod.rs index 42994551f..ad3ddc38f 100644 --- a/milli/src/update/facet/mod.rs +++ b/milli/src/update/facet/mod.rs @@ -141,7 +141,7 @@ impl<'i> FacetsUpdate<'i> { } } - pub fn execute(self, wtxn: &mut heed::RwTxn) -> Result<()> { + pub fn execute(self, wtxn: &mut heed::RwTxn<'_>) -> Result<()> { if self.data_size == 0 { return Ok(()); } @@ -181,7 +181,7 @@ impl<'i> FacetsUpdate<'i> { } fn index_facet_search( - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, normalized_delta_data: Merger, MergeFn>, index: &Index, ) -> Result<()> { @@ -417,7 +417,7 @@ pub(crate) mod test_helpers { pub fn insert<'a>( &self, - wtxn: &'a mut RwTxn, + wtxn: &'a mut RwTxn<'_>, field_id: u16, key: &'a >::EItem, docids: &RoaringBitmap, @@ -434,7 +434,7 @@ pub(crate) mod test_helpers { } pub fn delete_single_docid<'a>( &self, - wtxn: &'a mut RwTxn, + wtxn: &'a mut RwTxn<'_>, field_id: u16, key: &'a >::EItem, docid: u32, @@ -444,7 +444,7 @@ pub(crate) mod test_helpers { pub fn delete<'a>( &self, - wtxn: &'a mut RwTxn, + wtxn: &'a mut RwTxn<'_>, field_id: u16, key: &'a >::EItem, docids: &RoaringBitmap, @@ -462,7 +462,7 @@ pub(crate) mod test_helpers { pub fn bulk_insert<'a, 'b>( &self, - wtxn: &'a mut RwTxn, + wtxn: &'a mut RwTxn<'_>, field_ids: &[u16], els: impl IntoIterator< Item = &'a ((u16, >::EItem), RoaringBitmap), @@ -498,7 +498,7 @@ pub(crate) mod test_helpers { update.update(wtxn, field_ids).unwrap(); } - pub fn verify_structure_validity(&self, txn: &RoTxn, field_id: u16) { + pub fn verify_structure_validity(&self, txn: &RoTxn<'_>, field_id: u16) { let mut field_id_prefix = vec![]; field_id_prefix.extend_from_slice(&field_id.to_be_bytes()); diff --git a/milli/src/update/index_documents/enrich.rs b/milli/src/update/index_documents/enrich.rs index 2da717bb0..691b2b9d1 100644 --- a/milli/src/update/index_documents/enrich.rs +++ b/milli/src/update/index_documents/enrich.rs @@ -24,7 +24,7 @@ use crate::{FieldId, Index, Result}; /// - if reader.is_empty(), this function may panic in some cases #[tracing::instrument(level = "trace", skip_all, target = "indexing::documents")] pub fn enrich_documents_batch( - rtxn: &heed::RoTxn, + rtxn: &heed::RoTxn<'_>, index: &Index, autogenerate_docids: bool, reader: DocumentsBatchReader, @@ -145,9 +145,9 @@ pub fn enrich_documents_batch( #[tracing::instrument(level = "trace", skip(uuid_buffer, documents_batch_index, document) target = "indexing::documents")] fn fetch_or_generate_document_id( - document: &obkv::KvReader, + document: &obkv::KvReader<'_, FieldId>, documents_batch_index: &DocumentsBatchIndex, - primary_key: PrimaryKey, + primary_key: PrimaryKey<'_>, autogenerate_docids: bool, uuid_buffer: &mut [u8; uuid::fmt::Hyphenated::LENGTH], count: u32, diff --git a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs index 9c557de81..721d67e96 100644 --- a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs +++ b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs @@ -179,7 +179,7 @@ pub fn extract_docid_word_positions( /// Check if any searchable fields of a document changed. fn searchable_fields_changed( - obkv: &KvReader, + obkv: &KvReader<'_, FieldId>, settings_diff: &InnerIndexSettingsDiff, ) -> bool { let searchable_fields = &settings_diff.new.searchable_fields_ids; @@ -228,9 +228,9 @@ fn tokenizer_builder<'a>( /// Extract words mapped with their positions of a document, /// ensuring no Language detection mistakes was made. fn lang_safe_tokens_from_document<'a>( - obkv: &KvReader, + obkv: &KvReader<'_, FieldId>, settings: &InnerIndexSettings, - tokenizer: &Tokenizer, + tokenizer: &Tokenizer<'_>, max_positions_per_attributes: u32, del_add: DelAdd, buffers: &'a mut Buffers, @@ -295,9 +295,9 @@ fn lang_safe_tokens_from_document<'a>( /// Extract words mapped with their positions of a document. fn tokens_from_document<'a>( - obkv: &KvReader, + obkv: &KvReader<'a, FieldId>, searchable_fields: &[FieldId], - tokenizer: &Tokenizer, + tokenizer: &Tokenizer<'_>, max_positions_per_attributes: u32, del_add: DelAdd, buffers: &'a mut Buffers, diff --git a/milli/src/update/index_documents/extract/extract_geo_points.rs b/milli/src/update/index_documents/extract/extract_geo_points.rs index f997d6ab7..2c54df74b 100644 --- a/milli/src/update/index_documents/extract/extract_geo_points.rs +++ b/milli/src/update/index_documents/extract/extract_geo_points.rs @@ -68,7 +68,7 @@ pub fn extract_geo_points( /// Extract the finite floats lat and lng from two bytes slices. fn extract_lat_lng( - document: &obkv::KvReader, + document: &obkv::KvReader<'_,FieldId>, settings: &InnerIndexSettings, deladd: DelAdd, document_id: impl Fn() -> Value, diff --git a/milli/src/update/index_documents/helpers/grenad_helpers.rs b/milli/src/update/index_documents/helpers/grenad_helpers.rs index aa574024d..44009f2fa 100644 --- a/milli/src/update/index_documents/helpers/grenad_helpers.rs +++ b/milli/src/update/index_documents/helpers/grenad_helpers.rs @@ -172,7 +172,7 @@ pub fn grenad_obkv_into_chunks( pub fn write_sorter_into_database( sorter: Sorter, database: &heed::Database, - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, index_is_empty: bool, serialize_value: FS, merge_values: FM, diff --git a/milli/src/update/index_documents/helpers/merge_functions.rs b/milli/src/update/index_documents/helpers/merge_functions.rs index a265d152f..42784048a 100644 --- a/milli/src/update/index_documents/helpers/merge_functions.rs +++ b/milli/src/update/index_documents/helpers/merge_functions.rs @@ -45,8 +45,8 @@ pub fn keep_latest_obkv<'a>(_key: &[u8], obkvs: &[Cow<'a, [u8]>]) -> Result, + update: obkv::KvReaderU16<'_>, merge_additions: bool, buffer: &mut Vec, ) { diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 089b56025..5ad442813 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -758,7 +758,7 @@ where name = "index_documents_word_prefix_docids" )] fn execute_word_prefix_docids( - txn: &mut heed::RwTxn, + txn: &mut heed::RwTxn<'_>, merger: Merger, word_docids_db: Database, word_prefix_docids_db: Database, diff --git a/milli/src/update/index_documents/transform.rs b/milli/src/update/index_documents/transform.rs index 1dff29a90..73fa3ca7b 100644 --- a/milli/src/update/index_documents/transform.rs +++ b/milli/src/update/index_documents/transform.rs @@ -102,7 +102,7 @@ fn create_fields_mapping( impl<'a, 'i> Transform<'a, 'i> { pub fn new( - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, index: &'i Index, indexer_settings: &'a IndexerConfig, index_documents_method: IndexDocumentsMethod, @@ -155,7 +155,7 @@ impl<'a, 'i> Transform<'a, 'i> { pub fn read_documents( &mut self, reader: EnrichedDocumentsBatchReader, - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, progress_callback: FP, should_abort: FA, ) -> Result @@ -177,7 +177,7 @@ impl<'a, 'i> Transform<'a, 'i> { let mut document_sorter_key_buffer = Vec::new(); let mut documents_count = 0; let mut docid_buffer: Vec = Vec::new(); - let mut field_buffer: Vec<(u16, Cow<[u8]>)> = Vec::new(); + let mut field_buffer: Vec<(u16, Cow<'_, [u8]>)> = Vec::new(); while let Some(enriched_document) = cursor.next_enriched_document()? { let EnrichedDocument { document, document_id } = enriched_document; @@ -370,7 +370,7 @@ impl<'a, 'i> Transform<'a, 'i> { pub fn remove_documents( &mut self, mut to_remove: Vec, - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, should_abort: FA, ) -> Result where @@ -459,7 +459,7 @@ impl<'a, 'i> Transform<'a, 'i> { pub fn remove_documents_from_db_no_batch( &mut self, to_remove: &RoaringBitmap, - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, should_abort: FA, ) -> Result where @@ -493,7 +493,7 @@ impl<'a, 'i> Transform<'a, 'i> { &mut self, internal_docid: u32, external_docid: String, - txn: &heed::RoTxn, + txn: &heed::RoTxn<'_>, document_sorter_key_buffer: &mut Vec, document_sorter_value_buffer: &mut Vec, ) -> Result<()> { @@ -552,7 +552,7 @@ impl<'a, 'i> Transform<'a, 'i> { target = "indexing::transform" )] fn flatten_from_fields_ids_map( - obkv: &KvReader, + obkv: &KvReader<'_, FieldId>, fields_ids_map: &mut FieldsIdsMap, ) -> Result>> { if obkv @@ -566,7 +566,7 @@ impl<'a, 'i> Transform<'a, 'i> { // We first extract all the key+value out of the obkv. If a value is not nested // we keep a reference on its value. If the value is nested we'll get its value // as an owned `Vec` after flattening it. - let mut key_value: Vec<(FieldId, Cow<[u8]>)> = Vec::new(); + let mut key_value: Vec<(FieldId, Cow<'_, [u8]>)> = Vec::new(); // the object we're going to use to store the fields that need to be flattened. let mut doc = serde_json::Map::new(); @@ -609,7 +609,7 @@ impl<'a, 'i> Transform<'a, 'i> { /// Generate an obkv from a slice of key / value sorted by key. fn create_obkv_from_key_value( - key_value: &mut [(FieldId, Cow<[u8]>)], + key_value: &mut [(FieldId, Cow<'_, [u8]>)], output_buffer: &mut Vec, ) -> Result<()> { debug_assert!( @@ -677,7 +677,7 @@ impl<'a, 'i> Transform<'a, 'i> { #[tracing::instrument(level = "trace", skip_all, target = "indexing::transform")] pub(crate) fn output_from_sorter( self, - wtxn: &mut heed::RwTxn, + wtxn: &mut heed::RwTxn<'_>, progress_callback: F, ) -> Result where @@ -837,7 +837,7 @@ impl<'a, 'i> Transform<'a, 'i> { /// then fill the provided buffers with delta documents using KvWritterDelAdd. #[allow(clippy::too_many_arguments)] // need the vectors + fid, feel free to create a struct xo xo fn rebind_existing_document( - old_obkv: KvReader, + old_obkv: KvReader<'_, FieldId>, settings_diff: &InnerIndexSettingsDiff, modified_faceted_fields: &HashSet, mut injected_vectors: serde_json::Map, @@ -990,7 +990,7 @@ impl<'a, 'i> Transform<'a, 'i> { }; let readers: Result< - BTreeMap<&str, (Vec>, &RoaringBitmap)>, + BTreeMap<&str, (Vec>, &RoaringBitmap)>, > = settings_diff .embedding_config_updates .iter() diff --git a/milli/src/update/index_documents/typed_chunk.rs b/milli/src/update/index_documents/typed_chunk.rs index 4737c6b42..c5cf35ca8 100644 --- a/milli/src/update/index_documents/typed_chunk.rs +++ b/milli/src/update/index_documents/typed_chunk.rs @@ -128,7 +128,7 @@ impl TypedChunk { /// Return new documents seen. #[tracing::instrument(level = "trace", skip_all, target = "indexing::write_db")] pub(crate) fn write_typed_chunk_into_index( - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, index: &Index, settings_diff: &InnerIndexSettingsDiff, typed_chunks: Vec, @@ -165,7 +165,7 @@ pub(crate) fn write_typed_chunk_into_index( let mut vectors_buffer = Vec::new(); while let Some((key, reader)) = iter.next()? { let mut writer: KvWriter<_, FieldId> = KvWriter::memory(); - let reader: KvReader = KvReader::new(reader); + let reader: KvReader<'_, FieldId> = KvReader::new(reader); let (document_id_bytes, external_id_bytes) = try_split_array_at(key) .ok_or(SerializationError::Decoding { db_name: Some(DOCUMENTS) })?; @@ -835,7 +835,7 @@ fn merge_word_docids_reader_into_fst( fn write_entries_into_database( merger: Merger, database: &heed::Database, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, serialize_value: FS, merge_values: FM, ) -> Result<()> @@ -872,7 +872,7 @@ where fn write_proximity_entries_into_database_additional_searchables( merger: Merger, database: &heed::Database, - wtxn: &mut RwTxn, + wtxn: &mut RwTxn<'_>, ) -> Result<()> where R: io::Read + io::Seek, diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index b792cde52..eea7e90b8 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -44,7 +44,7 @@ where { fn deserialize_from_value( value: deserr::Value, - location: deserr::ValuePointerRef, + location: deserr::ValuePointerRef<'_>, ) -> std::result::Result { match value { deserr::Value::Null => Ok(Setting::Reset), @@ -617,7 +617,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> { fn update_synonyms(&mut self) -> Result { match self.synonyms { Setting::Set(ref user_synonyms) => { - fn normalize(tokenizer: &Tokenizer, text: &str) -> Vec { + fn normalize(tokenizer: &Tokenizer<'_>, text: &str) -> Vec { tokenizer .tokenize(text) .filter_map(|token| { @@ -838,7 +838,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> { fn update_exact_words(&mut self) -> Result<()> { match self.exact_words { Setting::Set(ref mut words) => { - fn normalize(tokenizer: &Tokenizer, text: &str) -> String { + fn normalize(tokenizer: &Tokenizer<'_>, text: &str) -> String { tokenizer.tokenize(text).map(|token| token.lemma().to_string()).collect() } @@ -1344,7 +1344,7 @@ pub(crate) struct InnerIndexSettings { } impl InnerIndexSettings { - pub fn from_index(index: &Index, rtxn: &heed::RoTxn) -> Result { + pub fn from_index(index: &Index, rtxn: &heed::RoTxn<'_>) -> Result { let stop_words = index.stop_words(rtxn)?; let stop_words = stop_words.map(|sw| sw.map_data(Vec::from).unwrap()); let allowed_separators = index.allowed_separators(rtxn)?; @@ -1407,7 +1407,7 @@ impl InnerIndexSettings { } // find and insert the new field ids - pub fn recompute_facets(&mut self, wtxn: &mut heed::RwTxn, index: &Index) -> Result<()> { + pub fn recompute_facets(&mut self, wtxn: &mut heed::RwTxn<'_>, index: &Index) -> Result<()> { let new_facets = self .fields_ids_map .iter() @@ -1422,7 +1422,7 @@ impl InnerIndexSettings { } // find and insert the new field ids - pub fn recompute_searchables(&mut self, wtxn: &mut heed::RwTxn, index: &Index) -> Result<()> { + pub fn recompute_searchables(&mut self, wtxn: &mut heed::RwTxn<'_>, index: &Index) -> Result<()> { let searchable_fields = self .user_defined_searchable_fields .as_ref() diff --git a/milli/src/vector/mod.rs b/milli/src/vector/mod.rs index c43fa8bd2..bfe99149b 100644 --- a/milli/src/vector/mod.rs +++ b/milli/src/vector/mod.rs @@ -345,7 +345,7 @@ where { fn deserialize_from_value( value: deserr::Value, - location: deserr::ValuePointerRef, + location: deserr::ValuePointerRef<'_>, ) -> Result { let value = DistributionShiftSerializable::deserialize_from_value(value, location)?; if value.mean < 0. || value.mean > 1. { diff --git a/milli/src/vector/parsed_vectors.rs b/milli/src/vector/parsed_vectors.rs index f555b39ae..11c59e155 100644 --- a/milli/src/vector/parsed_vectors.rs +++ b/milli/src/vector/parsed_vectors.rs @@ -21,7 +21,7 @@ pub enum Vectors { impl Deserr for Vectors { fn deserialize_from_value( value: deserr::Value, - location: deserr::ValuePointerRef, + location: deserr::ValuePointerRef<'_>, ) -> Result { match value { deserr::Value::Sequence(_) | deserr::Value::Null => { @@ -186,7 +186,7 @@ pub struct ParsedVectors(pub BTreeMap); impl Deserr for ParsedVectors { fn deserialize_from_value( value: deserr::Value, - location: deserr::ValuePointerRef, + location: deserr::ValuePointerRef<'_>, ) -> Result { let value = >::deserialize_from_value(value, location)?; Ok(ParsedVectors(value)) @@ -230,7 +230,7 @@ impl Error { } fn to_vector_map( - obkv: KvReaderDelAdd, + obkv: KvReaderDelAdd<'_>, side: DelAdd, ) -> Result>, Error> { Ok(if let Some(value) = obkv.get(side) { @@ -252,7 +252,7 @@ pub struct VectorOrArrayOfVectors { impl Deserr for VectorOrArrayOfVectors { fn deserialize_from_value( value: deserr::Value, - location: deserr::ValuePointerRef, + location: deserr::ValuePointerRef<'_>, ) -> Result { match value { deserr::Value::Null => Ok(VectorOrArrayOfVectors { inner: None }), From 66c606d7f91c9f4503e7fe6e701c17ef18ffebd9 Mon Sep 17 00:00:00 2001 From: hanbings Date: Thu, 4 Jul 2024 08:00:18 -0400 Subject: [PATCH 3/3] Run cargo fmt --- milli/src/external_documents_ids.rs | 12 ++++- milli/src/index.rs | 49 +++++++++++++++---- milli/src/lib.rs | 5 +- milli/src/search/new/logger/visual.rs | 2 +- milli/src/search/new/matches/mod.rs | 7 ++- milli/src/search/new/mod.rs | 5 +- .../src/search/new/query_term/parse_query.rs | 7 ++- .../extract/extract_geo_points.rs | 2 +- milli/src/update/settings.rs | 6 ++- 9 files changed, 77 insertions(+), 18 deletions(-) diff --git a/milli/src/external_documents_ids.rs b/milli/src/external_documents_ids.rs index 2c63087f0..f47df0762 100644 --- a/milli/src/external_documents_ids.rs +++ b/milli/src/external_documents_ids.rs @@ -28,7 +28,11 @@ impl ExternalDocumentsIds { self.0.is_empty(rtxn).map_err(Into::into) } - pub fn get>(&self, rtxn: &RoTxn<'_>, external_id: A) -> heed::Result> { + pub fn get>( + &self, + rtxn: &RoTxn<'_>, + external_id: A, + ) -> heed::Result> { self.0.get(rtxn, external_id.as_ref()) } @@ -51,7 +55,11 @@ impl ExternalDocumentsIds { /// /// - If attempting to delete a document that doesn't exist /// - If attempting to create a document that already exists - pub fn apply(&self, wtxn: &mut RwTxn<'_>, operations: Vec) -> heed::Result<()> { + pub fn apply( + &self, + wtxn: &mut RwTxn<'_>, + operations: Vec, + ) -> heed::Result<()> { for DocumentOperation { external_id, internal_id, kind } in operations { match kind { DocumentOperationKind::Create => { diff --git a/milli/src/index.rs b/milli/src/index.rs index d9fc07b54..bd194d95d 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -375,7 +375,11 @@ impl Index { /* primary key */ /// Writes the documents primary key, this is the field name that is used to store the id. - pub(crate) fn put_primary_key(&self, wtxn: &mut RwTxn<'_>, primary_key: &str) -> heed::Result<()> { + pub(crate) fn put_primary_key( + &self, + wtxn: &mut RwTxn<'_>, + primary_key: &str, + ) -> heed::Result<()> { self.set_updated_at(wtxn, &OffsetDateTime::now_utc())?; self.main.remap_types::().put(wtxn, main_key::PRIMARY_KEY_KEY, primary_key) } @@ -531,7 +535,10 @@ impl Index { } /// Delete the documents ids that are faceted with a _geo field. - pub(crate) fn delete_geo_faceted_documents_ids(&self, wtxn: &mut RwTxn<'_>) -> heed::Result { + pub(crate) fn delete_geo_faceted_documents_ids( + &self, + wtxn: &mut RwTxn<'_>, + ) -> heed::Result { self.main.remap_key_type::().delete(wtxn, main_key::GEO_FACETED_DOCUMENTS_IDS_KEY) } @@ -763,7 +770,10 @@ impl Index { } /// Identical to `user_defined_searchable_fields`, but returns ids instead. - pub fn user_defined_searchable_fields_ids(&self, rtxn: &RoTxn<'_>) -> Result>> { + pub fn user_defined_searchable_fields_ids( + &self, + rtxn: &RoTxn<'_>, + ) -> Result>> { match self.user_defined_searchable_fields(rtxn)? { Some(fields) => { let fields_ids_map = self.fields_ids_map(rtxn)?; @@ -1198,7 +1208,10 @@ impl Index { .unwrap_or_default()) } - pub fn synonyms(&self, rtxn: &RoTxn<'_>) -> heed::Result, Vec>>> { + pub fn synonyms( + &self, + rtxn: &RoTxn<'_>, + ) -> heed::Result, Vec>>> { Ok(self .main .remap_types::>() @@ -1384,7 +1397,11 @@ impl Index { .unwrap_or(DEFAULT_MIN_WORD_LEN_ONE_TYPO)) } - pub(crate) fn put_min_word_len_one_typo(&self, txn: &mut RwTxn<'_>, val: u8) -> heed::Result<()> { + pub(crate) fn put_min_word_len_one_typo( + &self, + txn: &mut RwTxn<'_>, + val: u8, + ) -> heed::Result<()> { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1403,7 +1420,11 @@ impl Index { .unwrap_or(DEFAULT_MIN_WORD_LEN_TWO_TYPOS)) } - pub(crate) fn put_min_word_len_two_typos(&self, txn: &mut RwTxn<'_>, val: u8) -> heed::Result<()> { + pub(crate) fn put_min_word_len_two_typos( + &self, + txn: &mut RwTxn<'_>, + val: u8, + ) -> heed::Result<()> { // It is not possible to put a bool in heed with OwnedType, so we put a u8 instead. We // identify 0 as being false, and anything else as true. The absence of a value is true, // because by default, we authorize typos. @@ -1467,7 +1488,11 @@ impl Index { self.main.remap_types::().get(txn, main_key::MAX_VALUES_PER_FACET) } - pub(crate) fn put_max_values_per_facet(&self, txn: &mut RwTxn<'_>, val: u64) -> heed::Result<()> { + pub(crate) fn put_max_values_per_facet( + &self, + txn: &mut RwTxn<'_>, + val: u64, + ) -> heed::Result<()> { self.main.remap_types::().put(txn, main_key::MAX_VALUES_PER_FACET, &val) } @@ -1508,7 +1533,10 @@ impl Index { self.main.remap_types::().put(txn, main_key::PAGINATION_MAX_TOTAL_HITS, &val) } - pub(crate) fn delete_pagination_max_total_hits(&self, txn: &mut RwTxn<'_>) -> heed::Result { + pub(crate) fn delete_pagination_max_total_hits( + &self, + txn: &mut RwTxn<'_>, + ) -> heed::Result { self.main.remap_key_type::().delete(txn, main_key::PAGINATION_MAX_TOTAL_HITS) } @@ -1544,7 +1572,10 @@ impl Index { self.script_language_docids.get(rtxn, key) } - pub fn script_language(&self, rtxn: &RoTxn<'_>) -> heed::Result>> { + pub fn script_language( + &self, + rtxn: &RoTxn<'_>, + ) -> heed::Result>> { let mut script_language: HashMap> = HashMap::new(); let mut script_language_doc_count: Vec<(Script, Language, u64)> = Vec::new(); let mut total = 0; diff --git a/milli/src/lib.rs b/milli/src/lib.rs index adce740a8..581ffc73c 100644 --- a/milli/src/lib.rs +++ b/milli/src/lib.rs @@ -229,7 +229,10 @@ pub fn obkv_to_json( } /// Transform every field of a raw obkv store into a JSON Object. -pub fn all_obkv_to_json(obkv: obkv::KvReaderU16<'_>, fields_ids_map: &FieldsIdsMap) -> Result { +pub fn all_obkv_to_json( + obkv: obkv::KvReaderU16<'_>, + fields_ids_map: &FieldsIdsMap, +) -> Result { let all_keys = obkv.iter().map(|(k, _v)| k).collect::>(); obkv_to_json(all_keys.as_slice(), fields_ids_map, obkv) } diff --git a/milli/src/search/new/logger/visual.rs b/milli/src/search/new/logger/visual.rs index 5b5a29b65..62c2d6798 100644 --- a/milli/src/search/new/logger/visual.rs +++ b/milli/src/search/new/logger/visual.rs @@ -97,7 +97,7 @@ impl SearchLogger for VisualSearchLogger { fn next_bucket_ranking_rule( &mut self, ranking_rule_idx: usize, - _ranking_rule: &dyn RankingRule<'_,QueryGraph>, + _ranking_rule: &dyn RankingRule<'_, QueryGraph>, universe: &RoaringBitmap, bucket: &RoaringBitmap, ) { diff --git a/milli/src/search/new/matches/mod.rs b/milli/src/search/new/matches/mod.rs index a0cfdaa65..f387e232b 100644 --- a/milli/src/search/new/matches/mod.rs +++ b/milli/src/search/new/matches/mod.rs @@ -244,7 +244,12 @@ impl<'t> Matcher<'t, '_> { } /// Returns the bounds in byte index of the crop window. - fn crop_bounds(&self, tokens: &[Token<'_>], matches: &[Match], crop_size: usize) -> (usize, usize) { + fn crop_bounds( + &self, + tokens: &[Token<'_>], + matches: &[Match], + crop_size: usize, + ) -> (usize, usize) { // if there is no match, we start from the beginning of the string by default. let first_match_word_position = matches.first().map(|m| m.word_position).unwrap_or(0); let first_match_token_position = matches.first().map(|m| m.token_position).unwrap_or(0); diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 2d0d63e0e..208e1b428 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -775,7 +775,10 @@ pub fn execute_search( }) } -fn check_sort_criteria(ctx: &SearchContext<'_>, sort_criteria: Option<&Vec>) -> Result<()> { +fn check_sort_criteria( + ctx: &SearchContext<'_>, + sort_criteria: Option<&Vec>, +) -> Result<()> { let sort_criteria = if let Some(sort_criteria) = sort_criteria { sort_criteria } else { diff --git a/milli/src/search/new/query_term/parse_query.rs b/milli/src/search/new/query_term/parse_query.rs index d7c279a27..d4c1c2f95 100644 --- a/milli/src/search/new/query_term/parse_query.rs +++ b/milli/src/search/new/query_term/parse_query.rs @@ -297,7 +297,12 @@ impl PhraseBuilder { } // precondition: token has kind Word or StopWord - fn push_word(&mut self, ctx: &mut SearchContext<'_>, token: &charabia::Token<'_>, position: u16) { + fn push_word( + &mut self, + ctx: &mut SearchContext<'_>, + token: &charabia::Token<'_>, + position: u16, + ) { if self.is_empty() { self.start = position; } diff --git a/milli/src/update/index_documents/extract/extract_geo_points.rs b/milli/src/update/index_documents/extract/extract_geo_points.rs index 2c54df74b..ac8b7abee 100644 --- a/milli/src/update/index_documents/extract/extract_geo_points.rs +++ b/milli/src/update/index_documents/extract/extract_geo_points.rs @@ -68,7 +68,7 @@ pub fn extract_geo_points( /// Extract the finite floats lat and lng from two bytes slices. fn extract_lat_lng( - document: &obkv::KvReader<'_,FieldId>, + document: &obkv::KvReader<'_, FieldId>, settings: &InnerIndexSettings, deladd: DelAdd, document_id: impl Fn() -> Value, diff --git a/milli/src/update/settings.rs b/milli/src/update/settings.rs index eea7e90b8..3ad6e658c 100644 --- a/milli/src/update/settings.rs +++ b/milli/src/update/settings.rs @@ -1422,7 +1422,11 @@ impl InnerIndexSettings { } // find and insert the new field ids - pub fn recompute_searchables(&mut self, wtxn: &mut heed::RwTxn<'_>, index: &Index) -> Result<()> { + pub fn recompute_searchables( + &mut self, + wtxn: &mut heed::RwTxn<'_>, + index: &Index, + ) -> Result<()> { let searchable_fields = self .user_defined_searchable_fields .as_ref()