Skip to content
Open
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
32 changes: 18 additions & 14 deletions encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::fmt::Debug;
use std::hash::Hash;

use vortex_array::ArrayCommon;
use vortex_array::ArrayEq;
use vortex_array::ArrayHash;
use vortex_array::ArrayRef;
Expand All @@ -20,7 +21,6 @@ use vortex_array::dtype::PType;
use vortex_array::patches::Patches;
use vortex_array::patches::PatchesMetadata;
use vortex_array::serde::ArrayChildren;
use vortex_array::stats::ArrayStats;
use vortex_array::stats::StatsSetRef;
use vortex_array::vtable;
use vortex_array::vtable::ArrayId;
Expand Down Expand Up @@ -58,26 +58,26 @@ impl VTable for ALPVTable {
}

fn len(array: &ALPArray) -> usize {
array.encoded.len()
array.common.len()
}

fn dtype(array: &ALPArray) -> &DType {
&array.dtype
array.common.dtype()
}

fn stats(array: &ALPArray) -> StatsSetRef<'_> {
array.stats_set.to_ref(array.as_ref())
array.common.stats().to_ref(array.as_ref())
}

fn array_hash<H: std::hash::Hasher>(array: &ALPArray, state: &mut H, precision: Precision) {
array.dtype.hash(state);
array.common.dtype().hash(state);
array.encoded.array_hash(state, precision);
array.exponents.hash(state);
array.patches.array_hash(state, precision);
}

fn array_eq(array: &ALPArray, other: &ALPArray, precision: Precision) -> bool {
array.dtype == other.dtype
array.common.dtype() == other.common.dtype()
&& array.encoded.array_eq(&other.encoded, precision)
&& array.exponents == other.exponents
&& array.patches.array_eq(&other.patches, precision)
Expand Down Expand Up @@ -261,9 +261,8 @@ impl VTable for ALPVTable {
pub struct ALPArray {
encoded: ArrayRef,
patches: Option<Patches>,
dtype: DType,
common: ArrayCommon,
exponents: Exponents,
stats_set: ArrayStats,
}

#[derive(Debug)]
Expand Down Expand Up @@ -428,12 +427,12 @@ impl ALPArray {
_ => unreachable!(),
};

let len = encoded.len();
Ok(Self {
dtype,
common: ArrayCommon::new(len, dtype),
encoded,
exponents,
patches,
stats_set: Default::default(),
})
}

Expand All @@ -447,17 +446,17 @@ impl ALPArray {
patches: Option<Patches>,
dtype: DType,
) -> Self {
let len = encoded.len();
Self {
dtype,
common: ArrayCommon::new(len, dtype),
encoded,
exponents,
patches,
stats_set: Default::default(),
}
}

pub fn ptype(&self) -> PType {
self.dtype.as_ptype()
self.common.dtype().as_ptype()
}

pub fn encoded(&self) -> &ArrayRef {
Expand All @@ -476,7 +475,12 @@ impl ALPArray {
/// Consumes the array and returns its parts.
#[inline]
pub fn into_parts(self) -> (ArrayRef, Exponents, Option<Patches>, DType) {
(self.encoded, self.exponents, self.patches, self.dtype)
(
self.encoded,
self.exponents,
self.patches,
self.common.into_dtype(),
)
}
}

Expand Down
25 changes: 12 additions & 13 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fmt::Debug;
use std::hash::Hash;

use itertools::Itertools;
use vortex_array::ArrayCommon;
use vortex_array::ArrayEq;
use vortex_array::ArrayHash;
use vortex_array::ArrayRef;
Expand All @@ -23,7 +24,6 @@ use vortex_array::dtype::PType;
use vortex_array::patches::Patches;
use vortex_array::patches::PatchesMetadata;
use vortex_array::serde::ArrayChildren;
use vortex_array::stats::ArrayStats;
use vortex_array::stats::StatsSetRef;
use vortex_array::validity::Validity;
use vortex_array::vtable;
Expand Down Expand Up @@ -75,19 +75,19 @@ impl VTable for ALPRDVTable {
}

fn len(array: &ALPRDArray) -> usize {
array.left_parts.len()
array.common.len()
}

fn dtype(array: &ALPRDArray) -> &DType {
&array.dtype
array.common.dtype()
}

fn stats(array: &ALPRDArray) -> StatsSetRef<'_> {
array.stats_set.to_ref(array.as_ref())
array.common.stats().to_ref(array.as_ref())
}

fn array_hash<H: std::hash::Hasher>(array: &ALPRDArray, state: &mut H, precision: Precision) {
array.dtype.hash(state);
array.common.dtype().hash(state);
array.left_parts.array_hash(state, precision);
array.left_parts_dictionary.array_hash(state, precision);
array.right_parts.array_hash(state, precision);
Expand All @@ -96,7 +96,7 @@ impl VTable for ALPRDVTable {
}

fn array_eq(array: &ALPRDArray, other: &ALPRDArray, precision: Precision) -> bool {
array.dtype == other.dtype
array.common.dtype() == other.common.dtype()
&& array.left_parts.array_eq(&other.left_parts, precision)
&& array
.left_parts_dictionary
Expand Down Expand Up @@ -357,13 +357,12 @@ impl VTable for ALPRDVTable {

#[derive(Clone, Debug)]
pub struct ALPRDArray {
dtype: DType,
common: ArrayCommon,
left_parts: ArrayRef,
left_parts_patches: Option<Patches>,
left_parts_dictionary: Buffer<u16>,
right_parts: ArrayRef,
right_bit_width: u8,
stats_set: ArrayStats,
}

#[derive(Debug)]
Expand Down Expand Up @@ -428,14 +427,14 @@ impl ALPRDArray {
})
.transpose()?;

let len = left_parts.len();
Ok(Self {
dtype,
common: ArrayCommon::new(len, dtype),
left_parts,
left_parts_dictionary,
right_parts,
right_bit_width,
left_parts_patches,
stats_set: Default::default(),
})
}

Expand All @@ -449,14 +448,14 @@ impl ALPRDArray {
right_bit_width: u8,
left_parts_patches: Option<Patches>,
) -> Self {
let len = left_parts.len();
Self {
dtype,
common: ArrayCommon::new(len, dtype),
left_parts,
left_parts_patches,
left_parts_dictionary,
right_parts,
right_bit_width,
stats_set: Default::default(),
}
}

Expand All @@ -465,7 +464,7 @@ impl ALPRDArray {
/// Returns false if the logical type of the array values is f64.
#[inline]
pub fn is_f32(&self) -> bool {
matches!(&self.dtype, DType::Primitive(PType::F32, _))
matches!(self.common.dtype(), DType::Primitive(PType::F32, _))
}

/// The leftmost (most significant) bits of the floating point values stored in the array.
Expand Down
20 changes: 9 additions & 11 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::fmt::Debug;
use std::hash::Hash;

use vortex_array::ArrayCommon;
use vortex_array::ArrayEq;
use vortex_array::ArrayHash;
use vortex_array::ArrayRef;
Expand All @@ -16,7 +17,6 @@ use vortex_array::buffer::BufferHandle;
use vortex_array::dtype::DType;
use vortex_array::scalar::Scalar;
use vortex_array::serde::ArrayChildren;
use vortex_array::stats::ArrayStats;
use vortex_array::stats::StatsSetRef;
use vortex_array::validity::Validity;
use vortex_array::vtable;
Expand Down Expand Up @@ -52,29 +52,29 @@ impl VTable for ByteBoolVTable {
}

fn len(array: &ByteBoolArray) -> usize {
array.buffer.len()
array.common.len()
}

fn dtype(array: &ByteBoolArray) -> &DType {
&array.dtype
array.common.dtype()
}

fn stats(array: &ByteBoolArray) -> StatsSetRef<'_> {
array.stats_set.to_ref(array.as_ref())
array.common.stats().to_ref(array.as_ref())
}

fn array_hash<H: std::hash::Hasher>(
array: &ByteBoolArray,
state: &mut H,
precision: Precision,
) {
array.dtype.hash(state);
array.common.dtype().hash(state);
array.buffer.array_hash(state, precision);
array.validity.array_hash(state, precision);
}

fn array_eq(array: &ByteBoolArray, other: &ByteBoolArray, precision: Precision) -> bool {
array.dtype == other.dtype
array.common.dtype() == other.common.dtype()
&& array.buffer.array_eq(&other.buffer, precision)
&& array.validity.array_eq(&other.validity, precision)
}
Expand Down Expand Up @@ -166,7 +166,7 @@ impl VTable for ByteBoolVTable {
);

array.validity = if children.is_empty() {
Validity::from(array.dtype.nullability())
Validity::from(array.common.dtype().nullability())
} else {
Validity::Array(children.into_iter().next().vortex_expect("checked"))
};
Expand Down Expand Up @@ -200,10 +200,9 @@ impl VTable for ByteBoolVTable {

#[derive(Clone, Debug)]
pub struct ByteBoolArray {
dtype: DType,
common: ArrayCommon,
buffer: BufferHandle,
validity: Validity,
stats_set: ArrayStats,
}

#[derive(Debug)]
Expand All @@ -226,10 +225,9 @@ impl ByteBoolArray {
);
}
Self {
dtype: DType::Bool(validity.nullability()),
common: ArrayCommon::new(length, DType::Bool(validity.nullability())),
buffer,
validity,
stats_set: Default::default(),
}
}

Expand Down
Loading
Loading