Skip to main content

vortex_array/arrays/varbin/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4mod array;
5pub use array::VarBinArray;
6
7pub(crate) mod compute;
8pub(crate) use compute::varbin_compute_min_max;
9
10mod vtable;
11pub use vtable::VarBinVTable;
12
13pub mod builder;
14
15mod accessor;
16
17use vortex_buffer::ByteBuffer;
18use vortex_dtype::DType;
19use vortex_error::VortexExpect;
20use vortex_error::vortex_err;
21
22use crate::scalar::Scalar;
23
24pub fn varbin_scalar(value: ByteBuffer, dtype: &DType) -> Scalar {
25    if matches!(dtype, DType::Utf8(_)) {
26        Scalar::try_utf8(value, dtype.nullability())
27            .map_err(|err| vortex_err!("Failed to create scalar from utf8 buffer: {}", err))
28            .vortex_expect("UTF-8 scalar creation should succeed")
29    } else {
30        Scalar::binary(value, dtype.nullability())
31    }
32}
33
34#[cfg(test)]
35mod tests;