Skip to content
Draft
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
7 changes: 4 additions & 3 deletions encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl VTable for ALP {
metadata: &Self::Metadata,
_buffers: &[BufferHandle],
children: &dyn ArrayChildren,
) -> VortexResult<ALPArray> {
) -> VortexResult<ArrayRef> {
let encoded_ptype = match &dtype {
DType::Primitive(PType::F32, n) => DType::Primitive(PType::I32, *n),
DType::Primitive(PType::F64, n) => DType::Primitive(PType::I64, *n),
Expand All @@ -185,14 +185,15 @@ impl VTable for ALP {
})
.transpose()?;

ALPArray::try_new(
Ok(ALPArray::try_new(
encoded,
Exponents {
e: u8::try_from(metadata.exp_e)?,
f: u8::try_from(metadata.exp_f)?,
},
patches,
)
)?
.into_array())
}

fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
Expand Down
7 changes: 4 additions & 3 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl VTable for ALPRD {
metadata: &Self::Metadata,
_buffers: &[BufferHandle],
children: &dyn ArrayChildren,
) -> VortexResult<ALPRDArray> {
) -> VortexResult<ArrayRef> {
if children.len() < 2 {
vortex_bail!(
"Expected at least 2 children for ALPRD encoding, found {}",
Expand Down Expand Up @@ -247,7 +247,7 @@ impl VTable for ALPRD {
})
.transpose()?;

ALPRDArray::try_new(
Ok(ALPRDArray::try_new(
dtype.clone(),
left_parts,
left_parts_dictionary,
Expand All @@ -259,7 +259,8 @@ impl VTable for ALPRD {
)
})?,
left_parts_patches,
)
)?
.into_array())
}

fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
Expand Down
26 changes: 13 additions & 13 deletions encodings/alp/src/alp_rd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::patches::Patches;
use vortex_array::validity::Validity;
use vortex_fastlanes::bitpack_compress::BitPackedEncoder;
use vortex_fastlanes::bitpack_compress::bitpack_encode_unchecked;

mod array;
Expand Down Expand Up @@ -230,20 +231,19 @@ impl RDEncoder {

// Bit-pack down the encoded left-parts array that have been dictionary encoded.
let primitive_left = PrimitiveArray::new(left_parts, array.validity().clone());
// SAFETY: by construction, all values in left_parts can be packed to left_bit_width.
let packed_left = unsafe {
bitpack_encode_unchecked(primitive_left, left_bit_width as _)
.vortex_expect("bitpack_encode_unchecked should succeed for left parts")
.into_array()
};

let packed_left = BitPackedEncoder::new(&primitive_left)
.with_bit_width(left_bit_width as _)
.pack()
.vortex_expect("bitpack_encode_unchecked should succeed for left parts")
.into_array()
.vortex_expect("Packed::into_array");
let primitive_right = PrimitiveArray::new(right_parts, Validity::NonNullable);
// SAFETY: by construction, all values in right_parts are right_bit_width + leading zeros.
let packed_right = unsafe {
bitpack_encode_unchecked(primitive_right, self.right_bit_width as _)
.vortex_expect("bitpack_encode_unchecked should succeed for right parts")
.into_array()
};
let packed_right = BitPackedEncoder::new(&primitive_right)
.with_bit_width(self.right_bit_width as _)
.pack()
.vortex_expect("bitpack_encode_unchecked should succeed for right parts")
.into_array()
.vortex_expect("Packed::into_array");

// Bit-pack the dict-encoded left-parts
// Bit-pack the right-parts
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 @@ -146,7 +146,7 @@ impl VTable for ByteBool {
_metadata: &Self::Metadata,
buffers: &[BufferHandle],
children: &dyn ArrayChildren,
) -> VortexResult<ByteBoolArray> {
) -> VortexResult<ArrayRef> {
let validity = if children.is_empty() {
Validity::from(dtype.nullability())
} else if children.len() == 1 {
Expand All @@ -161,7 +161,7 @@ impl VTable for ByteBool {
}
let buffer = buffers[0].clone();

Ok(ByteBoolArray::new(buffer, validity))
Ok(ByteBoolArray::new(buffer, validity).into_array())
}

fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
Expand Down
4 changes: 2 additions & 2 deletions encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl VTable for DateTimeParts {
metadata: &Self::Metadata,
_buffers: &[BufferHandle],
children: &dyn ArrayChildren,
) -> VortexResult<DateTimePartsArray> {
) -> VortexResult<ArrayRef> {
if children.len() != 3 {
vortex_bail!(
"Expected 3 children for datetime-parts encoding, found {}",
Expand All @@ -209,7 +209,7 @@ impl VTable for DateTimeParts {
len,
)?;

DateTimePartsArray::try_new(dtype.clone(), days, seconds, subseconds)
Ok(DateTimePartsArray::try_new(dtype.clone(), days, seconds, subseconds)?.into_array())
}

fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
Expand Down
4 changes: 2 additions & 2 deletions encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl VTable for DecimalByteParts {
metadata: &Self::Metadata,
_buffers: &[BufferHandle],
children: &dyn ArrayChildren,
) -> VortexResult<DecimalBytePartsArray> {
) -> VortexResult<ArrayRef> {
let Some(decimal_dtype) = dtype.as_decimal_opt() else {
vortex_bail!("decoding decimal but given non decimal dtype {}", dtype)
};
Expand All @@ -174,7 +174,7 @@ impl VTable for DecimalByteParts {
"lower_part_count > 0 not currently supported"
);

DecimalBytePartsArray::try_new(msp, *decimal_dtype)
Ok(DecimalBytePartsArray::try_new(msp, *decimal_dtype)?.into_array())
}

fn with_children(array: &mut Self::Array, children: Vec<ArrayRef>) -> VortexResult<()> {
Expand Down
18 changes: 0 additions & 18 deletions encodings/fastlanes/benches/bitpacking_take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ fn patched_take_10_stratified(bencher: Bencher) {
let uncompressed = PrimitiveArray::new(values, Validity::NonNullable);
let packed = bitpack_to_best_bit_width(&uncompressed).unwrap();

assert!(packed.patches().is_some());
assert_eq!(
packed.patches().unwrap().num_patches(),
NUM_EXCEPTIONS as usize
);

let indices = PrimitiveArray::from_iter((0..10).map(|i| i * 6_653));

bencher
Expand All @@ -186,12 +180,6 @@ fn patched_take_10_contiguous(bencher: Bencher) {
let uncompressed = PrimitiveArray::new(values, Validity::NonNullable);
let packed = bitpack_to_best_bit_width(&uncompressed).unwrap();

assert!(packed.patches().is_some());
assert_eq!(
packed.patches().unwrap().num_patches(),
NUM_EXCEPTIONS as usize
);

let indices = buffer![0..10].into_array();

bencher
Expand Down Expand Up @@ -250,12 +238,6 @@ fn patched_take_10k_contiguous_patches(bencher: Bencher) {
let uncompressed = PrimitiveArray::new(values, Validity::NonNullable);
let packed = bitpack_to_best_bit_width(&uncompressed).unwrap();

assert!(packed.patches().is_some());
assert_eq!(
packed.patches().unwrap().num_patches(),
NUM_EXCEPTIONS as usize
);

let indices =
PrimitiveArray::from_iter((BIG_BASE2..BIG_BASE2 + NUM_EXCEPTIONS).cycle().take(10000));

Expand Down
Loading
Loading