use std::cmp::max;
#[must_use]
pub fn bm25_pool(limit: u32, candidate_floor: u32) -> u32 {
max(limit.saturating_mul(2), max(candidate_floor, 50))
}
#[must_use]
pub fn vector_pool(limit: u32, candidate_floor: u32) -> u32 {
max(
limit.saturating_mul(5),
max(candidate_floor.saturating_mul(2), 100),
)
}
#[must_use]
pub fn fuzzy_pool(limit: u32, candidate_floor: u32) -> u32 {
max(limit.saturating_mul(2), max(candidate_floor, 50))
}
#[must_use]
pub fn rrf_pool(limit: u32, candidate_floor: u32) -> u32 {
max(limit, candidate_floor)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_bm25_pool() {
assert_eq!(bm25_pool(1, 40), 50);
assert_eq!(bm25_pool(10, 40), 50);
assert_eq!(bm25_pool(1000, 40), 2000);
assert_eq!(bm25_pool(1, 100), 100);
assert_eq!(bm25_pool(10, 100), 100);
assert_eq!(bm25_pool(1000, 100), 2000);
}
#[test]
fn test_vector_pool() {
assert_eq!(vector_pool(1, 40), 100);
assert_eq!(vector_pool(10, 40), 100);
assert_eq!(vector_pool(1000, 40), 5000);
assert_eq!(vector_pool(1, 100), 200);
assert_eq!(vector_pool(10, 100), 200);
assert_eq!(vector_pool(1000, 100), 5000);
}
#[test]
fn test_fuzzy_pool() {
assert_eq!(fuzzy_pool(1, 40), 50);
assert_eq!(fuzzy_pool(10, 40), 50);
assert_eq!(fuzzy_pool(1000, 40), 2000);
assert_eq!(fuzzy_pool(1, 100), 100);
assert_eq!(fuzzy_pool(10, 100), 100);
assert_eq!(fuzzy_pool(1000, 100), 2000);
}
#[test]
fn test_rrf_pool() {
assert_eq!(rrf_pool(1, 40), 40);
assert_eq!(rrf_pool(10, 40), 40);
assert_eq!(rrf_pool(1000, 40), 1000);
assert_eq!(rrf_pool(1, 100), 100);
assert_eq!(rrf_pool(10, 100), 100);
assert_eq!(rrf_pool(1000, 100), 1000);
}
}