Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions vortex-array/src/arrays/struct_/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use std::borrow::Borrow;
use std::iter::once;
use std::sync::Arc;

use itertools::Itertools;
use vortex_error::VortexExpect;
Expand Down Expand Up @@ -159,7 +158,7 @@ pub(super) const FIELDS_OFFSET: usize = 1;
/// ```
pub struct StructDataParts {
pub struct_fields: StructFields,
pub fields: Arc<[ArrayRef]>,
pub fields: Vec<ArrayRef>,
pub validity: Validity,
}

Expand Down Expand Up @@ -198,7 +197,7 @@ pub trait StructArrayExt: TypedArrayRef<Struct> {
.map(|s| s.as_ref().vortex_expect("StructArray field slot"))
}

fn unmasked_fields(&self) -> Arc<[ArrayRef]> {
fn unmasked_fields(&self) -> Vec<ArrayRef> {
self.iter_unmasked_fields().cloned().collect()
}

Expand Down Expand Up @@ -235,7 +234,7 @@ impl Array<Struct> {
/// Creates a new `StructArray`.
pub fn new(
names: FieldNames,
fields: impl Into<Arc<[ArrayRef]>>,
fields: impl IntoIterator<Item = ArrayRef>,
length: usize,
validity: Validity,
) -> Self {
Expand All @@ -246,11 +245,11 @@ impl Array<Struct> {
/// Constructs a new `StructArray`.
pub fn try_new(
names: FieldNames,
fields: impl Into<Arc<[ArrayRef]>>,
fields: impl IntoIterator<Item = ArrayRef>,
length: usize,
validity: Validity,
) -> VortexResult<Self> {
let fields = fields.into();
let fields: Vec<_> = fields.into_iter().collect();
let field_dtypes: Vec<_> = fields.iter().map(|d| d.dtype().clone()).collect();
let dtype = StructFields::new(names, field_dtypes);
let slots = make_struct_slots(&fields, &validity, length);
Expand All @@ -271,12 +270,12 @@ impl Array<Struct> {
///
/// Caller must ensure the field arrays match the supplied dtype, length, and validity.
pub unsafe fn new_unchecked(
fields: impl Into<Arc<[ArrayRef]>>,
fields: impl IntoIterator<Item = ArrayRef>,
dtype: StructFields,
length: usize,
validity: Validity,
) -> Self {
let fields = fields.into();
let fields: Vec<_> = fields.into_iter().collect();
let outer_dtype = DType::Struct(dtype, validity.nullability());
let slots = make_struct_slots(&fields, &validity, length);
unsafe {
Expand All @@ -288,12 +287,12 @@ impl Array<Struct> {

/// Constructs a new `StructArray` with an explicit dtype.
pub fn try_new_with_dtype(
fields: impl Into<Arc<[ArrayRef]>>,
fields: impl IntoIterator<Item = ArrayRef>,
dtype: StructFields,
length: usize,
validity: Validity,
) -> VortexResult<Self> {
let fields = fields.into();
let fields: Vec<_> = fields.into_iter().collect();
let outer_dtype = DType::Struct(dtype, validity.nullability());
let slots = make_struct_slots(&fields, &validity, length);
Array::try_from_parts(
Expand Down Expand Up @@ -393,7 +392,7 @@ impl Array<Struct> {

// TODO(ngates): remove this... it doesn't help to consume self.
pub fn into_data_parts(self) -> StructDataParts {
let fields: Arc<[ArrayRef]> = self.slots()[FIELDS_OFFSET..]
let fields: Vec<ArrayRef> = self.slots()[FIELDS_OFFSET..]
.iter()
.map(|s| s.as_ref().vortex_expect("StructArray field slot").clone())
.collect();
Expand Down Expand Up @@ -448,7 +447,7 @@ impl Array<Struct> {
let types = struct_dtype.fields().chain(once(array.dtype().clone()));
let new_fields = StructFields::new(names.collect(), types.collect());

let children: Arc<[ArrayRef]> = self.slots()[FIELDS_OFFSET..]
let children: Vec<ArrayRef> = self.slots()[FIELDS_OFFSET..]
.iter()
.map(|s| s.as_ref().vortex_expect("StructArray field slot").clone())
.chain(once(array))
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/arrays/struct_/compute/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::validity::Validity;
impl MaskReduce for Struct {
fn mask(array: ArrayView<'_, Struct>, mask: &ArrayRef) -> VortexResult<Option<ArrayRef>> {
StructArray::try_new_with_dtype(
array.unmasked_fields().iter().cloned().collect::<Vec<_>>(),
array.unmasked_fields(),
array.struct_fields().clone(),
array.len(),
array.validity()?.and(Validity::Array(mask.clone()))?,
Expand Down
8 changes: 4 additions & 4 deletions vortex-array/src/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Canonical {
struct_dtype
.fields()
.map(|f| Canonical::empty(&f).into_array())
.collect::<Arc<[_]>>(),
.collect::<Vec<_>>(),
struct_dtype.clone(),
0,
Validity::from(n),
Expand Down Expand Up @@ -854,9 +854,9 @@ impl Executable for RecursiveCanonical {
validity,
} = st.into_data_parts();
let executed_fields = fields
.iter()
.map(|f| Ok(f.clone().execute::<RecursiveCanonical>(ctx)?.0.into_array()))
.collect::<VortexResult<Arc<[_]>>>()?;
.into_iter()
.map(|f| Ok(f.execute::<RecursiveCanonical>(ctx)?.0.into_array()))
.collect::<VortexResult<Vec<_>>>()?;

Ok(RecursiveCanonical(Canonical::Struct(unsafe {
StructArray::new_unchecked(
Expand Down
4 changes: 1 addition & 3 deletions vortex-duckdb/src/convert/vector.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use std::sync::Arc;

use num_traits::AsPrimitive;
use vortex::array::ArrayRef;
use vortex::array::IntoArray;
Expand Down Expand Up @@ -377,7 +375,7 @@ pub fn data_chunk_to_vortex(
vector.flatten(len);
flat_vector_to_vortex(vector, len.as_())
})
.collect::<VortexResult<Arc<_>>>()?;
.collect::<VortexResult<Vec<_>>>()?;
StructArray::try_new(
field_names.clone(),
columns,
Expand Down
Loading