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