Skip to content

Commit 3eb9698

Browse files
committed
Share fixed-width compute kernels
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent acbf6f1 commit 3eb9698

25 files changed

Lines changed: 1320 additions & 1548 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex_buffer::ByteBuffer;
5+
use vortex_error::VortexResult;
6+
use vortex_error::vortex_ensure;
7+
use vortex_error::vortex_err;
8+
9+
use crate::array::ArrayView;
10+
use crate::arrays::Decimal;
11+
use crate::arrays::DecimalArray;
12+
use crate::arrays::fixed_width::FixedWidthArray;
13+
use crate::buffer::BufferHandle;
14+
use crate::validity::Validity;
15+
16+
impl FixedWidthArray for Decimal {
17+
fn byte_width(array: ArrayView<'_, Self>) -> usize {
18+
array.values_type().byte_width()
19+
}
20+
21+
fn values(array: ArrayView<'_, Self>) -> ByteBuffer {
22+
array.buffer_handle().to_host_sync()
23+
}
24+
25+
fn with_values(
26+
array: ArrayView<'_, Self>,
27+
values: ByteBuffer,
28+
len: usize,
29+
validity: Validity,
30+
) -> VortexResult<DecimalArray> {
31+
let expected_len = len
32+
.checked_mul(array.values_type().byte_width())
33+
.ok_or_else(|| vortex_err!("Decimal values buffer length overflows usize"))?;
34+
vortex_ensure!(
35+
values.len() == expected_len,
36+
"Decimal values buffer length does not match output length"
37+
);
38+
DecimalArray::try_new_handle(
39+
BufferHandle::new_host(values),
40+
array.values_type(),
41+
array.decimal_dtype(),
42+
validity,
43+
)
44+
}
45+
}

vortex-array/src/arrays/decimal/compute/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
mod between;
55
mod cast;
66
mod fill_null;
7+
mod fixed_width;
78
mod mask;
89
pub mod rules;
9-
mod take;
1010

1111
#[cfg(test)]
1212
mod tests {

0 commit comments

Comments
 (0)