@@ -23,6 +23,7 @@ use vortex_error::VortexResult;
2323use vortex_error:: vortex_bail;
2424use vortex_error:: vortex_ensure;
2525use vortex_error:: vortex_panic;
26+ use vortex_session:: Ref ;
2627use vortex_session:: SessionExt ;
2728use vortex_session:: VortexSession ;
2829
@@ -421,14 +422,15 @@ impl Executable for ArrayRef {
421422 }
422423 }
423424
424- let kernels = ctx
425- . session ( )
426- . get_opt :: < ArrayKernels > ( )
427- . map ( |v| v. map ( |i| i. clone ( ) ) ) ;
425+ let tmp_session = ctx. session ( ) . clone ( ) ;
426+ let kernels = tmp_session. get_opt :: < ArrayKernels > ( ) ;
427+
428428
429429 for ( slot_idx, slot) in array. slots ( ) . iter ( ) . enumerate ( ) {
430430 let Some ( child) = slot else { continue } ;
431- if let Some ( executed_parent) = execute_parent_for_child ( & array, child, slot_idx, kernels, ctx) ? {
431+ if let Some ( executed_parent) =
432+ execute_parent_for_child ( & array, child, slot_idx, kernels. as_ref ( ) , ctx) ?
433+ {
432434 ctx. log ( format_args ! (
433435 "execute_parent: slot[{}]({}) rewrote {} -> {}" ,
434436 slot_idx,
@@ -539,13 +541,10 @@ fn execute_parent_for_child(
539541 parent : & ArrayRef ,
540542 child : & ArrayRef ,
541543 slot_idx : usize ,
542- kernels : Option < & ArrayKernels > ,
544+ kernels : Option < & Ref < ArrayKernels > > ,
543545 ctx : & mut ExecutionCtx ,
544546) -> VortexResult < Option < ArrayRef > > {
545- if let Some ( kernels) = ctx
546- . session ( )
547- . get_opt :: < ArrayKernels > ( )
548- . map ( |v| v. deref ( ) . clone ( ) )
547+ if let Some ( kernels) = kernels
549548 && let Some ( plugins) =
550549 kernels. find_execute_parent ( parent. encoding_id ( ) , child. encoding_id ( ) )
551550 {
@@ -561,11 +560,25 @@ fn execute_parent_for_child(
561560
562561/// Try execute_parent on each occupied slot of the array.
563562fn try_execute_parent ( array : & ArrayRef , ctx : & mut ExecutionCtx ) -> VortexResult < Option < ArrayRef > > {
563+ let tmp_session = ctx. session ( ) . clone ( ) ;
564+ let kernels = tmp_session. get_opt :: < ArrayKernels > ( ) ;
565+
564566 for ( slot_idx, slot) in array. slots ( ) . iter ( ) . enumerate ( ) {
565567 let Some ( child) = slot else { continue } ;
566- if let Some ( result) = execute_parent_for_child ( array, child, slot_idx, ctx) ? {
567- result. statistics ( ) . inherit_from ( array. statistics ( ) ) ;
568- return Ok ( Some ( result) ) ;
568+ if let Some ( executed_parent) =
569+ execute_parent_for_child ( & array, child, slot_idx, kernels. as_ref ( ) , ctx) ?
570+ {
571+ ctx. log ( format_args ! (
572+ "execute_parent: slot[{}]({}) rewrote {} -> {}" ,
573+ slot_idx,
574+ child. encoding_id( ) ,
575+ array,
576+ executed_parent
577+ ) ) ;
578+ executed_parent
579+ . statistics ( )
580+ . inherit_from ( array. statistics ( ) ) ;
581+ return Ok ( Some ( executed_parent) ) ;
569582 }
570583 }
571584 Ok ( None )
0 commit comments