Skip to content

Commit

Permalink
ArrayData use SharedVec to hold children
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Sep 23, 2024
1 parent d3c214e commit 01318c3
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl DateTimePartsArray {
seconds_dtype: seconds.dtype().clone(),
subseconds_dtype: subsecond.dtype().clone(),
},
[days, seconds, subsecond].into(),
vec![days, seconds, subsecond].into(),
StatsSet::new(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion encodings/dict/src/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl DictArray {
codes_dtype: codes.dtype().clone(),
values_len: values.len(),
},
[values, codes].into(),
vec![values, codes].into(),
StatsSet::new(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/for/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FoRArray {
reference.dtype().clone(),
child.len(),
FoRMetadata { reference, shift },
[child].into(),
vec![child].into(),
StatsSet::new(),
)
}
Expand Down
6 changes: 2 additions & 4 deletions encodings/fsst/src/array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::Arc;

use fsst::{Decompressor, Symbol};
use serde::{Deserialize, Serialize};
use vortex::array::VarBinArray;
Expand Down Expand Up @@ -75,7 +73,7 @@ impl FSSTArray {
let len = codes.len();
let strings_dtype = codes.dtype().clone();
let uncompressed_lengths_dtype = uncompressed_lengths.dtype().clone();
let children = Arc::new([symbols, symbol_lengths, codes, uncompressed_lengths]);
let children = vec![symbols, symbol_lengths, codes, uncompressed_lengths];

Self::try_from_parts(
dtype,
Expand All @@ -85,7 +83,7 @@ impl FSSTArray {
codes_dtype: strings_dtype,
uncompressed_lengths_dtype,
},
children,
children.into(),
StatsSet::new(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion encodings/zigzag/src/zigzag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl ZigZagArray {
.with_nullability(encoded_dtype.nullability());

let len = encoded.len();
let children = [encoded];
let children = vec![encoded];

Self::try_from_parts(dtype, len, ZigZagMetadata, children.into(), StatsSet::new())
}
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/constant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl ConstantArray {
scalar: scalar.clone(),
length,
},
[].into(),
vec![].into(),
stats,
)
.unwrap_or_else(|err| {
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl ExtensionArray {
ExtensionMetadata {
storage_dtype: storage.dtype().clone(),
},
[storage].into(),
vec![storage].into(),
Default::default(),
)
.vortex_expect("Invalid ExtensionArray")
Expand Down
4 changes: 1 addition & 3 deletions vortex-array/src/array/null/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::Arc;

use serde::{Deserialize, Serialize};
use vortex_dtype::DType;
use vortex_error::{VortexExpect as _, VortexResult};
Expand All @@ -26,7 +24,7 @@ impl NullArray {
DType::Null,
len,
NullMetadata { len },
Arc::new([]),
vec![].into(),
StatsSet::nulls(len, &DType::Null),
)
.vortex_expect("NullArray::new should never fail!")
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/array/sparse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl SparseArray {
len,
fill_value,
},
[indices, values].into(),
vec![indices, values].into(),
StatsSet::new(),
)
}
Expand Down
5 changes: 3 additions & 2 deletions vortex-array/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use vortex_dtype::DType;
use vortex_error::{vortex_panic, VortexResult};
use vortex_scalar::Scalar;

use crate::arc_slice::SharedVec;
use crate::encoding::EncodingRef;
use crate::stats::{Stat, Statistics, StatsSet};
use crate::{Array, ArrayDType, ArrayMetadata, ToArray};
Expand All @@ -16,7 +17,7 @@ pub struct ArrayData {
len: usize,
metadata: Arc<dyn ArrayMetadata>,
buffer: Option<Buffer>,
children: Arc<[Array]>,
children: SharedVec<Array>,
stats_map: Arc<RwLock<StatsSet>>,
}

Expand All @@ -27,7 +28,7 @@ impl ArrayData {
len: usize,
metadata: Arc<dyn ArrayMetadata>,
buffer: Option<Buffer>,
children: Arc<[Array]>,
children: SharedVec<Array>,
statistics: StatsSet,
) -> VortexResult<Self> {
let data = Self {
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ macro_rules! impl_encoding {
dtype: vortex_dtype::DType,
len: usize,
metadata: [<$Name Metadata>],
children: std::sync::Arc<[$crate::Array]>,
children: $crate::arc_slice::SharedVec<$crate::Array>,
stats: $crate::stats::StatsSet,
) -> VortexResult<Self> {
Ok(Self { typed: $crate::TypedArray::try_from_parts(dtype, len, metadata, None, children, stats)? })
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::variants::ArrayVariants;
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};

pub mod accessor;
mod arc_slice;
pub mod arc_slice;
pub mod array;
pub mod arrow;
mod canonical;
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_error::{vortex_bail, vortex_panic, VortexError, VortexResult};

use crate::arc_slice::SharedVec;
use crate::stats::StatsSet;
use crate::{Array, ArrayData, ArrayDef, IntoArray, ToArray, TryDeserializeArrayMetadata};

Expand All @@ -19,7 +20,7 @@ impl<D: ArrayDef> TypedArray<D> {
len: usize,
metadata: D::Metadata,
buffer: Option<Buffer>,
children: Arc<[Array]>,
children: SharedVec<Array>,
stats: StatsSet,
) -> VortexResult<Self> {
let array = Array::Data(ArrayData::try_new(
Expand Down
1 change: 1 addition & 0 deletions vortex-dtype/src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl StructDType {
}
};

// TODO: do this without the extra allocations.
names.push(self.names[idx].clone());
dtypes.push(self.dtypes[idx].clone());
}
Expand Down

0 comments on commit 01318c3

Please sign in to comment.