diff --git a/Cargo.toml b/Cargo.toml index 7a697652c..8f77ef6c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,6 @@ lz4-compression = ["lz4"] failpoints = ["fail/failpoints"] unstable = [] # useful for benches. wasm-bindgen = ["uuid/wasm-bindgen"] -scoref64 = [] # scores are f64 instead of f32. was introduced to debug blockwand. [workspace] members = ["query-grammar"] diff --git a/src/directory/footer.rs b/src/directory/footer.rs index aa1854d48..33f6d06d4 100644 --- a/src/directory/footer.rs +++ b/src/directory/footer.rs @@ -271,7 +271,11 @@ mod tests { let mut vec = Vec::new(); let footer_proxy = FooterProxy::new(&mut vec); assert!(footer_proxy.terminate().is_ok()); - assert_eq!(vec.len(), 167); + if crate::store::COMPRESSION == "lz4" { + assert_eq!(vec.len(), 158); + } else { + assert_eq!(vec.len(), 167); + } let footer = Footer::deserialize(&mut &vec[..]).unwrap(); assert!(matches!( footer.versioned_footer, diff --git a/src/lib.rs b/src/lib.rs index 9789f46e1..e3a792648 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,18 +245,6 @@ pub type DocId = u32; /// with opstamp `n+1`. pub type Opstamp = u64; -/// A Score that represents the relevance of the document to the query -/// -/// This is modelled internally as a `f64`, because tantivy was compiled with the `scoref64` -/// feature. The larger the number, the more relevant the document is to the search query. -#[cfg(feature = "scoref64")] -pub type Score = f64; - -/// A Score that represents the relevance of the document to the query -/// -/// This is modelled internally as a `f32`. The larger the number, the more relevant -/// the document to the search query. -#[cfg(not(feature = "scoref64"))] pub type Score = f32; /// A `SegmentLocalId` identifies a segment. diff --git a/src/postings/compression/mod.rs b/src/postings/compression/mod.rs index e024ce575..5fd5d6a90 100644 --- a/src/postings/compression/mod.rs +++ b/src/postings/compression/mod.rs @@ -310,6 +310,7 @@ pub mod tests { mod bench { use super::*; + use crate::TERMINATED; use rand::rngs::StdRng; use rand::Rng; use rand::SeedableRng; @@ -340,7 +341,7 @@ mod bench { let mut encoder = BlockEncoder::new(); let data = generate_array(COMPRESSION_BLOCK_SIZE, 0.1); let (num_bits, compressed) = encoder.compress_block_sorted(&data, 0u32); - let mut decoder = BlockDecoder::new(); + let mut decoder = BlockDecoder::default(); b.iter(|| { decoder.uncompress_block_sorted(compressed, 0u32, num_bits); }); @@ -375,9 +376,9 @@ mod bench { let mut encoder = BlockEncoder::new(); let data = generate_array(NUM_INTS_BENCH_VINT, 0.001); let compressed = encoder.compress_vint_sorted(&data, 0u32); - let mut decoder = BlockDecoder::new(); + let mut decoder = BlockDecoder::default(); b.iter(|| { - decoder.uncompress_vint_sorted(compressed, 0u32, NUM_INTS_BENCH_VINT); + decoder.uncompress_vint_sorted(compressed, 0u32, NUM_INTS_BENCH_VINT, TERMINATED); }); } } diff --git a/src/postings/mod.rs b/src/postings/mod.rs index a3ce3611d..3f9cce259 100644 --- a/src/postings/mod.rs +++ b/src/postings/mod.rs @@ -727,7 +727,7 @@ mod bench { let mut s = 0u32; while segment_postings.doc() != TERMINATED { s += (segment_postings.doc() & n) % 1024; - segment_postings.advance() + segment_postings.advance(); } s }); diff --git a/src/postings/segment_postings.rs b/src/postings/segment_postings.rs index 839224cb4..25c7a5ff4 100644 --- a/src/postings/segment_postings.rs +++ b/src/postings/segment_postings.rs @@ -114,7 +114,7 @@ impl SegmentPostings { .iter() .map(|&fieldnorm| fieldnorm as u64) .sum::(); - total_num_tokens as Score / fieldnorms.len() as f32 + total_num_tokens as Score / fieldnorms.len() as Score }) .unwrap_or(0.0); let mut postings_serializer = PostingsSerializer::new( diff --git a/src/query/union.rs b/src/query/union.rs index 1209af4c6..6b189cadd 100644 --- a/src/query/union.rs +++ b/src/query/union.rs @@ -398,9 +398,9 @@ mod bench { use crate::query::score_combiner::DoNothingCombiner; use crate::query::{ConstScorer, Union, VecDocSet}; - use crate::tests; use crate::DocId; use crate::DocSet; + use crate::{tests, TERMINATED}; use test::Bencher; #[bench] @@ -414,10 +414,12 @@ mod bench { union_docset .iter() .map(|doc_ids| VecDocSet::from(doc_ids.clone())) - .map(ConstScorer::new) + .map(|docset| ConstScorer::new(docset, 1.0)) .collect::>(), ); - while v.advance() {} + while v.doc() != TERMINATED { + v.advance(); + } }); } #[bench] @@ -432,10 +434,12 @@ mod bench { union_docset .iter() .map(|doc_ids| VecDocSet::from(doc_ids.clone())) - .map(ConstScorer::new) + .map(|docset| ConstScorer::new(docset, 1.0)) .collect::>(), ); - while v.advance() {} + while v.doc() != TERMINATED { + v.advance(); + } }); } }