use query_planning::error::{QueryError, QueryErrorCode, Result};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MemoryResourcePolicy {
#[default]
DefaultCuda,
Pool {
initial_pool_size: usize,
maximum_pool_size: Option<usize>,
},
ExternalRuntime,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SourceSchedulerPolicy {
max_source_reads_in_flight: usize,
}
impl SourceSchedulerPolicy {
pub const fn serialized() -> Self {
Self { max_source_reads_in_flight: 1 }
}
pub const fn new(max_source_reads_in_flight: usize) -> Self {
Self { max_source_reads_in_flight }
}
pub const fn max_source_reads_in_flight(self) -> usize {
self.max_source_reads_in_flight
}
pub const fn enables_prefetch(self) -> bool {
self.max_source_reads_in_flight > 1
}
pub fn validate(self) -> Result<()> {
if self.max_source_reads_in_flight == 0 {
return Err(QueryError::new(
QueryErrorCode::InvalidConfiguration,
"query_engine.source_scheduler_policy.validate",
"source scheduler max_source_reads_in_flight must be greater than zero",
)
.with_fact("field", "max_source_reads_in_flight")
.with_fact("reason", "zero"));
}
Ok(())
}
}
impl Default for SourceSchedulerPolicy {
fn default() -> Self {
Self { max_source_reads_in_flight: 2 }
}
}