Skip to content

Commit 8be56d6

Browse files
committed
fix[vortex-array]: don't chunk elements in ListViewArray.naive_rebuild
Signed-off-by: Alfonso Subiotto Marques <[email protected]>
1 parent 4968607 commit 8be56d6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

vortex-array/src/arrays/listview/rebuild.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use vortex_dtype::{IntegerPType, Nullability, match_each_integer_ptype};
77
use vortex_error::VortexExpect;
88
use vortex_scalar::Scalar;
99

10-
use crate::arrays::{ChunkedArray, ListViewArray};
10+
use crate::arrays::ListViewArray;
11+
use crate::builders::builder_with_capacity;
1112
use crate::vtable::ValidityHelper;
1213
use crate::{Array, IntoArray, ToCanonical, compute};
1314

@@ -138,15 +139,17 @@ impl ListViewArray {
138139
let offsets = offsets.into_array();
139140
let sizes = sizes.into_array();
140141

141-
// SAFETY: all chunks were sliced from the same array so have same DType.
142-
let elements =
143-
unsafe { ChunkedArray::new_unchecked(chunks, element_dtype.as_ref().clone()) };
142+
let mut builder = builder_with_capacity(element_dtype.as_ref(), n_elements.as_());
143+
for chunk in &chunks {
144+
chunk.append_to_builder(builder.as_mut());
145+
}
146+
let elements = builder.finish_into_canonical();
144147

145148
// SAFETY: elements are contiguous, offsets and sizes hand-built to be zero copy
146149
// to list.
147150
unsafe {
148151
ListViewArray::new_unchecked(
149-
elements.to_canonical().into_array(),
152+
elements.into_array(),
150153
offsets,
151154
sizes,
152155
self.validity.clone(),

0 commit comments

Comments
 (0)