Skip to content

Commit a9ce27f

Browse files
committed
fixup
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent 9f5ca5d commit a9ce27f

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

vortex-array/src/arrays/patched/compute/compare.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use vortex_error::VortexResult;
77

88
use crate::ArrayRef;
99
use crate::Canonical;
10-
use crate::DynArray;
1110
use crate::ExecutionCtx;
1211
use crate::IntoArray;
1312
use crate::arrays::BoolArray;
@@ -43,7 +42,6 @@ impl CompareKernel for Patched {
4342
// We slice the inner before performing the comparison.
4443
let result = lhs
4544
.inner
46-
.slice(lhs.offset..lhs.offset + lhs.len)?
4745
.binary(
4846
ConstantArray::new(constant.clone(), lhs.len()).into_array(),
4947
operator.into(),
@@ -142,6 +140,9 @@ impl<V: NativePType> ApplyPatches<'_, V> {
142140
continue;
143141
}
144142
let bit_index = bit_index - self.offset;
143+
if bit_index >= self.bits.len() {
144+
break;
145+
}
145146
if cmp(patch_value, self.constant) {
146147
self.bits.set(bit_index)
147148
} else {

vortex-array/src/arrays/patched/vtable/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use crate::SerializeMetadata;
3333
use crate::arrays::PrimitiveArray;
3434
use crate::arrays::patched::PatchedArray;
3535
use crate::arrays::patched::compute::rules::PARENT_RULES;
36-
use crate::arrays::patched::patch_lanes;
3736
use crate::arrays::patched::vtable::kernels::PARENT_KERNELS;
3837
use crate::arrays::primitive::PrimitiveArrayParts;
3938
use crate::buffer::BufferHandle;
@@ -222,9 +221,7 @@ impl VTable for Patched {
222221

223222
let len = array.len();
224223

225-
// Slice the inner by its offset before appending it.
226-
let sliced_inner = array.inner.slice(array.offset..array.offset + array.len)?;
227-
sliced_inner.append_to_builder(builder, ctx)?;
224+
array.inner.append_to_builder(builder, ctx)?;
228225

229226
let offset = array.offset;
230227
let lane_offsets: Buffer<u32> =
@@ -336,10 +333,6 @@ impl VTable for Patched {
336333
let offset = array.offset;
337334
let len = array.len;
338335

339-
// Slice the buffer and validity from the offset.
340-
let buffer = buffer.slice_typed::<V>(offset..offset + len);
341-
let validity = validity.slice(offset..offset + len)?;
342-
343336
let mut output = Buffer::<V>::from_byte_buffer(buffer.unwrap_host()).into_mut();
344337

345338
apply_patches_primitive::<V>(

vortex-array/src/arrays/patched/vtable/operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl OperationsVTable<Patched> for Patched {
4747
}
4848

4949
// Otherwise, access the underlying value.
50-
array.inner.scalar_at(index + array.offset)
50+
array.inner.scalar_at(index)
5151
}
5252
}
5353

vortex-array/src/arrays/patched/vtable/slice.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ impl SliceReduce for Patched {
2424
let chunk_start = (range.start + array.offset) / 1024;
2525
let chunk_stop = (range.end + array.offset).div_ceil(1024);
2626

27-
// Slice the inner to chunk boundaries
28-
let inner_start = chunk_start * 1024;
29-
let inner_stop = (chunk_stop * 1024).min(array.inner.len());
30-
let inner = array.inner.slice(inner_start..inner_stop)?;
27+
let inner = array.inner.slice(range.start..range.end)?;
3128

3229
// Slice to only maintain offsets to the sliced chunks
3330
let sliced_lane_offsets = array
@@ -78,20 +75,19 @@ mod tests {
7875
let values = buffer![0u16; 512].into_array();
7976
let patch_indices = buffer![1u32, 8, 30].into_array();
8077
let patch_values = buffer![u16::MAX; 3].into_array();
81-
let patches = Patches::new(512, 0, patch_indices, patch_values, None).unwrap();
78+
let patches = Patches::new(512, 0, patch_indices, patch_values, None)?;
8279

8380
let mut ctx = ExecutionCtx::new(LEGACY_SESSION.clone());
8481

85-
let patched_array =
86-
PatchedArray::from_array_and_patches(values, &patches, &mut ctx).unwrap();
82+
let patched_array = PatchedArray::from_array_and_patches(values, &patches, &mut ctx)?;
8783

8884
let sliced = patched_array.slice(1..10)?;
8985

9086
insta::assert_snapshot!(
9187
sliced.display_tree_encodings_only(),
9288
@r#"
9389
root: vortex.patched(u16, len=9)
94-
inner: vortex.primitive(u16, len=512)
90+
inner: vortex.primitive(u16, len=9)
9591
patch_indices: vortex.primitive(u16, len=3)
9692
patch_values: vortex.primitive(u16, len=3)
9793
"#);

0 commit comments

Comments
 (0)