@@ -115,21 +115,28 @@ Each child is given the opportunity to execute its parent in a fused manner via
115115` ExecuteParentKernel ` . Unlike reduce rules, parent kernels may read buffers and perform real
116116computation.
117117
118- An encoding declares its parent kernels in a ` ParentKernelSet ` , specifying which parent types
119- each kernel handles via a ` Matcher ` :
118+ An encoding declares parent kernels by implementing ` ExecuteParentKernel ` and registering them
119+ with the session-scoped kernel registry, specifying which parent types each kernel handles via a
120+ ` Matcher ` :
120121
121122``` rust
122123pub trait ExecuteParentKernel <V : VTable > {
123124 type Parent : Matcher ; // which parent types this kernel handles
124125
125126 fn execute_parent (
126127 & self ,
127- array : & V :: Array , // the child
128+ array : ArrayView <' _ , V >, // the child
128129 parent : <Self :: Parent as Matcher >:: Match <'_ >, // the matched parent
129130 child_idx : usize ,
130131 ctx : & mut ExecutionCtx ,
131132 ) -> VortexResult <Option <ArrayRef >>;
132133}
134+
135+ pub fn initialize (session : & VortexSession ) {
136+ session
137+ . kernels ()
138+ . register_execute_parent_kernel (parent_id , Child , Kernel );
139+ }
133140```
134141
135142Examples:
@@ -195,17 +202,23 @@ execute_until<M>(root):
195202 │ restore builder, │
196203 │ loop ▼
197204 │ ┌────────────────────────────────────────────┐
198- │ │ Step 2a: current_array.execute_parent( │
199- │ │ stack.top.parent_array ) │
200- │ │ child looks UP at the suspended parent │
205+ │ │ Step 2a: execute_parent_for_child( │
206+ │ │ stack.top.parent_array, │
207+ │ │ current_array ) │
208+ │ │ lookup session kernels by key: │
209+ │ │ (parent.encoding_id(), │
210+ │ │ child.encoding_id()) │
201211 │ ├────────────┬───────────────────────────────┘
202212 │ │ Some │ None
203213 │ │ │
204214 │ │ ▼
205215 │ │ ┌─────────────────────────────────────────┐
206- │ │ │ Step 2b: each child.execute_parent( │
207- │ │ │ current_array ) │
208- │ │ │ children look UP at current_array │
216+ │ │ │ Step 2b: for each child: │
217+ │ │ │ execute_parent_for_child( │
218+ │ │ │ current_array, child ) │
219+ │ │ │ lookup session kernels by key: │
220+ │ │ │ (parent.encoding_id(), │
221+ │ │ │ child.encoding_id()) │
209222 │ │ ├──────────┬──────────────────────────────┘
210223 │ │ │ Some │ None
211224 │ │ │ │
@@ -236,6 +249,9 @@ Step 2a and Step 2b are skipped while `current_builder` is active. `AppendChild`
236249consumes ` current_array ` : some slots already live in the builder, so a parent rewrite would
237250observe inconsistent state and could discard accumulated builder data.
238251
252+ Both Step 2a and Step 2b route through ` execute_parent_for_child ` , which looks up
253+ ` (parent.encoding_id(), child.encoding_id()) ` in the session kernel snapshot.
254+
239255## Incremental Execution
240256
241257Execution is incremental: each call to ` execute ` moves the array one step closer to canonical
@@ -256,12 +272,12 @@ codes through the slice, missing the Dict-RLE optimization entirely. Incremental
256272avoids this:
257273
2582741 . First iteration: the slice ` execute ` returns ` ExecuteSlot ` for its ` RunEndArray ` child.
259- Once that child is in focus, Step 2a gives it a chance to rewrite the suspended slice
260- parent before the child is forced toward canonical form.
275+ Once that child is in focus, Step 2a looks up a registered parent kernel for the
276+ ` (slice, runend) ` pair before the child is forced toward canonical form.
261277
2622782 . Second iteration: the ` RunEndArray ` codes child now matches the Dict-RLE pattern. Its
263- ` execute_parent ` provides a fused kernel that expands runs while performing dictionary
264- lookups in a single pass, returning the canonical array directly.
279+ registered execute-parent kernel expands runs while performing dictionary lookups in a single
280+ pass, returning the canonical array directly.
265281
266282## Walkthrough: Executing a RunEnd-Encoded Array
267283
0 commit comments