diff --git a/meilidb-core/src/query_builder.rs b/meilidb-core/src/query_builder.rs index 78557c9a4..ca9b43467 100644 --- a/meilidb-core/src/query_builder.rs +++ b/meilidb-core/src/query_builder.rs @@ -702,7 +702,7 @@ mod tests { for ((docid, attr, _), count) in fields_counts { let prev = index.documents_fields_counts - .document_attribute_count( + .document_field_count( &mut writer, docid, SchemaAttr(attr), diff --git a/meilidb-core/src/store/documents_fields_counts.rs b/meilidb-core/src/store/documents_fields_counts.rs index 95aff986a..75b50966e 100644 --- a/meilidb-core/src/store/documents_fields_counts.rs +++ b/meilidb-core/src/store/documents_fields_counts.rs @@ -27,19 +27,14 @@ impl DocumentsFieldsCounts { document_id: DocumentId, ) -> Result { - let document_id_bytes = document_id.0.to_be_bytes(); let mut keys_to_delete = Vec::new(); // WARN we can not delete the keys using the iterator // so we store them and delete them just after - let iter = self.documents_fields_counts.iter_from(writer, document_id_bytes)?; - for result in iter { - let (key, _) = result?; - let array = TryFrom::try_from(key).unwrap(); - let (current_document_id, _) = document_attribute_from_key(array); - if current_document_id != document_id { break } - - keys_to_delete.push(key.to_owned()); + for result in self.document_fields_counts(writer, document_id)? { + let (attribute, _) = result?; + let key = document_attribute_into_key(document_id, attribute); + keys_to_delete.push(key); } let count = keys_to_delete.len(); @@ -50,9 +45,9 @@ impl DocumentsFieldsCounts { Ok(count) } - pub fn document_attribute_count<'a>( + pub fn document_field_count( &self, - reader: &'a impl rkv::Readable, + reader: &impl rkv::Readable, document_id: DocumentId, attribute: SchemaAttr, ) -> Result, rkv::StoreError> @@ -92,7 +87,7 @@ pub struct DocumentFieldsCountsIter<'r> { iter: rkv::store::single::Iter<'r>, } -impl<'r> Iterator for DocumentFieldsCountsIter<'r> { +impl Iterator for DocumentFieldsCountsIter<'_> { type Item = Result<(SchemaAttr, u64), rkv::StoreError>; fn next(&mut self) -> Option { @@ -116,7 +111,7 @@ pub struct DocumentsIdsIter<'r> { iter: rkv::store::single::Iter<'r>, } -impl<'r> Iterator for DocumentsIdsIter<'r> { +impl Iterator for DocumentsIdsIter<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/meilidb-core/src/update/customs_update.rs b/meilidb-core/src/update/customs_update.rs index fa65d7c67..5334b6659 100644 --- a/meilidb-core/src/update/customs_update.rs +++ b/meilidb-core/src/update/customs_update.rs @@ -1,5 +1,5 @@ -use crate::{store, error::UnsupportedOperation, MResult}; use crate::update::{Update, next_update_id}; +use crate::{store, MResult}; pub fn apply_customs_update( writer: &mut rkv::Writer,