Skip to content

Commit 3188e24

Browse files
expose execution context for validity::to_bool and remove validity mask from array vtable (#7432)
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 0d143da commit 3188e24

138 files changed

Lines changed: 1643 additions & 498 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

encodings/alp/benches/alp_compress.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ fn compress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64,
6666
let values = values.freeze();
6767
let array = PrimitiveArray::new(values, validity);
6868

69-
bencher
70-
.with_inputs(|| &array)
71-
.bench_values(|array| alp_encode(array.as_view(), None).unwrap())
69+
bencher.with_inputs(|| &array).bench_values(|array| {
70+
alp_encode(
71+
array.as_view(),
72+
None,
73+
&mut LEGACY_SESSION.create_execution_ctx(),
74+
)
75+
.unwrap()
76+
})
7277
}
7378

7479
#[divan::bench(types = [f32, f64], args = BENCH_ARGS)]
@@ -95,6 +100,7 @@ fn decompress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64
95100
alp_encode(
96101
PrimitiveArray::new(Buffer::copy_from(&values), validity.clone()).as_view(),
97102
None,
103+
&mut LEGACY_SESSION.create_execution_ctx(),
98104
)
99105
.unwrap(),
100106
LEGACY_SESSION.create_execution_ctx(),

encodings/alp/public-api.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ pub fn f64::to_bits(value: Self) -> Self::UINT
636636

637637
pub fn f64::to_u16(bits: Self::UINT) -> u16
638638

639-
pub fn vortex_alp::alp_encode(parray: vortex_array::array::view::ArrayView<'_, vortex_array::arrays::primitive::vtable::Primitive>, exponents: core::option::Option<vortex_alp::Exponents>) -> vortex_error::VortexResult<vortex_alp::ALPArray>
639+
pub fn vortex_alp::alp_encode(parray: vortex_array::array::view::ArrayView<'_, vortex_array::arrays::primitive::vtable::Primitive>, exponents: core::option::Option<vortex_alp::Exponents>, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_alp::ALPArray>
640640

641641
pub fn vortex_alp::alp_rd_decode<T: vortex_alp::ALPRDFloat>(left_parts: vortex_buffer::buffer_mut::BufferMut<u16>, left_parts_dict: &[u16], right_bit_width: u8, right_parts: vortex_buffer::buffer_mut::BufferMut<<T as vortex_alp::ALPRDFloat>::UINT>, left_parts_patches: core::option::Option<vortex_array::patches::Patches>, ctx: &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_buffer::buffer::Buffer<T>>
642642

encodings/alp/src/alp/array.rs

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,11 @@ mod tests {
552552
#[case(2048)]
553553
#[case(2049)]
554554
fn test_execute_f32(#[case] size: usize) {
555+
let mut ctx = SESSION.create_execution_ctx();
555556
let values = PrimitiveArray::from_iter((0..size).map(|i| i as f32));
556-
let encoded = alp_encode(values.as_view(), None).unwrap();
557+
let encoded = alp_encode(values.as_view(), None, &mut ctx).unwrap();
557558

558559
let result_canonical = {
559-
let mut ctx = SESSION.create_execution_ctx();
560560
encoded
561561
.clone()
562562
.into_array()
@@ -582,7 +582,12 @@ mod tests {
582582
#[case(2049)]
583583
fn test_execute_f64(#[case] size: usize) {
584584
let values = PrimitiveArray::from_iter((0..size).map(|i| i as f64));
585-
let encoded = alp_encode(values.as_view(), None).unwrap();
585+
let encoded = alp_encode(
586+
values.as_view(),
587+
None,
588+
&mut LEGACY_SESSION.create_execution_ctx(),
589+
)
590+
.unwrap();
586591

587592
let result_canonical = {
588593
let mut ctx = SESSION.create_execution_ctx();
@@ -616,7 +621,12 @@ mod tests {
616621
.collect();
617622

618623
let array = PrimitiveArray::from_iter(values);
619-
let encoded = alp_encode(array.as_view(), None).unwrap();
624+
let encoded = alp_encode(
625+
array.as_view(),
626+
None,
627+
&mut LEGACY_SESSION.create_execution_ctx(),
628+
)
629+
.unwrap();
620630
assert!(encoded.patches().unwrap().array_len() > 0);
621631

622632
let result_canonical = {
@@ -650,7 +660,12 @@ mod tests {
650660
.collect();
651661

652662
let array = PrimitiveArray::from_option_iter(values);
653-
let encoded = alp_encode(array.as_view(), None).unwrap();
663+
let encoded = alp_encode(
664+
array.as_view(),
665+
None,
666+
&mut LEGACY_SESSION.create_execution_ctx(),
667+
)
668+
.unwrap();
654669

655670
let result_canonical = {
656671
let mut ctx = SESSION.create_execution_ctx();
@@ -685,7 +700,12 @@ mod tests {
685700
.collect();
686701

687702
let array = PrimitiveArray::from_option_iter(values);
688-
let encoded = alp_encode(array.as_view(), None).unwrap();
703+
let encoded = alp_encode(
704+
array.as_view(),
705+
None,
706+
&mut LEGACY_SESSION.create_execution_ctx(),
707+
)
708+
.unwrap();
689709
assert!(encoded.patches().unwrap().array_len() > 0);
690710

691711
let result_canonical = {
@@ -721,7 +741,12 @@ mod tests {
721741
.collect();
722742

723743
let array = PrimitiveArray::from_option_iter(values.clone());
724-
let encoded = alp_encode(array.as_view(), None).unwrap();
744+
let encoded = alp_encode(
745+
array.as_view(),
746+
None,
747+
&mut LEGACY_SESSION.create_execution_ctx(),
748+
)
749+
.unwrap();
725750

726751
let slice_end = size - slice_start;
727752
let slice_len = slice_end - slice_start;
@@ -772,7 +797,12 @@ mod tests {
772797
.collect();
773798

774799
let array = PrimitiveArray::from_option_iter(values.clone());
775-
let encoded = alp_encode(array.as_view(), None).unwrap();
800+
let encoded = alp_encode(
801+
array.as_view(),
802+
None,
803+
&mut LEGACY_SESSION.create_execution_ctx(),
804+
)
805+
.unwrap();
776806

777807
let slice_end = size - slice_start;
778808
let slice_len = slice_end - slice_start;
@@ -783,7 +813,16 @@ mod tests {
783813
for idx in 0..slice_len {
784814
let expected_value = values[slice_start + idx];
785815

786-
let result_valid = result_primitive.validity_mask().unwrap().value(idx);
816+
let result_valid = result_primitive
817+
.as_ref()
818+
.validity()
819+
.unwrap()
820+
.to_mask(
821+
result_primitive.as_ref().len(),
822+
&mut LEGACY_SESSION.create_execution_ctx(),
823+
)
824+
.unwrap()
825+
.value(idx);
787826
assert_eq!(
788827
result_valid,
789828
expected_value.is_some(),
@@ -813,7 +852,12 @@ mod tests {
813852
let original = PrimitiveArray::from_iter(values);
814853

815854
// First encode normally to get a properly formed ALPArray with patches.
816-
let normally_encoded = alp_encode(original.as_view(), None).unwrap();
855+
let normally_encoded = alp_encode(
856+
original.as_view(),
857+
None,
858+
&mut LEGACY_SESSION.create_execution_ctx(),
859+
)
860+
.unwrap();
817861
assert!(
818862
normally_encoded.patches().is_some(),
819863
"Test requires patches to be present"

0 commit comments

Comments
 (0)