use vortex_error::VortexResult;
use vortex_error::vortex_err;
use super::BatchPlan;
use crate::ArrayRef;
use crate::dtype::DType;
use crate::scalar_fn::ExecutionArgs;
#[derive(Clone, Copy)]
pub(crate) struct BorrowedRowFnArgs<'a> {
arrays: &'a [ArrayRef],
row_count: usize,
dtypes: &'a [DType],
plan: &'a BatchPlan,
}
impl<'a> BorrowedRowFnArgs<'a> {
pub(crate) fn new(
arrays: &'a [ArrayRef],
row_count: usize,
dtypes: &'a [DType],
plan: &'a BatchPlan,
) -> Self {
Self {
arrays,
row_count,
dtypes,
plan,
}
}
pub(crate) fn dtypes(&self) -> &'a [DType] {
self.dtypes
}
pub(crate) fn plan(&self) -> &'a BatchPlan {
self.plan
}
}
impl ExecutionArgs for BorrowedRowFnArgs<'_> {
fn get(&self, index: usize) -> VortexResult<ArrayRef> {
self.arrays.get(index).cloned().ok_or_else(|| {
vortex_err!(
"row-function input index must be less than {}, got {index}",
self.arrays.len(),
)
})
}
fn num_inputs(&self) -> usize {
self.arrays.len()
}
fn row_count(&self) -> usize {
self.row_count
}
}