44//! Verifies ownership of RowFn output allocations independently of input decoding.
55
66use std:: mem:: MaybeUninit ;
7+ use std:: ops:: BitOrAssign ;
78
89use rstest:: rstest;
910use vortex_buffer:: BufferAllocatorRef ;
@@ -42,6 +43,7 @@ use crate::dtype::DType;
4243use crate :: memory:: MemorySessionExt ;
4344use crate :: memory:: test_allocator:: tracking_allocator;
4445use crate :: scalar_fn:: VecExecutionArgs ;
46+ use crate :: scalar_fn:: unstable:: row:: FailureEvidence ;
4547use crate :: scalar_fn:: unstable:: row:: FixedSizeListSink ;
4648use crate :: scalar_fn:: unstable:: row:: InitializedElement ;
4749use crate :: scalar_fn:: unstable:: row:: OutputBuffer ;
@@ -61,7 +63,7 @@ enum Traversal {
6163 Filtered ,
6264}
6365
64- fn collect_owned < Out : OutputElement > (
66+ fn collect_owned < Out : OutputElement , Fail : FailureEvidence > (
6567 traversal : Traversal ,
6668 args : & VecExecutionArgs ,
6769 valid : & MaskValuesRef ,
@@ -75,19 +77,19 @@ fn collect_owned<Out: OutputElement>(
7577 |_| ( ) ,
7678 |_, ( value, ) | apply ( value) ,
7779 ) ,
78- Traversal :: Fallible => execute_owned :: < ( i64 , ) , Out , ( ) , bool > (
80+ Traversal :: Fallible => execute_owned :: < ( i64 , ) , Out , ( ) , Fail > (
7981 args,
8082 ctx,
8183 |_| ( ) ,
82- |_, ( value, ) | ( apply ( value) , false ) ,
84+ |_, ( value, ) | ( apply ( value) , Fail :: default ( ) ) ,
8385 |_| Ok ( ( ) ) ,
8486 ) ,
8587 Traversal :: DenseAttempt => {
86- match execute_owned_dense_attempt :: < ( i64 , ) , Out , ( ) , bool > (
88+ match execute_owned_dense_attempt :: < ( i64 , ) , Out , ( ) , Fail > (
8789 args,
8890 ctx,
8991 |_| ( ) ,
90- |_, ( value, ) | ( apply ( value) , false ) ,
92+ |_, ( value, ) | ( apply ( value) , Fail :: default ( ) ) ,
9193 |_| Ok ( ( ) ) ,
9294 ) ? {
9395 DenseAttempt :: Values ( values) => Ok ( values) ,
@@ -156,9 +158,9 @@ fn owned_payload_uses_context_allocator(
156158 . with_allocator ( allocator) ;
157159
158160 let output = if boolean {
159- collect_owned ( traversal, & args, & valid, & mut ctx, |value| value % 2 == 0 ) ?
161+ collect_owned :: < _ , bool > ( traversal, & args, & valid, & mut ctx, |value| value % 2 == 0 ) ?
160162 } else {
161- collect_owned ( traversal, & args, & valid, & mut ctx, |value| value) ?
163+ collect_owned :: < _ , bool > ( traversal, & args, & valid, & mut ctx, |value| value) ?
162164 } ;
163165 if boolean {
164166 tracker. assert_owns ( output. as_ :: < Bool > ( ) . to_bit_buffer ( ) . inner ( ) . as_slice ( ) ) ;
@@ -406,6 +408,14 @@ fn fixed_size_list_payload_uses_allocator() -> VortexResult<()> {
406408 Ok ( ( ) )
407409}
408410
411+ // Zero-sized outputs require failure evidence that is also zero-sized.
412+ #[ derive( Clone , Copy , Default ) ]
413+ struct NoFailure ;
414+
415+ impl BitOrAssign for NoFailure {
416+ fn bitor_assign ( & mut self , _rhs : Self ) { }
417+ }
418+
409419/// A zero-sized element whose collection storage does not depend on Vortex buffers.
410420#[ derive( Clone , Copy , Default ) ]
411421struct One ;
@@ -450,7 +460,7 @@ fn zero_sized_output_uses_its_own_storage(#[case] traversal: Traversal) -> Vorte
450460 . create_execution_ctx ( )
451461 . with_allocator ( allocator) ;
452462
453- let output = collect_owned :: < One > ( traversal, & args, & valid, & mut ctx, |_| One ) ?;
463+ let output = collect_owned :: < One , NoFailure > ( traversal, & args, & valid, & mut ctx, |_| One ) ?;
454464 assert_arrays_eq ! ( & output, & expected, & mut ctx) ;
455465 tracker. assert_owns ( output. as_ :: < Primitive > ( ) . as_slice :: < i64 > ( ) ) ;
456466
0 commit comments