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
45 changes: 45 additions & 0 deletions vortex-array/src/arrays/decimal/compute/fixed_width.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_buffer::ByteBuffer;
use vortex_error::VortexResult;
use vortex_error::vortex_ensure;
use vortex_error::vortex_err;

use crate::array::ArrayView;
use crate::arrays::Decimal;
use crate::arrays::DecimalArray;
use crate::arrays::fixed_width::FixedWidthArray;
use crate::buffer::BufferHandle;
use crate::validity::Validity;

impl FixedWidthArray for Decimal {
fn byte_width(array: ArrayView<'_, Self>) -> usize {
array.values_type().byte_width()
}

fn values(array: ArrayView<'_, Self>) -> ByteBuffer {
array.buffer_handle().to_host_sync()
}

fn with_values(
array: ArrayView<'_, Self>,
values: ByteBuffer,
len: usize,
validity: Validity,
) -> VortexResult<DecimalArray> {
let expected_len = len
.checked_mul(array.values_type().byte_width())
.ok_or_else(|| vortex_err!("Decimal values buffer length overflows usize"))?;
vortex_ensure!(
values.len() == expected_len,
"Decimal values buffer length does not match output length"
);
DecimalArray::try_new_handle(
BufferHandle::new_host(values),
array.values_type(),
array.decimal_dtype(),
validity,
)
}
}
2 changes: 1 addition & 1 deletion vortex-array/src/arrays/decimal/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
mod between;
mod cast;
mod fill_null;
mod fixed_width;
mod mask;
pub mod rules;
mod take;

#[cfg(test)]
mod tests {
Expand Down
Loading
Loading