From 064158e4e29077749b8eb18dd87a706ec71908e5 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 1 Feb 2023 15:34:01 +0100 Subject: [PATCH] Update test --- milli/src/heed_codec/mod.rs | 1 - milli/src/index.rs | 5 ++--- milli/src/update/delete_documents.rs | 29 +++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/milli/src/heed_codec/mod.rs b/milli/src/heed_codec/mod.rs index f3ca5f0d1..a4df63e22 100644 --- a/milli/src/heed_codec/mod.rs +++ b/milli/src/heed_codec/mod.rs @@ -23,4 +23,3 @@ pub use self::roaring_bitmap_length::{ pub use self::script_language_codec::ScriptLanguageCodec; pub use self::str_beu32_codec::StrBEU32Codec; pub use self::str_str_u8_codec::{U8StrStrCodec, UncheckedU8StrStrCodec}; -pub use self::script_language_codec::ScriptLanguageCodec; diff --git a/milli/src/index.rs b/milli/src/index.rs index ef26fc305..803c04a50 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -19,8 +19,7 @@ use crate::heed_codec::facet::{ FacetGroupKeyCodec, FacetGroupValueCodec, FieldDocIdFacetF64Codec, FieldDocIdFacetStringCodec, FieldIdCodec, OrderedF64Codec, }; -use crate::heed_codec::StrRefCodec; -use crate::heed_codec::ScriptLanguageCodec; +use crate::heed_codec::{ScriptLanguageCodec, StrRefCodec}; use crate::{ default_criteria, BEU32StrCodec, BoRoaringBitmapCodec, CboRoaringBitmapCodec, Criterion, DocumentId, ExternalDocumentsIds, FacetDistribution, FieldDistribution, FieldId, @@ -154,7 +153,7 @@ impl Index { ) -> Result { use db_name::*; - options.max_dbs(18); + options.max_dbs(19); unsafe { options.flag(Flags::MdbAlwaysFreePages) }; let env = options.open(path)?; diff --git a/milli/src/update/delete_documents.rs b/milli/src/update/delete_documents.rs index 7e9b11592..0fbf53f74 100644 --- a/milli/src/update/delete_documents.rs +++ b/milli/src/update/delete_documents.rs @@ -1184,8 +1184,9 @@ mod tests { stats_should_not_return_deleted_documents_(DeletionStrategy::AlwaysSoft); } - #[test] - fn stored_detected_script_and_language_should_not_return_deleted_documents() { + fn stored_detected_script_and_language_should_not_return_deleted_documents_( + deletion_strategy: DeletionStrategy, + ) { use charabia::{Language, Script}; let index = TempIndex::new(); let mut wtxn = index.write_txn().unwrap(); @@ -1202,14 +1203,32 @@ mod tests { ])) .unwrap(); - delete_documents(&mut wtxn, &index, &["1"]); + let key_cmn = (Script::Cj, Language::Cmn); + let cj_cmn_docs = + index.script_language_documents_ids(&wtxn, &key_cmn).unwrap().unwrap_or_default(); + let mut expected_cj_cmn_docids = RoaringBitmap::new(); + expected_cj_cmn_docids.push(1); + expected_cj_cmn_docids.push(5); + assert_eq!(cj_cmn_docs, expected_cj_cmn_docids); + + delete_documents(&mut wtxn, &index, &["1"], deletion_strategy); wtxn.commit().unwrap(); let rtxn = index.read_txn().unwrap(); - let key_cmn = (Script::Cj, Language::Cmn); - let cj_cmn_docs = index.script_language_documents_ids(&rtxn, &key_cmn).unwrap().unwrap(); + let cj_cmn_docs = + index.script_language_documents_ids(&rtxn, &key_cmn).unwrap().unwrap_or_default(); let mut expected_cj_cmn_docids = RoaringBitmap::new(); expected_cj_cmn_docids.push(5); assert_eq!(cj_cmn_docs, expected_cj_cmn_docids); } + + #[test] + fn stored_detected_script_and_language_should_not_return_deleted_documents() { + stored_detected_script_and_language_should_not_return_deleted_documents_( + DeletionStrategy::AlwaysHard, + ); + stored_detected_script_and_language_should_not_return_deleted_documents_( + DeletionStrategy::AlwaysSoft, + ); + } }