Skip to content

Commit 159207e

Browse files
authored
ListArray::reset_offsets doesn't need to revalidate array after reset (#8781)
Reset offsets operations if they start from a valid array they should stay valid
1 parent f47bf54 commit 159207e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

vortex-array/src/arrays/list/array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::array::child_to_validity;
2828
use crate::array::validity_to_child;
2929
use crate::arrays::ConstantArray;
3030
use crate::arrays::List;
31+
use crate::arrays::ListArray;
3132
use crate::arrays::Primitive;
3233
use crate::builtins::ArrayBuiltins;
3334
use crate::dtype::DType;
@@ -338,7 +339,6 @@ pub trait ListArrayExt: TypedArrayRef<List> {
338339
let mut elements = self.sliced_elements()?;
339340
if recurse && elements.is_canonical() {
340341
let compacted = elements
341-
.clone()
342342
.execute::<Canonical>(ctx)?
343343
.compact(ctx)?
344344
.into_array();
@@ -357,7 +357,8 @@ pub trait ListArrayExt: TypedArrayRef<List> {
357357
Operator::Sub,
358358
)?;
359359

360-
Array::<List>::try_new(elements, adjusted_offsets, self.list_validity())
360+
// SAFETY: By resetting the offsets we simply "shift" everything left and discard trailing garbage, so all invariants remain the same.
361+
Ok(unsafe { ListArray::new_unchecked(elements, adjusted_offsets, self.list_validity()) })
361362
}
362363
}
363364
impl<T: TypedArrayRef<List>> ListArrayExt for T {}

0 commit comments

Comments
 (0)