use crate::backend::native::CpuProfile;
#[derive(Clone, Debug)]
pub struct NativeConfig {
pub create_if_missing: bool,
pub reserve_node_capacity: Option<usize>,
pub reserve_edge_capacity: Option<usize>,
pub cpu_profile: Option<CpuProfile>,
pub max_parallel_transactions: usize,
}
impl Default for NativeConfig {
fn default() -> Self {
Self {
create_if_missing: true,
reserve_node_capacity: None,
reserve_edge_capacity: None,
cpu_profile: None,
max_parallel_transactions: 4,
}
}
}
impl NativeConfig {
pub fn effective_cpu_profile(&self) -> CpuProfile {
if let Ok(env_profile) = std::env::var("SQLITEGRAPH_NATIVE_CPU_PROFILE") {
if let Ok(profile) = env_profile.parse() {
return crate::backend::native::cpu_tuning::resolve_cpu_profile(profile);
}
eprintln!(
"Warning: Invalid SQLITEGRAPH_NATIVE_CPU_PROFILE '{}', using default profile",
env_profile
);
}
if let Some(profile) = self.cpu_profile {
return crate::backend::native::cpu_tuning::resolve_cpu_profile(profile);
}
CpuProfile::Generic
}
pub fn with_cpu_profile(mut self, profile: CpuProfile) -> Self {
self.cpu_profile = Some(profile);
self
}
pub fn with_parallel_recovery(mut self, degree: usize) -> Self {
self.max_parallel_transactions = degree;
self
}
}