pub mod bm25;
pub mod fusion;
pub mod jaccard;
pub mod sketch;
pub mod tfidf;
pub mod top_k;
#[cfg(any(test, feature = "bench"))]
pub mod sketch_bench {
use crate::retrieval::sketch;
#[inline(always)]
pub fn hamming(a: &[u64], b: &[u64]) -> u32 {
sketch::hamming(a, b)
}
#[inline(always)]
pub fn hamming_scalar(a: &[u64], b: &[u64]) -> u32 {
sketch::hamming_scalar(a, b)
}
#[cfg(target_arch = "x86_64")]
#[inline(always)]
pub unsafe fn hamming_avx2_popcnt(a: &[u64], b: &[u64]) -> u32 {
unsafe { sketch::hamming_x86_64_bench::hamming_popcnt(a, b) }
}
#[cfg(target_arch = "x86_64")]
#[inline(always)]
pub unsafe fn hamming_avx2_shuffle(a: &[u64], b: &[u64]) -> u32 {
unsafe { sketch::hamming_x86_64_bench::hamming_shuffle(a, b) }
}
}
use crate::file::text_indexing::TextSpaceState;
use crate::format::{FrameId, TermId};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Hit {
pub frame_id: FrameId,
pub score: f32,
}
pub(crate) fn resolve_query_terms(
state: &TextSpaceState,
query_tokens: &[Vec<u8>],
) -> Vec<(TermId, u32)> {
let mut qfs: Vec<(TermId, u32)> = Vec::with_capacity(query_tokens.len());
for token in query_tokens {
if let Some(term_id) = state.lookup_term(token) {
match qfs.iter_mut().find(|(t, _)| *t == term_id) {
Some((_, qf)) => *qf += 1,
None => qfs.push((term_id, 1)),
}
}
}
qfs
}