@@ -67,19 +67,19 @@ pub trait BindContext {
6767/// Each step of the kernel processes zero or more input vectors, and writes output to a
6868/// pre-allocated mutable output vector.
6969///
70- /// Input vectors are provided via the [`KernelCtx`] and indicate the position of their elements
71- /// as either [`PipelineVector::InPlace`] or [`PipelineVector::Compact`] based on whether
72- /// the selected elements are in their original positions or compacted at the start of the vector
73- /// respectively.
70+ /// Input vectors will either have length [`N`], indicating that all elements from the step are
71+ /// present. Or they will have length equal to the [`BitView::true_count`] of the selection mask,
72+ /// in which case only the selected elements are present.
7473///
75- /// The provided mutable output vector is guaranteed to have at least `N` elements of capacity.
76- /// The kernel **must** append either [`BitView::true_count`] elements to the output vector (in
77- /// which case the output elements are considered to be in the "Compact" position), or it must
78- /// append `N` elements (in which case the output elements are considered to be in their "InPlace"
79- /// positions). The pipeline driver will assert these conditions after each step.
74+ /// Output vectors will always be passed with length zero.
8075///
81- /// Note that the output vector may not be empty at the start of the step. The kernel must append
82- /// its output to the existing contents of the output vector, rather than replacing it.
76+ /// Kernels may choose to output either all `N` elements in their original positions, or output
77+ /// only the selected elements to the first `true_count` positions of the output vector. When
78+ /// emitting `N` elements in-place, the kernel may omit expensive computations over the unselected
79+ /// elements, provided that the output elements in those positions are still valid (i.e. typically
80+ /// zeroed, rather than undefined).
81+ ///
82+ /// The pipeline driver will verify these conditions before and after each step.
8383pub trait Kernel : Send {
8484 /// Perform a single step of the kernel.
8585 fn step (
@@ -92,11 +92,11 @@ pub trait Kernel: Send {
9292
9393/// The context provided to kernels during execution to access input vectors.
9494pub struct KernelCtx {
95- vectors : Vec < Option < PipelineVector > > ,
95+ vectors : Vec < Option < VectorMut > > ,
9696}
9797
9898impl KernelCtx {
99- fn new ( vectors : Vec < PipelineVector > ) -> Self {
99+ fn new ( vectors : Vec < VectorMut > ) -> Self {
100100 Self {
101101 vectors : vectors. into_iter ( ) . map ( Some ) . collect ( ) ,
102102 }
@@ -112,21 +112,21 @@ impl KernelCtx {
112112 ///
113113 /// If the input vector at the given index is not available (typically because the vector
114114 /// happens to be currently borrowed as an output vector!).
115- pub fn input ( & mut self , id : VectorId ) -> & PipelineVector {
115+ pub fn input ( & mut self , id : VectorId ) -> & VectorMut {
116116 self . vectors [ id. 0 ]
117117 . as_ref ( )
118118 . vortex_expect ( "Input vector at index is not available" )
119119 }
120120
121121 #[ inline]
122- fn take_output ( & mut self , id : & VectorId ) -> PipelineVector {
122+ fn take_output ( & mut self , id : & VectorId ) -> VectorMut {
123123 self . vectors [ id. 0 ]
124124 . take ( )
125125 . vortex_expect ( "Output vector at index is not available" )
126126 }
127127
128128 #[ inline]
129- fn replace_output ( & mut self , id : & VectorId , vec : PipelineVector ) {
129+ fn replace_output ( & mut self , id : & VectorId , vec : VectorMut ) {
130130 self . vectors [ id. 0 ] = Some ( vec) ;
131131 }
132132}
@@ -140,23 +140,3 @@ impl VectorId {
140140 VectorId ( idx)
141141 }
142142}
143-
144- /// A pipeline vector passed into and out of pipeline kernels.
145- #[ derive( Debug ) ]
146- pub enum PipelineVector {
147- /// `InPlace` indicates that elements are in their original positions, where the selected
148- /// elements are identified by true values in the selection mask.
149- InPlace ( VectorMut ) ,
150- /// Compact indicates that the selected elements are compacted at the start of the vector in
151- /// positions `0..true_count`.
152- Compact ( VectorMut ) ,
153- }
154-
155- impl From < PipelineVector > for VectorMut {
156- fn from ( value : PipelineVector ) -> Self {
157- match value {
158- PipelineVector :: InPlace ( vec) => vec,
159- PipelineVector :: Compact ( vec) => vec,
160- }
161- }
162- }
0 commit comments