use std::fmt;
use std::ops::Range;
use vortex_error::VortexResult;
use vortex_io::request::IoBatch;
use vortex_io::request::IoConsumer;
use crate::planning::morsel::Morsel;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WorkScope {
pub file_ordinal: u64,
pub rows: Range<u64>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum State {
Done,
NeedsCompute,
Waiting,
}
pub enum PlannerOutput {
Done,
Continue,
NeedsIO(IoBatch),
Planner(WorkScope, Box<dyn Planner>),
Morsel(WorkScope, Box<dyn Morsel>),
}
pub trait Planner: IoConsumer + Send {
fn state(&self) -> State;
fn compute(&mut self) -> VortexResult<PlannerOutput>;
}
impl fmt::Debug for PlannerOutput {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Done => f.write_str("Done"),
Self::Continue => f.write_str("Continue"),
Self::NeedsIO(batch) => f.debug_tuple("NeedsIO").field(batch).finish(),
Self::Planner(scope, _) => f.debug_tuple("Planner").field(scope).finish(),
Self::Morsel(scope, _) => f.debug_tuple("Morsel").field(scope).finish(),
}
}
}