Materialize ranked non-subject inputs whole and expose them to extent overrides

This commit is contained in:
Dennis Kobert
2026-08-17 09:26:59 +00:00
parent a03db0ac6c
commit 0f3e3f7337
5 changed files with 81 additions and 6 deletions

View File

@@ -42,6 +42,23 @@ impl<'a> ExtentIn<'a> {
}
}
/// A ranked (`IList`) input materialized whole: `get` drives the batch and
/// yields the level as a [`List`](crate::node::List), for extents that depend
/// on the input's data rather than its counts alone.
pub struct ListIn<'a, T> {
get: &'a dyn Fn() -> GPoll<crate::node::List<'a, T>>,
}
impl<'a, T> ListIn<'a, T> {
pub fn new(get: &'a dyn Fn() -> GPoll<crate::node::List<'a, T>>) -> Self {
Self { get }
}
pub fn get(&self) -> GPoll<crate::node::List<'a, T>> {
(self.get)()
}
}
/// The queried absolute level (innermost `0`), paired with the node's depth.
#[derive(Clone, Copy, Debug)]
pub struct LevelIn {

View File

@@ -177,7 +177,7 @@ pub struct List<'a, T> {
_element: PhantomData<T>,
}
impl<'a, T: Copy> List<'a, T> {
impl<'a, T> List<'a, T> {
/// # Safety
/// `T` must be the batch's record element type, proven at the consumer's wiring.
pub unsafe fn new(batch: RecordBatch<'a>) -> Self {
@@ -192,12 +192,30 @@ impl<'a, T: Copy> List<'a, T> {
self.batch.is_empty()
}
pub fn get(&self, index: usize) -> T {
pub fn get(&self, index: usize) -> T
where
T: Copy,
{
// SAFETY: `List::new` established that `T` is the batch's element type.
unsafe { self.batch.get(index).element::<T>() }
}
pub fn iter(&self) -> impl Iterator<Item = T> + '_ {
/// Borrows lane `index`'s element, through the park for droppable types.
pub fn element_ref(&self, index: usize) -> &T {
// SAFETY: `List::new` established that `T` is the batch's element type,
// and the borrow lives within the batch's own lifetime.
unsafe { crate::record::borrow_element::<T>(self.batch.get(index).rec()) }
}
/// Lane `index`'s record, for attribute reads beside the element.
pub fn lane(&self, index: usize) -> RecordLane<'a> {
self.batch.get(index)
}
pub fn iter(&self) -> impl Iterator<Item = T> + '_
where
T: Copy,
{
(0..self.len()).map(move |index| self.get(index))
}
}