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;
8
9mod vtable;
10pub use vtable::VarBin;
11
12pub mod builder;
13
14mod accessor;
15
16use vortex_buffer::ByteBuffer;
17use vortex_error::VortexExpect;
18use vortex_error::vortex_err;
19
20use crate::dtype::DType;
21use crate::scalar::Scalar;
22
23pub fn varbin_scalar(value: ByteBuffer, dtype: &DType) -> Scalar {
24    if matches!(dtype, DType::Utf8(_)) {
25        Scalar::try_utf8(value, dtype.nullability())
26            .map_err(|err| vortex_err!("Failed to create scalar from utf8 buffer: {}", err))
27            .vortex_expect("UTF-8 scalar creation should succeed")
28    } else {
29        Scalar::binary(value, dtype.nullability())
30    }
31}
32
33#[cfg(test)]
34mod tests;