#[derive(Debug, Clone)]
pub struct BulkInsertConfig {
pub batch_size: usize,
pub defer_index_updates: bool,
pub memory_threshold: usize,
pub parallel_processing: bool,
pub worker_threads: usize,
}
impl Default for BulkInsertConfig {
fn default() -> Self {
Self {
batch_size: 10000,
defer_index_updates: true,
memory_threshold: 256 * 1024 * 1024, parallel_processing: true,
worker_threads: std::thread::available_parallelism()
.map(|n| n.get().min(8))
.unwrap_or(4),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_worker_threads_is_cpu_based_and_bounded() {
let config = BulkInsertConfig::default();
assert!(config.worker_threads >= 1);
assert!(config.worker_threads <= 8);
}
}