use crate::common::defaults::thread_count_for_hnsw;
pub mod build_condition_checker;
mod config;
mod entry_points;
pub mod graph_layers;
pub mod graph_layers_builder;
mod graph_layers_healer;
pub mod graph_links;
pub mod hnsw;
mod links_container;
pub mod point_scorer;
mod search_context;
#[derive(Debug, Clone, Copy)]
pub struct HnswM {
pub m: usize,
pub m0: usize,
}
impl HnswM {
pub fn new(m: usize, m0: usize) -> Self {
Self { m, m0 }
}
pub fn new2(m: usize) -> Self {
Self { m, m0: 2 * m }
}
pub fn level_m(&self, level: usize) -> usize {
if level == 0 { self.m0 } else { self.m }
}
}
#[cfg(not(feature = "gpu"))]
pub mod gpu {
pub mod gpu_devices_manager {
pub struct LockedGpuDevice<'a> {
phantom: std::marker::PhantomData<&'a usize>,
}
}
pub mod gpu_insert_context {
pub struct GpuInsertContext<'a> {
phantom: std::marker::PhantomData<&'a usize>,
}
}
pub mod gpu_vector_storage {
pub struct GpuVectorStorage {}
}
}
#[cfg(test)]
mod tests;
pub fn get_num_indexing_threads(max_indexing_threads: usize) -> usize {
if max_indexing_threads == 0 {
let num_cpu = crate::common::cpu::get_num_cpus();
num_cpu.clamp(1, thread_count_for_hnsw(num_cpu))
} else {
max_indexing_threads
}
}