Skip to content

Commit 197266d

Browse files
committed
Merge remote-tracking branch 'origin/develop' into ji/vector-eq
# Conflicts: # vortex-vector/src/binaryview/types.rs # vortex-vector/src/listview/scalar.rs # vortex-vector/src/struct_/scalar.rs
2 parents 27bf707 + 346b1f6 commit 197266d

File tree

217 files changed

+6959
-6015
lines changed

Some content is hidden

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

217 files changed

+6959
-6015
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

encodings/alp/src/alp/array.rs

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use vortex_array::DeserializeMetadata;
1515
use vortex_array::Precision;
1616
use vortex_array::ProstMetadata;
1717
use vortex_array::SerializeMetadata;
18-
use vortex_array::execution::ExecutionCtx;
18+
use vortex_array::kernel::BindCtx;
19+
use vortex_array::kernel::KernelRef;
20+
use vortex_array::kernel::kernel;
1921
use vortex_array::patches::Patches;
2022
use vortex_array::patches::PatchesMetadata;
2123
use vortex_array::serde::ArrayChildren;
@@ -41,7 +43,7 @@ use vortex_error::VortexExpect;
4143
use vortex_error::VortexResult;
4244
use vortex_error::vortex_bail;
4345
use vortex_error::vortex_ensure;
44-
use vortex_vector::Vector;
46+
use vortex_error::vortex_err;
4547

4648
use crate::ALPFloat;
4749
use crate::alp::Exponents;
@@ -140,17 +142,61 @@ impl VTable for ALPVTable {
140142
)
141143
}
142144

143-
fn batch_execute(array: &ALPArray, ctx: &mut ExecutionCtx) -> VortexResult<Vector> {
144-
let encoded_vector = array.encoded().batch_execute(ctx)?;
145+
fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
146+
// Children: encoded, patches (if present): indices, values, chunk_offsets (optional)
147+
let patches_info = array
148+
.patches
149+
.as_ref()
150+
.map(|p| (p.array_len(), p.offset(), p.chunk_offsets().is_some()));
151+
152+
let expected_children = match &patches_info {
153+
Some((_, _, has_chunk_offsets)) => 1 + 2 + if *has_chunk_offsets { 1 } else { 0 },
154+
None => 1,
155+
};
156+
157+
vortex_ensure!(
158+
children.len() == expected_children,
159+
"ALPArray expects {} children, got {}",
160+
expected_children,
161+
children.len()
162+
);
163+
164+
let mut children_iter = children.into_iter();
165+
array.encoded = children_iter
166+
.next()
167+
.ok_or_else(|| vortex_err!("Expected encoded child"))?;
168+
169+
if let Some((array_len, offset, _has_chunk_offsets)) = patches_info {
170+
let indices = children_iter
171+
.next()
172+
.ok_or_else(|| vortex_err!("Expected patch indices child"))?;
173+
let values = children_iter
174+
.next()
175+
.ok_or_else(|| vortex_err!("Expected patch values child"))?;
176+
let chunk_offsets = children_iter.next();
177+
178+
array.patches = Some(Patches::new(
179+
array_len,
180+
offset,
181+
indices,
182+
values,
183+
chunk_offsets,
184+
));
185+
}
186+
187+
Ok(())
188+
}
145189

146-
let patches_vectors = if let Some(patches) = array.patches() {
190+
fn bind_kernel(array: &ALPArray, ctx: &mut BindCtx) -> VortexResult<KernelRef> {
191+
let encoded = array.encoded().bind_kernel(ctx)?;
192+
let patches_kernels = if let Some(patches) = array.patches() {
147193
Some((
148-
patches.indices().batch_execute(ctx)?,
149-
patches.values().batch_execute(ctx)?,
194+
patches.indices().bind_kernel(ctx)?,
195+
patches.values().bind_kernel(ctx)?,
150196
patches
151197
.chunk_offsets()
152198
.as_ref()
153-
.map(|co| co.batch_execute(ctx))
199+
.map(|co| co.bind_kernel(ctx))
154200
.transpose()?,
155201
))
156202
} else {
@@ -161,7 +207,24 @@ impl VTable for ALPVTable {
161207
let exponents = array.exponents();
162208

163209
match_each_alp_float_ptype!(array.dtype().as_ptype(), |T| {
164-
decompress_into_vector::<T>(encoded_vector, exponents, patches_vectors, patches_offset)
210+
Ok(kernel(move || {
211+
let encoded_vector = encoded.execute()?;
212+
let patches_vectors = match patches_kernels {
213+
Some((idx_kernel, val_kernel, co_kernel)) => Some((
214+
idx_kernel.execute()?,
215+
val_kernel.execute()?,
216+
co_kernel.map(|k| k.execute()).transpose()?,
217+
)),
218+
None => None,
219+
};
220+
221+
decompress_into_vector::<T>(
222+
encoded_vector,
223+
exponents,
224+
patches_vectors,
225+
patches_offset,
226+
)
227+
}))
165228
})
166229
}
167230
}
@@ -456,15 +519,18 @@ mod tests {
456519
use std::sync::LazyLock;
457520

458521
use rstest::rstest;
522+
use vortex_array::VectorExecutor;
459523
use vortex_array::arrays::PrimitiveArray;
524+
use vortex_array::session::ArraySession;
460525
use vortex_array::vtable::ValidityHelper;
461526
use vortex_dtype::PTypeDowncast;
462527
use vortex_session::VortexSession;
463528
use vortex_vector::VectorOps;
464529

465530
use super::*;
466531

467-
static SESSION: LazyLock<VortexSession> = LazyLock::new(VortexSession::empty);
532+
static SESSION: LazyLock<VortexSession> =
533+
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());
468534

469535
#[rstest]
470536
#[case(0)]
@@ -480,7 +546,7 @@ mod tests {
480546
let values = PrimitiveArray::from_iter((0..size).map(|i| i as f32));
481547
let encoded = alp_encode(&values, None).unwrap();
482548

483-
let result_vector = encoded.to_array().execute(&SESSION).unwrap();
549+
let result_vector = encoded.to_array().execute_vector(&SESSION).unwrap();
484550
// Compare against the traditional array-based decompress path
485551
let expected = decompress_into_array(encoded);
486552

@@ -504,7 +570,7 @@ mod tests {
504570
let values = PrimitiveArray::from_iter((0..size).map(|i| i as f64));
505571
let encoded = alp_encode(&values, None).unwrap();
506572

507-
let result_vector = encoded.to_array().execute(&SESSION).unwrap();
573+
let result_vector = encoded.to_array().execute_vector(&SESSION).unwrap();
508574
// Compare against the traditional array-based decompress path
509575
let expected = decompress_into_array(encoded);
510576

@@ -534,7 +600,7 @@ mod tests {
534600
let encoded = alp_encode(&array, None).unwrap();
535601
assert!(encoded.patches().unwrap().array_len() > 0);
536602

537-
let result_vector = encoded.to_array().execute(&SESSION).unwrap();
603+
let result_vector = encoded.to_array().execute_vector(&SESSION).unwrap();
538604
// Compare against the traditional array-based decompress path
539605
let expected = decompress_into_array(encoded);
540606

@@ -562,7 +628,7 @@ mod tests {
562628
let array = PrimitiveArray::from_option_iter(values);
563629
let encoded = alp_encode(&array, None).unwrap();
564630

565-
let result_vector = encoded.to_array().execute(&SESSION).unwrap();
631+
let result_vector = encoded.to_array().execute_vector(&SESSION).unwrap();
566632
// Compare against the traditional array-based decompress path
567633
let expected = decompress_into_array(encoded);
568634

@@ -601,7 +667,7 @@ mod tests {
601667
let encoded = alp_encode(&array, None).unwrap();
602668
assert!(encoded.patches().unwrap().array_len() > 0);
603669

604-
let result_vector = encoded.to_array().execute(&SESSION).unwrap();
670+
let result_vector = encoded.to_array().execute_vector(&SESSION).unwrap();
605671
// Compare against the traditional array-based decompress path
606672
let expected = decompress_into_array(encoded);
607673

@@ -643,7 +709,7 @@ mod tests {
643709
let slice_len = slice_end - slice_start;
644710
let sliced_encoded = encoded.slice(slice_start..slice_end);
645711

646-
let result_vector = sliced_encoded.execute(&SESSION).unwrap();
712+
let result_vector = sliced_encoded.execute_vector_optimized(&SESSION).unwrap();
647713
let result_primitive = result_vector.into_primitive().into_f64();
648714

649715
for idx in 0..slice_len {

encodings/alp/src/alp_rd/array.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use vortex_error::VortexError;
4545
use vortex_error::VortexExpect;
4646
use vortex_error::VortexResult;
4747
use vortex_error::vortex_bail;
48+
use vortex_error::vortex_ensure;
4849
use vortex_error::vortex_err;
4950

5051
use crate::alp_rd::alp_rd_decode;
@@ -185,6 +186,47 @@ impl VTable for ALPRDVTable {
185186
left_parts_patches,
186187
)
187188
}
189+
190+
fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
191+
// Children: left_parts, right_parts, patches (if present): indices, values
192+
let patches_info = array
193+
.left_parts_patches
194+
.as_ref()
195+
.map(|p| (p.array_len(), p.offset()));
196+
197+
let expected_children = if patches_info.is_some() { 4 } else { 2 };
198+
199+
vortex_ensure!(
200+
children.len() == expected_children,
201+
"ALPRDArray expects {} children, got {}",
202+
expected_children,
203+
children.len()
204+
);
205+
206+
let mut children_iter = children.into_iter();
207+
array.left_parts = children_iter
208+
.next()
209+
.ok_or_else(|| vortex_err!("Expected left_parts child"))?;
210+
array.right_parts = children_iter
211+
.next()
212+
.ok_or_else(|| vortex_err!("Expected right_parts child"))?;
213+
214+
if let Some((array_len, offset)) = patches_info {
215+
let indices = children_iter
216+
.next()
217+
.ok_or_else(|| vortex_err!("Expected patch indices child"))?;
218+
let values = children_iter
219+
.next()
220+
.ok_or_else(|| vortex_err!("Expected patch values child"))?;
221+
222+
array.left_parts_patches = Some(Patches::new(
223+
array_len, offset, indices, values,
224+
None, // chunk_offsets not currently supported for ALPRD
225+
));
226+
}
227+
228+
Ok(())
229+
}
188230
}
189231

190232
#[derive(Clone, Debug)]

encodings/bytebool/src/array.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ use vortex_buffer::BitBuffer;
3535
use vortex_buffer::BufferHandle;
3636
use vortex_buffer::ByteBuffer;
3737
use vortex_dtype::DType;
38+
use vortex_error::VortexExpect;
3839
use vortex_error::VortexResult;
3940
use vortex_error::vortex_bail;
41+
use vortex_error::vortex_ensure;
4042
use vortex_error::vortex_panic;
4143
use vortex_scalar::Scalar;
4244

@@ -99,6 +101,22 @@ impl VTable for ByteBoolVTable {
99101

100102
Ok(ByteBoolArray::new(buffer, validity))
101103
}
104+
105+
fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
106+
vortex_ensure!(
107+
children.len() <= 1,
108+
"ByteBoolArray expects at most 1 child (validity), got {}",
109+
children.len()
110+
);
111+
112+
array.validity = if children.is_empty() {
113+
Validity::from(array.dtype.nullability())
114+
} else {
115+
Validity::Array(children.into_iter().next().vortex_expect("checked"))
116+
};
117+
118+
Ok(())
119+
}
102120
}
103121

104122
#[derive(Clone, Debug)]

encodings/datetime-parts/src/array.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ use vortex_buffer::BufferHandle;
3434
use vortex_dtype::DType;
3535
use vortex_dtype::Nullability;
3636
use vortex_dtype::PType;
37+
use vortex_error::VortexExpect;
3738
use vortex_error::VortexResult;
3839
use vortex_error::vortex_bail;
40+
use vortex_error::vortex_ensure;
3941
use vortex_error::vortex_err;
4042

4143
vtable!(DateTimeParts);
@@ -142,6 +144,21 @@ impl VTable for DateTimePartsVTable {
142144

143145
DateTimePartsArray::try_new(dtype.clone(), days, seconds, subseconds)
144146
}
147+
148+
fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
149+
vortex_ensure!(
150+
children.len() == 3,
151+
"DateTimePartsArray expects exactly 3 children (days, seconds, subseconds), got {}",
152+
children.len()
153+
);
154+
155+
let mut children_iter = children.into_iter();
156+
array.days = children_iter.next().vortex_expect("checked");
157+
array.seconds = children_iter.next().vortex_expect("checked");
158+
array.subseconds = children_iter.next().vortex_expect("checked");
159+
160+
Ok(())
161+
}
145162
}
146163

147164
#[derive(Clone, Debug)]

encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use vortex_dtype::match_each_signed_integer_ptype;
4444
use vortex_error::VortexExpect;
4545
use vortex_error::VortexResult;
4646
use vortex_error::vortex_bail;
47+
use vortex_error::vortex_ensure;
4748
use vortex_scalar::DecimalValue;
4849
use vortex_scalar::Scalar;
4950

@@ -116,6 +117,16 @@ impl VTable for DecimalBytePartsVTable {
116117

117118
DecimalBytePartsArray::try_new(msp, *decimal_dtype)
118119
}
120+
121+
fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
122+
vortex_ensure!(
123+
children.len() == 1,
124+
"DecimalBytePartsArray expects exactly 1 child (msp), got {}",
125+
children.len()
126+
);
127+
array.msp = children.into_iter().next().vortex_expect("checked");
128+
Ok(())
129+
}
119130
}
120131

121132
/// This array encodes decimals as between 1-4 columns of primitive typed children.

encodings/fastlanes/src/bitpacking/array/bitpack_decompress.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ mod tests {
204204
use std::sync::LazyLock;
205205

206206
use vortex_array::IntoArray;
207+
use vortex_array::VectorExecutor;
207208
use vortex_array::assert_arrays_eq;
208209
use vortex_array::validity::Validity;
209210
use vortex_buffer::Buffer;
@@ -536,7 +537,7 @@ mod tests {
536537
let unpacked_array = unpack_array(&bitpacked);
537538

538539
// Method 3: Using the execute() method (this is what would be used in production).
539-
let executed = bitpacked.into_array().execute(&SESSION).unwrap();
540+
let executed = bitpacked.into_array().execute_vector(&SESSION).unwrap();
540541

541542
// All three should produce the same length.
542543
assert_eq!(vector_result.len(), array.len(), "vector length mismatch");
@@ -556,7 +557,10 @@ mod tests {
556557

557558
// Verify that the execute() method works correctly by comparing with unpack_array.
558559
// We convert unpack_array result to a vector using execute() to compare.
559-
let unpacked_executed = unpacked_array.into_array().execute(&SESSION).unwrap();
560+
let unpacked_executed = unpacked_array
561+
.into_array()
562+
.execute_vector(&SESSION)
563+
.unwrap();
560564
match (&executed, &unpacked_executed) {
561565
(Vector::Primitive(exec_pv), Vector::Primitive(unpack_pv)) => {
562566
assert_eq!(
@@ -593,7 +597,7 @@ mod tests {
593597
let sliced_bp = sliced.as_::<BitPackedVTable>();
594598
let vector_result = unpack_to_primitive_vector(sliced_bp);
595599
let unpacked_array = unpack_array(sliced_bp);
596-
let executed = sliced.execute(&SESSION).unwrap();
600+
let executed = sliced.execute_vector(&SESSION).unwrap();
597601

598602
assert_eq!(
599603
vector_result.len(),

0 commit comments

Comments
 (0)