use std::borrow::Cow;
use std::fmt;
use std::fmt::Debug;
use std::ops::Range;
use vortex_array::DeserializeMetadata;
use vortex_array::SerializeMetadata;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_mask::Mask;
use vortex_session::registry::Id;
use crate::plan::physical::PlanChildren;
use crate::plan::physical::pipeline::Chain;
use crate::plan::physical::pipeline::Compiler;
use crate::plan::physical::pipeline::Reach;
use crate::plan::physical::typed::Plan;
use crate::segments::SegmentId;
pub type PlanId = Id;
pub trait PlanVTable: 'static + Clone + Sized + Send + Sync + Debug {
type PlanData: 'static + Send + Sync + Clone + Debug;
type Metadata: SerializeMetadata + DeserializeMetadata + Debug;
fn id(&self) -> PlanId;
fn fmt(plan: &Plan<Self>, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let _ = (plan, formatter);
Ok(())
}
fn metadata(plan: &Plan<Self>) -> Option<Self::Metadata>;
fn with_children(
plan: &Plan<Self>,
children: &PlanChildren,
data: &mut Self::PlanData,
) -> VortexResult<()> {
let _ = (plan, children, data);
Ok(())
}
fn child_name(plan: &Plan<Self>, index: usize) -> Cow<'_, str> {
let _ = plan;
Cow::Owned(format!("child[{index}]"))
}
fn compile(
plan: &Plan<Self>,
rows: Range<u64>,
mask: &Mask,
compiler: &mut Compiler<'_>,
) -> VortexResult<Option<Chain>> {
let _ = (rows, mask, compiler);
vortex_bail!("Plan {} has no pipeline implementation", plan.vtable().id())
}
fn reach(
plan: &Plan<Self>,
rows: Range<u64>,
at: &Reach,
visit: &mut dyn FnMut(SegmentId, Range<u64>),
) -> VortexResult<()> {
let _ = (plan, rows, at, visit);
Ok(())
}
}