query_runtime/runtime/
execution_policy.rs1use query_planning::error::{QueryError, QueryErrorCode, Result};
4
5#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
6pub enum MemoryResourcePolicy {
7 #[default]
8 DefaultCuda,
9 Pool {
10 initial_pool_size: usize,
11 maximum_pool_size: Option<usize>,
12 },
13 ExternalRuntime,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
18pub struct SourceSchedulerPolicy {
19 max_source_reads_in_flight: usize,
20}
21
22impl SourceSchedulerPolicy {
23 pub const fn serialized() -> Self {
25 Self { max_source_reads_in_flight: 1 }
26 }
27
28 pub const fn new(max_source_reads_in_flight: usize) -> Self {
31 Self { max_source_reads_in_flight }
32 }
33
34 pub const fn max_source_reads_in_flight(self) -> usize {
36 self.max_source_reads_in_flight
37 }
38
39 pub const fn enables_prefetch(self) -> bool {
41 self.max_source_reads_in_flight > 1
42 }
43
44 pub fn validate(self) -> Result<()> {
46 if self.max_source_reads_in_flight == 0 {
47 return Err(QueryError::new(
48 QueryErrorCode::InvalidConfiguration,
49 "query_engine.source_scheduler_policy.validate",
50 "source scheduler max_source_reads_in_flight must be greater than zero",
51 )
52 .with_fact("field", "max_source_reads_in_flight")
53 .with_fact("reason", "zero"));
54 }
55 Ok(())
56 }
57}
58
59impl Default for SourceSchedulerPolicy {
60 fn default() -> Self {
61 Self { max_source_reads_in_flight: 2 }
62 }
63}