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::VortexSession;
use vortex_session::registry::Id;
use crate::execution::pipeline::Chain;
use crate::execution::pipeline::Compiler;
use crate::plan::PlanRef;
use crate::plan::PlanSlots;
use crate::plan::typed::Plan;
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_slots(
plan: &Plan<Self>,
slots: &PlanSlots,
data: &mut Self::PlanData,
) -> VortexResult<()> {
let _ = (plan, slots, data);
Ok(())
}
fn slot_name(plan: &Plan<Self>, slot: usize) -> Cow<'_, str> {
let _ = plan;
Cow::Owned(format!("slot[{slot}]"))
}
fn is_data_source(_plan: &Plan<Self>) -> bool {
false
}
fn reduce(_plan: &Plan<Self>, _session: &VortexSession) -> VortexResult<Option<PlanRef>> {
Ok(None)
}
fn reduce_parent(
_plan: &Plan<Self>,
_parent: &PlanRef,
_slot: usize,
_session: &VortexSession,
) -> VortexResult<Option<PlanRef>> {
Ok(None)
}
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())
}
}