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