Skip to content

Commit 01318c3

Browse files
committed
ArrayData use SharedVec to hold children
1 parent d3c214e commit 01318c3

File tree

14 files changed

+18
-19
lines changed

14 files changed

+18
-19
lines changed

encodings/datetime-parts/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl DateTimePartsArray {
6161
seconds_dtype: seconds.dtype().clone(),
6262
subseconds_dtype: subsecond.dtype().clone(),
6363
},
64-
[days, seconds, subsecond].into(),
64+
vec![days, seconds, subsecond].into(),
6565
StatsSet::new(),
6666
)
6767
}

encodings/dict/src/dict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl DictArray {
3636
codes_dtype: codes.dtype().clone(),
3737
values_len: values.len(),
3838
},
39-
[values, codes].into(),
39+
vec![values, codes].into(),
4040
StatsSet::new(),
4141
)
4242
}

encodings/fastlanes/src/for/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl FoRArray {
3737
reference.dtype().clone(),
3838
child.len(),
3939
FoRMetadata { reference, shift },
40-
[child].into(),
40+
vec![child].into(),
4141
StatsSet::new(),
4242
)
4343
}

encodings/fsst/src/array.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::sync::Arc;
2-
31
use fsst::{Decompressor, Symbol};
42
use serde::{Deserialize, Serialize};
53
use vortex::array::VarBinArray;
@@ -75,7 +73,7 @@ impl FSSTArray {
7573
let len = codes.len();
7674
let strings_dtype = codes.dtype().clone();
7775
let uncompressed_lengths_dtype = uncompressed_lengths.dtype().clone();
78-
let children = Arc::new([symbols, symbol_lengths, codes, uncompressed_lengths]);
76+
let children = vec![symbols, symbol_lengths, codes, uncompressed_lengths];
7977

8078
Self::try_from_parts(
8179
dtype,
@@ -85,7 +83,7 @@ impl FSSTArray {
8583
codes_dtype: strings_dtype,
8684
uncompressed_lengths_dtype,
8785
},
88-
children,
86+
children.into(),
8987
StatsSet::new(),
9088
)
9189
}

encodings/zigzag/src/zigzag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ZigZagArray {
3333
.with_nullability(encoded_dtype.nullability());
3434

3535
let len = encoded.len();
36-
let children = [encoded];
36+
let children = vec![encoded];
3737

3838
Self::try_from_parts(dtype, len, ZigZagMetadata, children.into(), StatsSet::new())
3939
}

vortex-array/src/array/constant/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ConstantArray {
4646
scalar: scalar.clone(),
4747
length,
4848
},
49-
[].into(),
49+
vec![].into(),
5050
stats,
5151
)
5252
.unwrap_or_else(|err| {

vortex-array/src/array/extension/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl ExtensionArray {
2626
ExtensionMetadata {
2727
storage_dtype: storage.dtype().clone(),
2828
},
29-
[storage].into(),
29+
vec![storage].into(),
3030
Default::default(),
3131
)
3232
.vortex_expect("Invalid ExtensionArray")

vortex-array/src/array/null/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::sync::Arc;
2-
31
use serde::{Deserialize, Serialize};
42
use vortex_dtype::DType;
53
use vortex_error::{VortexExpect as _, VortexResult};
@@ -26,7 +24,7 @@ impl NullArray {
2624
DType::Null,
2725
len,
2826
NullMetadata { len },
29-
Arc::new([]),
27+
vec![].into(),
3028
StatsSet::nulls(len, &DType::Null),
3129
)
3230
.vortex_expect("NullArray::new should never fail!")

vortex-array/src/array/sparse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl SparseArray {
8181
len,
8282
fill_value,
8383
},
84-
[indices, values].into(),
84+
vec![indices, values].into(),
8585
StatsSet::new(),
8686
)
8787
}

vortex-array/src/data.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use vortex_dtype::DType;
55
use vortex_error::{vortex_panic, VortexResult};
66
use vortex_scalar::Scalar;
77

8+
use crate::arc_slice::SharedVec;
89
use crate::encoding::EncodingRef;
910
use crate::stats::{Stat, Statistics, StatsSet};
1011
use crate::{Array, ArrayDType, ArrayMetadata, ToArray};
@@ -16,7 +17,7 @@ pub struct ArrayData {
1617
len: usize,
1718
metadata: Arc<dyn ArrayMetadata>,
1819
buffer: Option<Buffer>,
19-
children: Arc<[Array]>,
20+
children: SharedVec<Array>,
2021
stats_map: Arc<RwLock<StatsSet>>,
2122
}
2223

@@ -27,7 +28,7 @@ impl ArrayData {
2728
len: usize,
2829
metadata: Arc<dyn ArrayMetadata>,
2930
buffer: Option<Buffer>,
30-
children: Arc<[Array]>,
31+
children: SharedVec<Array>,
3132
statistics: StatsSet,
3233
) -> VortexResult<Self> {
3334
let data = Self {

vortex-array/src/implementation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ macro_rules! impl_encoding {
6464
dtype: vortex_dtype::DType,
6565
len: usize,
6666
metadata: [<$Name Metadata>],
67-
children: std::sync::Arc<[$crate::Array]>,
67+
children: $crate::arc_slice::SharedVec<$crate::Array>,
6868
stats: $crate::stats::StatsSet,
6969
) -> VortexResult<Self> {
7070
Ok(Self { typed: $crate::TypedArray::try_from_parts(dtype, len, metadata, None, children, stats)? })

vortex-array/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::variants::ArrayVariants;
3535
use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};
3636

3737
pub mod accessor;
38-
mod arc_slice;
38+
pub mod arc_slice;
3939
pub mod array;
4040
pub mod arrow;
4141
mod canonical;

vortex-array/src/typed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use vortex_buffer::Buffer;
44
use vortex_dtype::DType;
55
use vortex_error::{vortex_bail, vortex_panic, VortexError, VortexResult};
66

7+
use crate::arc_slice::SharedVec;
78
use crate::stats::StatsSet;
89
use crate::{Array, ArrayData, ArrayDef, IntoArray, ToArray, TryDeserializeArrayMetadata};
910

@@ -19,7 +20,7 @@ impl<D: ArrayDef> TypedArray<D> {
1920
len: usize,
2021
metadata: D::Metadata,
2122
buffer: Option<Buffer>,
22-
children: Arc<[Array]>,
23+
children: SharedVec<Array>,
2324
stats: StatsSet,
2425
) -> VortexResult<Self> {
2526
let array = Array::Data(ArrayData::try_new(

vortex-dtype/src/dtype.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl StructDType {
190190
}
191191
};
192192

193+
// TODO: do this without the extra allocations.
193194
names.push(self.names[idx].clone());
194195
dtypes.push(self.dtypes[idx].clone());
195196
}

0 commit comments

Comments
 (0)