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
4 changes: 2 additions & 2 deletions encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ pub trait ALPArrayExt: ALPArraySlotsExt {
fn patches(&self) -> Option<Patches> {
PatchesData::patches_from_slots(
self.patches_data.as_ref(),
self.as_ref().len(),
self.as_ref().slots(),
self.len(),
self.slots(),
PATCH_SLOTS,
)
}
Expand Down
6 changes: 1 addition & 5 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,7 @@ pub trait ALPRDArrayExt: ALPRDArraySlotsExt {
}

fn left_parts_patches(&self) -> Option<Patches> {
patches_from_slots(
self.as_ref().slots(),
self.patches_data.as_ref(),
self.as_ref().len(),
)
patches_from_slots(self.slots(), self.patches_data.as_ref(), self.len())
}

fn left_parts_dictionary(&self) -> &Buffer<u16> {
Expand Down
4 changes: 2 additions & 2 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ pub trait ByteBoolArrayExt: TypedArrayRef<ByteBool> + ByteBoolArraySlotsExt {
/// Returns the [`Validity`] derived from the validity slot.
fn bytebool_validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[ByteBoolSlots::VALIDITY].as_ref(),
self.as_ref().dtype().nullability(),
self.slots()[ByteBoolSlots::VALIDITY].as_ref(),
self.dtype().nullability(),
)
}
}
Expand Down
13 changes: 4 additions & 9 deletions encodings/fastlanes/src/bitpacking/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,15 @@ pub trait BitPackedArrayExt: BitPackedArraySlotsExt {
fn patches(&self) -> Option<Patches> {
PatchesData::patches_from_slots(
self.patches_data.as_ref(),
self.as_ref().len(),
self.as_ref().slots(),
self.len(),
self.slots(),
PATCH_SLOTS,
)
}

#[inline]
fn validity(&self) -> Validity {
child_to_validity(self.validity_child(), self.as_ref().dtype().nullability())
child_to_validity(self.validity_child(), self.dtype().nullability())
}

#[inline]
Expand All @@ -480,12 +480,7 @@ pub trait BitPackedArrayExt: BitPackedArraySlotsExt {
&'a self,
scratch: &'a mut [MaybeUninit<T>; FL_CHUNK_SIZE],
) -> VortexResult<BitUnpackedChunks<'a, T>> {
BitPackedData::unpacked_chunks::<T>(
self,
self.as_ref().dtype(),
self.as_ref().len(),
scratch,
)
BitPackedData::unpacked_chunks::<T>(self, self.dtype(), self.len(), scratch)
}
}

Expand Down
2 changes: 1 addition & 1 deletion encodings/fastlanes/src/for_/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait FoRArrayExt: FoRArraySlotsExt {

#[inline]
fn ptype(&self) -> PType {
self.as_ref().dtype().as_ptype()
self.dtype().as_ptype()
}
}

Expand Down
7 changes: 3 additions & 4 deletions encodings/fsst/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,23 +1022,22 @@ pub trait FSSTArrayExt: FSSTArraySlotsExt {
/// from [`FSSTData`] with the offsets and validity stored in the array's slots.
fn codes(&self) -> VarBinArray {
let offsets = self.codes_offsets().clone();
let validity =
child_to_validity(self.codes_validity(), self.as_ref().dtype().nullability());
let validity = child_to_validity(self.codes_validity(), self.dtype().nullability());
let codes_bytes = self.codes_bytes_handle().clone();
// SAFETY: components were validated at construction time.
unsafe {
VarBinArray::new_unchecked_from_handle(
offsets,
codes_bytes,
DType::Binary(self.as_ref().dtype().nullability()),
DType::Binary(self.dtype().nullability()),
validity,
)
}
}

/// Get the DType of the codes array.
fn codes_dtype(&self) -> DType {
DType::Binary(self.as_ref().dtype().nullability())
DType::Binary(self.dtype().nullability())
}
}

Expand Down
4 changes: 2 additions & 2 deletions encodings/onpair/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ pub trait OnPairArrayExt: OnPairArraySlotsExt {
/// the outer dtype's nullability.
fn array_validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[OnPairSlots::VALIDITY].as_ref(),
self.as_ref().dtype().nullability(),
self.slots()[OnPairSlots::VALIDITY].as_ref(),
self.dtype().nullability(),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions encodings/parquet-variant/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ pub trait ParquetVariantArrayExt:
/// Returns the outer row validity for the Variant values.
fn parquet_variant_validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[ParquetVariantSlots::VALIDITY].as_ref(),
self.as_ref().dtype().nullability(),
self.slots()[ParquetVariantSlots::VALIDITY].as_ref(),
self.dtype().nullability(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions encodings/pco/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ pub trait PcoArrayExt: PcoArraySlotsExt {
/// Reconstruct the unsliced [`Validity`] from the validity slot.
fn unsliced_validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[PcoSlots::VALIDITY].as_ref(),
self.as_ref().dtype().nullability(),
self.slots()[PcoSlots::VALIDITY].as_ref(),
self.dtype().nullability(),
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions encodings/sparse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ impl SparseOwnedExt for Array<Sparse> {
let patches = Patches::new(
self.len(),
self.patches().offset(),
self.as_ref().slots()[SparseSlots::PATCH_INDICES]
self.slots()[SparseSlots::PATCH_INDICES]
.clone()
.vortex_expect("indices"),
self.as_ref().slots()[SparseSlots::PATCH_VALUES]
self.slots()[SparseSlots::PATCH_VALUES]
.clone()
.vortex_expect("values"),
self.as_ref().slots()[SparseSlots::PATCH_CHUNK_OFFSETS].clone(),
self.slots()[SparseSlots::PATCH_CHUNK_OFFSETS].clone(),
)?;
Ok(SparseParts {
patches,
Expand Down
8 changes: 4 additions & 4 deletions vortex-array-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn expand_array_slots(

#[doc = "Returns a borrowed view of all slots."]
fn slots_view(&self) -> #view_ident<'_> {
#view_ident::from_slots(self.as_ref().slots())
#view_ident::from_slots(self.slots())
}
}

Expand Down Expand Up @@ -661,22 +661,22 @@ impl SlotField {
#[inline]
fn #field_ident(&self) -> &::vortex_array::ArrayRef {
::vortex_error::VortexExpect::vortex_expect(
self.as_ref().slots()[#struct_ident::#const_ident].as_ref(),
self.slots()[#struct_ident::#const_ident].as_ref(),
#expect_message,
)
}
},
SlotFieldType::Optional => quote! {
#[inline]
fn #field_ident(&self) -> Option<&::vortex_array::ArrayRef> {
self.as_ref().slots()[#struct_ident::#const_ident].as_ref()
self.slots()[#struct_ident::#const_ident].as_ref()
}
},
SlotFieldType::VariadicTail => quote! {
#[inline]
fn #field_ident(&self) -> ::vortex_array::SlotSlice<'_> {
::vortex_array::SlotSlice::new(
&self.as_ref().slots()[#struct_ident::#const_ident..],
&self.slots()[#struct_ident::#const_ident..],
#expect_message,
)
}
Expand Down
24 changes: 24 additions & 0 deletions vortex-array/src/array/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ pub trait TypedArrayRef<V: VTable>: AsRef<ArrayRef> + Deref<Target = V::TypedArr
fn to_owned(&self) -> Array<V> {
self.as_ref().clone().downcast()
}

/// Returns the child slots of the array.
fn slots(&self) -> &[Option<ArrayRef>] {
self.as_ref().slots()
}

/// Returns the logical [`DType`] of the array.
fn dtype(&self) -> &DType {
self.as_ref().dtype()
}

/// Returns the number of rows in the array.
fn len(&self) -> usize {
self.as_ref().len()
}

/// Returns `true` if the array has no rows.
fn is_empty(&self) -> bool {
self.as_ref().is_empty()
}
}

impl<V: VTable> TypedArrayRef<V> for Array<V> {}
Expand Down Expand Up @@ -281,16 +301,19 @@ impl<V: VTable> Array<V> {
}

/// Returns the logical dtype.
#[allow(clippy::same_name_method)]
pub fn dtype(&self) -> &DType {
self.inner.dtype()
}

/// Returns the length.
#[allow(clippy::same_name_method)]
pub fn len(&self) -> usize {
self.inner.len()
}

/// Returns whether this array is empty.
#[allow(clippy::same_name_method)]
pub fn is_empty(&self) -> bool {
self.inner.len() == 0
}
Expand Down Expand Up @@ -352,6 +375,7 @@ impl<V: VTable> Array<V> {
}

/// Returns the array slots.
#[allow(clippy::same_name_method)]
pub fn slots(&self) -> &[Option<ArrayRef>] {
self.inner.slots()
}
Expand Down
4 changes: 4 additions & 0 deletions vortex-array/src/array/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@ impl<'a, V: VTable> ArrayView<'a, V> {
}

/// Returns this array's child slots.
#[allow(clippy::same_name_method)]
pub fn slots(&self) -> &'a [Option<ArrayRef>] {
self.array.slots()
}

/// Returns the logical dtype.
#[allow(clippy::same_name_method)]
pub fn dtype(&self) -> &DType {
self.array.dtype()
}

/// Returns the number of rows.
#[allow(clippy::same_name_method)]
pub fn len(&self) -> usize {
self.array.len()
}

/// Returns `true` when the array has no rows.
#[allow(clippy::same_name_method)]
pub fn is_empty(&self) -> bool {
self.array.len() == 0
}
Expand Down
8 changes: 4 additions & 4 deletions vortex-array/src/arrays/bool/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ pub struct BoolDataParts {

pub trait BoolArrayExt: TypedArrayRef<Bool> {
fn nullability(&self) -> crate::dtype::Nullability {
match self.as_ref().dtype() {
match self.dtype() {
DType::Bool(nullability) => *nullability,
_ => unreachable!("BoolArrayExt requires a bool dtype"),
}
}

fn validity(&self) -> Validity {
child_to_validity(
self.as_ref().slots()[BoolSlots::VALIDITY].as_ref(),
self.slots()[BoolSlots::VALIDITY].as_ref(),
self.nullability(),
)
}
Expand Down Expand Up @@ -130,11 +130,11 @@ pub trait BoolArrayExt: TypedArrayRef<Bool> {

fn to_mask_fill_null_false(&self, ctx: &mut ExecutionCtx) -> Mask {
let validity_mask = BoolArrayExt::validity(self)
.execute_mask(self.as_ref().len(), ctx)
.execute_mask(self.len(), ctx)
.vortex_expect("Failed to compute validity mask");
let buffer = match validity_mask {
Mask::AllTrue(_) => self.to_bit_buffer(),
Mask::AllFalse(_) => return Mask::new_false(self.as_ref().len()),
Mask::AllFalse(_) => return Mask::new_false(self.len()),
Mask::Values(validity) => validity.bit_buffer() & self.to_bit_buffer(),
};
Mask::from_buffer(buffer)
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/arrays/bool/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl BoolArray {
pub fn opt_bool_vec(&self, ctx: &mut ExecutionCtx) -> Vec<Option<bool>> {
self.validity()
.vortex_expect("failed to get validity")
.execute_mask(self.as_ref().len(), ctx)
.execute_mask(self.len(), ctx)
.vortex_expect("Failed to compute validity mask")
.to_bit_buffer()
.iter()
Expand All @@ -24,7 +24,7 @@ impl BoolArray {
pub fn bool_vec(&self, ctx: &mut ExecutionCtx) -> Vec<bool> {
self.validity()
.vortex_expect("failed to get validity")
.execute_mask(self.as_ref().len(), ctx)
.execute_mask(self.len(), ctx)
.vortex_expect("Failed to compute validity mask")
.to_bit_buffer()
.iter()
Expand Down
18 changes: 7 additions & 11 deletions vortex-array/src/arrays/chunked/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,25 @@ impl Display for ChunkedData {

pub trait ChunkedArrayExt: TypedArrayRef<Chunked> {
fn chunk_offsets_array(&self) -> &ArrayRef {
self.as_ref().slots()[ChunkedSlots::CHUNK_OFFSETS]
self.slots()[ChunkedSlots::CHUNK_OFFSETS]
.as_ref()
.vortex_expect("validated chunk offsets slot")
}

fn nchunks(&self) -> usize {
self.as_ref()
.slots()
self.slots()
.len()
.saturating_sub(ChunkedSlots::CHUNKS_OFFSET)
}

fn chunk(&self, idx: usize) -> &ArrayRef {
self.as_ref().slots()[ChunkedSlots::CHUNKS_OFFSET + idx]
self.slots()[ChunkedSlots::CHUNKS_OFFSET + idx]
.as_ref()
.vortex_expect("validated chunk slot")
}

fn iter_chunks(&self) -> impl Iterator<Item = &ArrayRef> {
self.as_ref().slots()[ChunkedSlots::CHUNKS_OFFSET..]
self.slots()[ChunkedSlots::CHUNKS_OFFSET..]
.iter()
.map(|slot| slot.as_ref().vortex_expect("validated chunk slot"))
}
Expand All @@ -99,10 +98,7 @@ pub trait ChunkedArrayExt: TypedArrayRef<Chunked> {
}

fn find_chunk_idx(&self, index: usize) -> VortexResult<(usize, usize)> {
assert!(
index <= self.as_ref().len(),
"Index out of bounds of the array"
);
assert!(index <= self.len(), "Index out of bounds of the array");
let chunk_offset_values = self.chunk_offset_values();
let index_chunk = chunk_offset_values
.search_sorted(&index, SearchSortedSide::Right)?
Expand All @@ -115,14 +111,14 @@ pub trait ChunkedArrayExt: TypedArrayRef<Chunked> {

fn array_iterator(&self) -> impl ArrayIterator + '_ {
ArrayIteratorAdapter::new(
self.as_ref().dtype().clone(),
self.dtype().clone(),
self.iter_chunks().map(|chunk| Ok(chunk.clone())),
)
}

fn array_stream(&self) -> impl ArrayStream + '_ {
ArrayStreamAdapter::new(
self.as_ref().dtype().clone(),
self.dtype().clone(),
stream::iter(self.iter_chunks().map(|chunk| Ok(chunk.clone()))),
)
}
Expand Down
4 changes: 2 additions & 2 deletions vortex-array/src/arrays/chunked/paired_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ pub(crate) struct PairedChunks {
pub(crate) trait PairedChunksExt: ChunkedArrayExt {
fn paired_chunks<T: ChunkedArrayExt>(&self, other: &T) -> PairedChunks {
assert_eq!(
self.as_ref().len(),
self.len(),
other.as_ref().len(),
"paired_chunks requires arrays of equal length"
);
PairedChunks {
left: ChunkCursor::new(self.chunks()),
right: ChunkCursor::new(other.chunks()),
pos: 0,
total_len: self.as_ref().len(),
total_len: self.len(),
}
}
}
Expand Down
Loading
Loading