pub mod bits;
pub(crate) mod operator;
pub mod row_selection;
mod types;
pub mod vec;
pub mod view;
use std::cell::RefCell;
pub use row_selection::*;
pub use types::*;
use vec::VectorRef;
use vortex_error::VortexResult;
use self::vec::Vector;
use self::view::ViewMut;
use crate::Canonical;
use crate::operator::Operator;
use crate::pipeline::bits::BitView;
pub const N: usize = 1024;
pub const N_WORDS: usize = N / usize::BITS as usize;
pub trait PipelinedOperator: Operator {
fn row_selection(&self) -> RowSelection;
fn bind(&self, ctx: &dyn BindContext) -> VortexResult<Box<dyn Kernel>>;
fn vector_children(&self) -> Vec<usize>;
fn batch_children(&self) -> Vec<usize>;
}
pub trait BindContext {
fn children(&self) -> &[VectorId];
fn batch_inputs(&self) -> &[BatchId];
}
pub type VectorId = usize;
pub type BatchId = usize;
pub trait Kernel: Send {
fn step(
&self,
ctx: &KernelContext,
chunk_idx: usize,
selection: &BitView,
out: &mut ViewMut,
) -> VortexResult<()>;
}
pub struct KernelContext {
pub(crate) vectors: Vec<RefCell<Vector>>,
pub(crate) batch_inputs: Vec<Canonical>,
}
impl KernelContext {
pub fn vector(&self, vector_id: VectorId) -> VectorRef<'_> {
VectorRef::new(self.vectors[vector_id].borrow())
}
pub fn batch_input(&self, batch_id: BatchId) -> &Canonical {
&self.batch_inputs[batch_id]
}
}