From 047e4fcd3ed73141b4b9012e061411ffb36a7d3a Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Fri, 17 Jul 2026 12:00:37 +0100 Subject: [PATCH 1/2] inital work Signed-off-by: Adam Gutglick --- encodings/sparse/src/canonical.rs | 1 + fuzz/src/array/compare.rs | 6 +- fuzz/src/array/filter.rs | 6 +- fuzz/src/array/mod.rs | 1 + fuzz/src/array/search_sorted.rs | 6 +- fuzz/src/array/slice.rs | 6 +- fuzz/src/array/sort.rs | 6 +- fuzz/src/array/take.rs | 6 +- .../src/aggregate_fn/fns/is_sorted/mod.rs | 2 + .../fns/uncompressed_size_in_bytes/mod.rs | 4 + vortex-array/src/arrays/arbitrary.rs | 1 + .../src/arrays/constant/vtable/canonical.rs | 1 + vortex-array/src/arrays/map/array.rs | 27 + vortex-array/src/arrays/map/compute/cast.rs | 4 + vortex-array/src/arrays/map/compute/filter.rs | 4 + vortex-array/src/arrays/map/compute/mask.rs | 4 + vortex-array/src/arrays/map/compute/mod.rs | 11 + vortex-array/src/arrays/map/compute/rules.rs | 4 + vortex-array/src/arrays/map/compute/slice.rs | 4 + vortex-array/src/arrays/map/compute/take.rs | 4 + vortex-array/src/arrays/map/mod.rs | 18 + vortex-array/src/arrays/map/vtable/mod.rs | 11 + .../src/arrays/map/vtable/operations.rs | 4 + .../src/arrays/map/vtable/validity.rs | 4 + vortex-array/src/arrays/mod.rs | 4 + vortex-array/src/builders/mod.rs | 3 + vortex-array/src/builders/tests.rs | 3 + vortex-array/src/canonical.rs | 3 + .../src/compute/conformance/consistency.rs | 1 + vortex-array/src/dtype/arbitrary/mod.rs | 9 +- vortex-array/src/dtype/coercion.rs | 67 ++ vortex-array/src/dtype/dtype_impl.rs | 50 +- vortex-array/src/dtype/map.rs | 201 ++++ vortex-array/src/dtype/mod.rs | 10 + vortex-array/src/dtype/serde/flatbuffers.rs | 64 ++ vortex-array/src/dtype/serde/mod.rs | 27 + vortex-array/src/dtype/serde/proto.rs | 52 + vortex-array/src/dtype/serde/serde.rs | 65 ++ vortex-array/src/scalar/arbitrary.rs | 17 + vortex-array/src/scalar/cast.rs | 1 + vortex-array/src/scalar/constructor.rs | 54 + .../src/scalar/convert/from_scalar.rs | 11 + vortex-array/src/scalar/display.rs | 1 + vortex-array/src/scalar/downcast.rs | 16 + vortex-array/src/scalar/proto.rs | 73 +- vortex-array/src/scalar/scalar_impl.rs | 8 + vortex-array/src/scalar/scalar_value.rs | 4 +- vortex-array/src/scalar/typed_view/map.rs | 334 ++++++ vortex-array/src/scalar/typed_view/mod.rs | 2 + vortex-array/src/scalar/validate.rs | 31 + .../src/scalar_fn/fns/binary/compare/mod.rs | 2 +- .../scalar_fn/fns/binary/compare/nested.rs | 2 +- vortex-arrow/src/convert.rs | 3 + vortex-arrow/src/dtype.rs | 128 +++ vortex-arrow/src/executor/mod.rs | 2 +- vortex-arrow/src/scalar.rs | 126 +++ vortex-arrow/src/session.rs | 73 ++ vortex-datafusion/src/convert/scalars.rs | 3 + vortex-datafusion/src/convert/schema.rs | 107 ++ vortex-duckdb/src/convert/dtype.rs | 39 +- vortex-duckdb/src/convert/scalar.rs | 1 + vortex-duckdb/src/duckdb/logical_type.rs | 12 + vortex-ffi/cinclude/vortex.h | 21 + vortex-ffi/src/dtype.rs | 79 ++ .../flatbuffers/vortex-dtype/dtype.fbs | 8 + vortex-flatbuffers/src/generated/array.rs | 434 ++++---- vortex-flatbuffers/src/generated/dtype.rs | 974 +++++++++++------- vortex-flatbuffers/src/generated/footer.rs | 664 ++++++------ vortex-flatbuffers/src/generated/layout.rs | 129 +-- vortex-flatbuffers/src/generated/message.rs | 288 +++--- vortex-proto/proto/dtype.proto | 8 + vortex-proto/src/generated/vortex.dtype.rs | 18 +- vortex-python/python/vortex/__init__.py | 6 + vortex-python/python/vortex/_lib/dtype.pyi | 4 + vortex-python/python/vortex/_lib/scalar.pyi | 8 + vortex-python/src/dtype/factory.rs | 31 + vortex-python/src/dtype/map.rs | 10 + vortex-python/src/dtype/mod.rs | 5 + vortex-python/src/python_repr.rs | 8 + vortex-python/src/scalar/factory.rs | 50 +- vortex-python/src/scalar/into_py.rs | 49 + vortex-python/src/scalar/map.rs | 43 + vortex-python/src/scalar/mod.rs | 4 + vortex-python/test/test_dtype.py | 9 + vortex-python/test/test_scalar.py | 24 + vortex-row/src/codec.rs | 4 +- 86 files changed, 3476 insertions(+), 1156 deletions(-) create mode 100644 vortex-array/src/arrays/map/array.rs create mode 100644 vortex-array/src/arrays/map/compute/cast.rs create mode 100644 vortex-array/src/arrays/map/compute/filter.rs create mode 100644 vortex-array/src/arrays/map/compute/mask.rs create mode 100644 vortex-array/src/arrays/map/compute/mod.rs create mode 100644 vortex-array/src/arrays/map/compute/rules.rs create mode 100644 vortex-array/src/arrays/map/compute/slice.rs create mode 100644 vortex-array/src/arrays/map/compute/take.rs create mode 100644 vortex-array/src/arrays/map/mod.rs create mode 100644 vortex-array/src/arrays/map/vtable/mod.rs create mode 100644 vortex-array/src/arrays/map/vtable/operations.rs create mode 100644 vortex-array/src/arrays/map/vtable/validity.rs create mode 100644 vortex-array/src/dtype/map.rs create mode 100644 vortex-array/src/scalar/typed_view/map.rs create mode 100644 vortex-python/src/dtype/map.rs create mode 100644 vortex-python/src/scalar/map.rs diff --git a/encodings/sparse/src/canonical.rs b/encodings/sparse/src/canonical.rs index 0be6d0a4162..034107cadff 100644 --- a/encodings/sparse/src/canonical.rs +++ b/encodings/sparse/src/canonical.rs @@ -151,6 +151,7 @@ pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> Vort DType::FixedSizeList(.., nullability) => { execute_sparse_fixed_size_list(&patches, &fill_value, len, *nullability, ctx)? } + DType::Map(..) => vortex_bail!("Sparse canonicalization does not support Map arrays yet"), DType::Struct(struct_fields, ..) => execute_sparse_struct( struct_fields, fill_value.as_struct(), diff --git a/fuzz/src/array/compare.rs b/fuzz/src/array/compare.rs index f594a9b4102..03ce50a7170 100644 --- a/fuzz/src/array/compare.rs +++ b/fuzz/src/array/compare.rs @@ -186,7 +186,11 @@ pub fn compare_canonical_array( })) .into_array() } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/fuzz/src/array/filter.rs b/fuzz/src/array/filter.rs index aa54b0d9488..746479aa46c 100644 --- a/fuzz/src/array/filter.rs +++ b/fuzz/src/array/filter.rs @@ -121,7 +121,11 @@ pub fn filter_canonical_array( ) .map(|a| a.into_array()) } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/fuzz/src/array/mod.rs b/fuzz/src/array/mod.rs index b6402cb1e1d..9bb6e12f66b 100644 --- a/fuzz/src/array/mod.rs +++ b/fuzz/src/array/mod.rs @@ -518,6 +518,7 @@ fn actions_for_dtype(dtype: &DType) -> HashSet { acc.intersection(&actions).copied().collect() }) } + DType::Map(..) => HashSet::new(), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), // Currently, no support at all DType::Variant(_) => unreachable!("Variant dtype shouldn't be fuzzed"), diff --git a/fuzz/src/array/search_sorted.rs b/fuzz/src/array/search_sorted.rs index 762182b35fb..6eb0d63e93a 100644 --- a/fuzz/src/array/search_sorted.rs +++ b/fuzz/src/array/search_sorted.rs @@ -149,7 +149,11 @@ pub fn search_sorted_canonical_array( .collect::>>()?; scalar_vals.search_sorted(&scalar.cast(array.dtype())?, side) } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/fuzz/src/array/slice.rs b/fuzz/src/array/slice.rs index 2a151002805..bda68486ee5 100644 --- a/fuzz/src/array/slice.rs +++ b/fuzz/src/array/slice.rs @@ -124,7 +124,11 @@ pub fn slice_canonical_array( ) .map(|a| a.into_array()) } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/fuzz/src/array/sort.rs b/fuzz/src/array/sort.rs index 3f00fccd06e..b0af8638898 100644 --- a/fuzz/src/array/sort.rs +++ b/fuzz/src/array/sort.rs @@ -102,7 +102,11 @@ pub fn sort_canonical_array(array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexR }); take_canonical_array_non_nullable_indices(array, &sort_indices, ctx) } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/fuzz/src/array/take.rs b/fuzz/src/array/take.rs index c67ae6184d8..8e59bc085db 100644 --- a/fuzz/src/array/take.rs +++ b/fuzz/src/array/take.rs @@ -148,7 +148,11 @@ pub fn take_canonical_array( ) .map(|a| a.into_array()) } - d @ (DType::Null | DType::Union(..) | DType::Variant(_) | DType::Extension(_)) => { + d @ (DType::Null + | DType::Map(..) + | DType::Union(..) + | DType::Variant(_) + | DType::Extension(_)) => { unreachable!("DType {d} not supported for fuzzing") } } diff --git a/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs b/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs index ada9e6eb2e5..99a7b99128a 100644 --- a/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs @@ -246,6 +246,7 @@ impl AggregateFnVTable for IsSorted { DType::Null | DType::List(..) | DType::FixedSizeList(..) + | DType::Map(..) | DType::Struct(..) | DType::Union(..) | DType::Variant(..) @@ -263,6 +264,7 @@ impl AggregateFnVTable for IsSorted { DType::Null | DType::List(..) | DType::FixedSizeList(..) + | DType::Map(..) | DType::Struct(..) | DType::Union(..) | DType::Variant(..) diff --git a/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs b/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs index 6b2feb380a7..752cf952a5e 100644 --- a/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs @@ -233,6 +233,9 @@ pub(crate) fn constant_uncompressed_size_in_bytes( let canonical = array.array().clone().execute::(ctx)?; return canonical_uncompressed_size_in_bytes(&canonical, ctx); } + DType::Map(..) => { + vortex_bail!("UncompressedSizeInBytes is not supported for map arrays yet") + } DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => { vortex_bail!("UncompressedSizeInBytes is not supported for Variant arrays") @@ -286,6 +289,7 @@ fn supports_uncompressed_size_in_bytes(dtype: &DType) -> bool { DType::List(element_dtype, _) | DType::FixedSizeList(element_dtype, ..) => { supports_uncompressed_size_in_bytes(element_dtype) } + DType::Map(..) => false, DType::Struct(fields, _) => fields .fields() .all(|field| supports_uncompressed_size_in_bytes(&field)), diff --git a/vortex-array/src/arrays/arbitrary.rs b/vortex-array/src/arrays/arbitrary.rs index 5d5d9f60bf9..8d5edc77045 100644 --- a/vortex-array/src/arrays/arbitrary.rs +++ b/vortex-array/src/arrays/arbitrary.rs @@ -157,6 +157,7 @@ fn random_array_chunk( DType::FixedSizeList(elem_dtype, list_size, null) => { random_fixed_size_list(u, elem_dtype, *list_size, *null, chunk_len) } + DType::Map(..) => Err(IncorrectFormat), DType::Struct(sdt, n) => { let first_array = sdt .fields() diff --git a/vortex-array/src/arrays/constant/vtable/canonical.rs b/vortex-array/src/arrays/constant/vtable/canonical.rs index e160bcc16a9..1f15a7e9f3b 100644 --- a/vortex-array/src/arrays/constant/vtable/canonical.rs +++ b/vortex-array/src/arrays/constant/vtable/canonical.rs @@ -126,6 +126,7 @@ pub(crate) fn constant_canonicalize( )) } DType::List(..) => Canonical::List(constant_canonical_list_array(scalar, array.len())), + DType::Map(..) => vortex_error::vortex_bail!("canonical map arrays are not yet supported"), DType::FixedSizeList(element_dtype, list_size, _) => { let value = scalar.as_list(); diff --git a/vortex-array/src/arrays/map/array.rs b/vortex-array/src/arrays/map/array.rs new file mode 100644 index 00000000000..6ad0180b46b --- /dev/null +++ b/vortex-array/src/arrays/map/array.rs @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +/// Placeholder for Vortex's canonical map array. +/// +/// Its physical storage layout will be defined when map array support is implemented. +#[derive(Clone, Debug, Default)] +pub struct MapArray; + +/// Placeholder for map-array metadata that is independent of child slots. +/// +/// Fields will be added with the selected canonical map layout. +#[derive(Clone, Debug, Default)] +pub struct MapData; + +/// Placeholder for the inputs used to construct a [`MapArray`]. +/// +/// Its fields will be defined with the selected canonical map layout. +#[derive(Clone, Debug, Default)] +pub struct MapDataParts; + +/// Marker trait for map-array accessors. +/// +/// Logical accessors will be added once the physical layout is selected. +pub trait MapArrayExt {} + +impl MapArrayExt for MapArray {} diff --git a/vortex-array/src/arrays/map/compute/cast.rs b/vortex-array/src/arrays/map/compute/cast.rs new file mode 100644 index 00000000000..33de7274db0 --- /dev/null +++ b/vortex-array/src/arrays/map/compute/cast.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array cast kernels will live here. diff --git a/vortex-array/src/arrays/map/compute/filter.rs b/vortex-array/src/arrays/map/compute/filter.rs new file mode 100644 index 00000000000..891be6ec845 --- /dev/null +++ b/vortex-array/src/arrays/map/compute/filter.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array filter kernels will live here. diff --git a/vortex-array/src/arrays/map/compute/mask.rs b/vortex-array/src/arrays/map/compute/mask.rs new file mode 100644 index 00000000000..fc8f76a937b --- /dev/null +++ b/vortex-array/src/arrays/map/compute/mask.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array mask kernels will live here. diff --git a/vortex-array/src/arrays/map/compute/mod.rs b/vortex-array/src/arrays/map/compute/mod.rs new file mode 100644 index 00000000000..932ffb41394 --- /dev/null +++ b/vortex-array/src/arrays/map/compute/mod.rs @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array compute-kernel namespace. + +mod cast; +mod filter; +mod mask; +pub(crate) mod rules; +mod slice; +mod take; diff --git a/vortex-array/src/arrays/map/compute/rules.rs b/vortex-array/src/arrays/map/compute/rules.rs new file mode 100644 index 00000000000..9933659e56a --- /dev/null +++ b/vortex-array/src/arrays/map/compute/rules.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array parent-reduction rules will live here. diff --git a/vortex-array/src/arrays/map/compute/slice.rs b/vortex-array/src/arrays/map/compute/slice.rs new file mode 100644 index 00000000000..c23fa491138 --- /dev/null +++ b/vortex-array/src/arrays/map/compute/slice.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array slice kernels will live here. diff --git a/vortex-array/src/arrays/map/compute/take.rs b/vortex-array/src/arrays/map/compute/take.rs new file mode 100644 index 00000000000..926b512693b --- /dev/null +++ b/vortex-array/src/arrays/map/compute/take.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array take kernels will live here. diff --git a/vortex-array/src/arrays/map/mod.rs b/vortex-array/src/arrays/map/mod.rs new file mode 100644 index 00000000000..a38751230dc --- /dev/null +++ b/vortex-array/src/arrays/map/mod.rs @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Canonical map array scaffolding. +//! +//! The physical layout for maps has not been selected yet. This module only reserves the +//! standard canonical-array structure and public type names. + +mod array; +pub use array::MapArray; +pub use array::MapArrayExt; +pub use array::MapData; +pub use array::MapDataParts; + +pub(crate) mod compute; + +mod vtable; +pub use vtable::Map; diff --git a/vortex-array/src/arrays/map/vtable/mod.rs b/vortex-array/src/arrays/map/vtable/mod.rs new file mode 100644 index 00000000000..0292b50a437 --- /dev/null +++ b/vortex-array/src/arrays/map/vtable/mod.rs @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +mod operations; +mod validity; + +/// Placeholder encoding marker for [`super::MapArray`]. +/// +/// The corresponding vtable will be implemented with the canonical map array layout. +#[derive(Clone, Debug, Default)] +pub struct Map; diff --git a/vortex-array/src/arrays/map/vtable/operations.rs b/vortex-array/src/arrays/map/vtable/operations.rs new file mode 100644 index 00000000000..21e55849123 --- /dev/null +++ b/vortex-array/src/arrays/map/vtable/operations.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array vtable operations will live here. diff --git a/vortex-array/src/arrays/map/vtable/validity.rs b/vortex-array/src/arrays/map/vtable/validity.rs new file mode 100644 index 00000000000..85b1a782ddb --- /dev/null +++ b/vortex-array/src/arrays/map/vtable/validity.rs @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Map array validity handling will live here. diff --git a/vortex-array/src/arrays/mod.rs b/vortex-array/src/arrays/mod.rs index 15b6b5aa6be..43178a4a3cf 100644 --- a/vortex-array/src/arrays/mod.rs +++ b/vortex-array/src/arrays/mod.rs @@ -76,6 +76,10 @@ pub mod listview; pub use listview::ListView; pub use listview::ListViewArray; +pub mod map; +pub use map::Map; +pub use map::MapArray; + pub mod masked; pub use masked::Masked; pub use masked::MaskedArray; diff --git a/vortex-array/src/builders/mod.rs b/vortex-array/src/builders/mod.rs index 561efc2711e..aae935fc430 100644 --- a/vortex-array/src/builders/mod.rs +++ b/vortex-array/src/builders/mod.rs @@ -288,6 +288,9 @@ pub fn builder_with_capacity(dtype: &DType, capacity: usize) -> Box { + vortex_error::vortex_panic!(InvalidArgument: "map builders are not yet supported") + } DType::FixedSizeList(elem_dtype, list_size, null) => { Box::new(FixedSizeListBuilder::with_capacity( Arc::clone(elem_dtype), diff --git a/vortex-array/src/builders/tests.rs b/vortex-array/src/builders/tests.rs index 138e6941def..a9db688f239 100644 --- a/vortex-array/src/builders/tests.rs +++ b/vortex-array/src/builders/tests.rs @@ -631,6 +631,9 @@ fn create_test_scalars_for_dtype(dtype: &DType, count: usize) -> Vec { .collect(); Scalar::fixed_size_list(Arc::clone(element_dtype), elements, *n) } + DType::Map(..) => { + panic!("map builders are not supported until MapArray exists") + } DType::Struct(fields, n) => { // Create struct scalars with field values. let field_values: Vec = fields diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index 71da52e1300..d725bb65632 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -209,6 +209,9 @@ impl Canonical { // An empty list view is trivially copyable to a list. .with_zero_copy_to_list(true) }), + DType::Map(..) => { + vortex_panic!(InvalidArgument: "canonical map arrays are not yet supported") + } DType::FixedSizeList(elem_dtype, list_size, null) => Canonical::FixedSizeList(unsafe { FixedSizeListArray::new_unchecked( Canonical::empty(elem_dtype).into_array(), diff --git a/vortex-array/src/compute/conformance/consistency.rs b/vortex-array/src/compute/conformance/consistency.rs index 73f98cce4a7..18cda1c425e 100644 --- a/vortex-array/src/compute/conformance/consistency.rs +++ b/vortex-array/src/compute/conformance/consistency.rs @@ -1227,6 +1227,7 @@ fn test_cast_slice_consistency(array: &ArrayRef, ctx: &mut ExecutionCtx) { opposite, )] } + DType::Map(..) => vec![], /* Map arrays are not materializable until their layout is chosen. */ DType::Struct(fields, nullability) => { let opposite = match nullability { Nullability::NonNullable => Nullability::Nullable, diff --git a/vortex-array/src/dtype/arbitrary/mod.rs b/vortex-array/src/dtype/arbitrary/mod.rs index 9b95074ff6f..4a56cba98ec 100644 --- a/vortex-array/src/dtype/arbitrary/mod.rs +++ b/vortex-array/src/dtype/arbitrary/mod.rs @@ -36,7 +36,7 @@ impl<'a> Arbitrary<'a> for FieldName { fn random_dtype(u: &mut Unstructured<'_>, depth: u8) -> Result { const BASE_TYPE_COUNT: i32 = 5; - const CONTAINER_TYPE_COUNT: i32 = 3; + const CONTAINER_TYPE_COUNT: i32 = 4; let max_dtype_kind = if depth == 0 { BASE_TYPE_COUNT } else { @@ -59,6 +59,13 @@ fn random_dtype(u: &mut Unstructured<'_>, depth: u8) -> Result { u.choose_index(3)?.try_into().vortex_expect("impossible"), u.arbitrary()?, ), + 9 => DType::map( + random_dtype(u, depth - 1)?.as_nonnullable(), + random_dtype(u, depth - 1)?, + u.arbitrary()?, + u.arbitrary()?, + ) + .vortex_expect("non-nullable generated map keys are always valid"), // Null, // Extension(ExtDType, Nullability), _ => unreachable!("Number out of range"), diff --git a/vortex-array/src/dtype/coercion.rs b/vortex-array/src/dtype/coercion.rs index 3df356d93af..59396e4274a 100644 --- a/vortex-array/src/dtype/coercion.rs +++ b/vortex-array/src/dtype/coercion.rs @@ -115,6 +115,20 @@ impl DType { return Some(DType::List(Arc::new(elem), union_null)); } + if let (DType::Map(lhs, _), DType::Map(rhs, _)) = (self, other) { + if lhs.key_dtype() != rhs.key_dtype() || lhs.value_dtype() != rhs.value_dtype() { + return None; + } + + return DType::map( + lhs.key_dtype(), + lhs.value_dtype(), + lhs.keys_sorted() && rhs.keys_sorted(), + union_null, + ) + .ok(); + } + // Identity (ignoring nullability): return self with union nullability if self.eq_ignore_nullability(other) { return Some(self.with_nullability(union_null)); @@ -202,6 +216,13 @@ impl DType { && target_elem.can_coerce_from(source_elem); } + if let (DType::Map(target, _), DType::Map(source, _)) = (self, other) { + return (self.is_nullable() || !other.is_nullable()) + && (!target.keys_sorted() || source.keys_sorted()) + && target.key_dtype() == source.key_dtype() + && target.value_dtype() == source.value_dtype(); + } + // Same type (ignoring nullability): check nullability compatibility if self.eq_ignore_nullability(other) { return self.is_nullable() || !other.is_nullable(); @@ -824,4 +845,50 @@ mod tests { DType::Decimal(DecimalDType::new(15, 5), NonNullable) ); } + + #[test] + fn map_least_supertype_unions_outer_nullability_and_intersects_sortedness() { + let key = DType::Primitive(PType::I32, NonNullable); + let value = DType::Utf8(Nullable); + let sorted = DType::map(key.clone(), value.clone(), true, NonNullable).unwrap(); + let unsorted = DType::map(key.clone(), value.clone(), false, Nullable).unwrap(); + + assert_eq!( + sorted.least_supertype(&unsorted), + Some(DType::map(key, value, false, Nullable).unwrap()) + ); + } + + #[test] + fn map_least_supertype_requires_identical_key_and_value_dtypes() { + let i32_map = DType::map( + DType::Primitive(PType::I32, NonNullable), + DType::Utf8(Nullable), + false, + NonNullable, + ) + .unwrap(); + let i64_map = DType::map( + DType::Primitive(PType::I64, NonNullable), + DType::Utf8(Nullable), + false, + NonNullable, + ) + .unwrap(); + + assert_eq!(i32_map.least_supertype(&i64_map), None); + } + + #[test] + fn map_coercion_does_not_create_a_sortedness_assertion() { + let key = DType::Primitive(PType::I32, NonNullable); + let value = DType::Utf8(Nullable); + let sorted = DType::map(key.clone(), value.clone(), true, Nullable).unwrap(); + let unsorted = DType::map(key.clone(), value, false, Nullable).unwrap(); + let different_value = DType::map(key, DType::Utf8(NonNullable), false, Nullable).unwrap(); + + assert!(!sorted.can_coerce_from(&unsorted)); + assert!(unsorted.can_coerce_from(&sorted)); + assert!(!unsorted.can_coerce_from(&different_value)); + } } diff --git a/vortex-array/src/dtype/dtype_impl.rs b/vortex-array/src/dtype/dtype_impl.rs index 5767a124667..380ce97a758 100644 --- a/vortex-array/src/dtype/dtype_impl.rs +++ b/vortex-array/src/dtype/dtype_impl.rs @@ -8,11 +8,13 @@ use std::sync::Arc; use DType::*; use itertools::Itertools; use vortex_error::VortexExpect; +use vortex_error::VortexResult; use vortex_error::vortex_panic; use super::DType; use crate::dtype::FieldDType; use crate::dtype::FieldName; +use crate::dtype::MapDType; use crate::dtype::PType; use crate::dtype::StructFields; use crate::dtype::UnionVariants; @@ -63,6 +65,7 @@ impl DType { | Binary(null) | List(_, null) | FixedSizeList(_, _, null) + | Map(_, null) | Struct(_, null) | Variant(null) => matches!(null, Nullability::Nullable), Union(variants) => variants.derived_nullability().is_nullable(), @@ -94,6 +97,7 @@ impl DType { Binary(_) => Binary(nullability), List(edt, _) => List(Arc::clone(edt), nullability), FixedSizeList(edt, size, _) => FixedSizeList(Arc::clone(edt), *size, nullability), + Map(map, _) => Map(map.clone(), nullability), Struct(sf, _) => Struct(sf.clone(), nullability), Union(vs) => Union(vs.clone()), Variant(_) => Variant(nullability), @@ -120,6 +124,7 @@ impl DType { (FixedSizeList(lhs_dtype, lhs_size, _), FixedSizeList(rhs_dtype, rhs_size, _)) => { lhs_size == rhs_size && lhs_dtype.eq_ignore_nullability(rhs_dtype) } + (Map(lhs, _), Map(rhs, _)) => lhs == rhs, (Struct(lhs_dtype, _), Struct(rhs_dtype, _)) => { (lhs_dtype.names() == rhs_dtype.names()) && (lhs_dtype @@ -254,6 +259,11 @@ impl DType { matches!(self, FixedSizeList(..)) } + /// Check if `self` is a [`DType::Map`]. + pub fn is_map(&self) -> bool { + matches!(self, Map(..)) + } + /// Check if `self` is a [`DType::Struct`] pub fn is_struct(&self) -> bool { matches!(self, Struct(_, _)) @@ -278,7 +288,7 @@ impl DType { /// recursive type. pub fn is_nested(&self) -> bool { match self { - List(..) | FixedSizeList(..) | Struct(..) | Union(..) | Variant(..) => true, + List(..) | FixedSizeList(..) | Map(..) | Struct(..) | Union(..) | Variant(..) => true, Extension(ext) => ext.storage_dtype().is_nested(), _ => false, } @@ -297,7 +307,7 @@ impl DType { Decimal(decimal, _) => { Some(DecimalType::smallest_decimal_value_type(decimal).byte_width()) } - Utf8(_) | Binary(_) | List(..) => None, + Utf8(_) | Binary(_) | List(..) | Map(..) => None, FixedSizeList(elem_dtype, list_size, _) => { elem_dtype.element_size().map(|s| s * *list_size as usize) } @@ -376,6 +386,24 @@ impl DType { } } + /// Get the [`MapDType`] if `self` is a [`DType::Map`], otherwise `None`. + pub fn as_map_opt(&self) -> Option<&MapDType> { + if let Map(map, _) = self { + Some(map) + } else { + None + } + } + + /// Owned version of [Self::as_map_opt]. + pub fn into_map_opt(self) -> Option { + if let Map(map, _) = self { + Some(map) + } else { + None + } + } + /// Get the inner element dtype if `self` is **either** a [`DType::List`] or a /// [`DType::FixedSizeList`], otherwise returns `None` pub fn as_any_size_list_element_opt(&self) -> Option<&Arc> { @@ -469,6 +497,23 @@ impl DType { List(Arc::new(dtype.into()), nullability) } + /// Convenience method for creating a [`DType::Map`]. + /// + /// # Errors + /// + /// Returns an error when the key dtype is nullable. + pub fn map( + key: impl Into, + value: impl Into, + keys_sorted: bool, + nullability: Nullability, + ) -> VortexResult { + Ok(Map( + MapDType::try_new(key.into(), value.into(), keys_sorted)?, + nullability, + )) + } + /// Convenience method for creating a [`DType::Struct`]. pub fn struct_, impl Into)>>( iter: I, @@ -489,6 +534,7 @@ impl Display for DType { Binary(null) => write!(f, "binary{null}"), List(edt, null) => write!(f, "list({edt}){null}"), FixedSizeList(edt, size, null) => write!(f, "fixed_size_list({edt})[{size}]{null}"), + Map(map, null) => write!(f, "{map}{null}"), Struct(sf, null) => write!( f, "{{{}}}{null}", diff --git a/vortex-array/src/dtype/map.rs b/vortex-array/src/dtype/map.rs new file mode 100644 index 00000000000..889429035bf --- /dev/null +++ b/vortex-array/src/dtype/map.rs @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use std::fmt; +use std::hash::Hash; +use std::sync::Arc; + +use vortex_error::VortexExpect; +use vortex_error::VortexResult; +use vortex_error::vortex_ensure; + +use crate::dtype::DType; +use crate::dtype::FieldDType; +use crate::dtype::Nullability; + +/// Logical type information for a map's entries. +/// +/// A map has ordered key/value entries. Keys must be non-nullable, while values may be nullable. +/// `keys_sorted` is a producer assertion matching Arrow's map type; it is not validated against +/// data at type construction time. +#[allow( + clippy::derived_hash_with_manual_eq, + reason = "manual PartialEq adds Arc::ptr_eq fast path only" +)] +#[derive(Clone, Eq, Hash)] +pub struct MapDType(Arc); + +impl PartialEq for MapDType { + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.0, &other.0) || self.0 == other.0 + } +} + +impl fmt::Debug for MapDType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("MapDType") + .field("key", &self.0.key) + .field("value", &self.0.value) + .field("keys_sorted", &self.0.keys_sorted) + .finish() + } +} + +impl fmt::Display for MapDType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "map({}, {}, keys_sorted={})", + self.key_dtype(), + self.value_dtype(), + self.keys_sorted() + ) + } +} + +struct MapDTypeInner { + key: FieldDType, + value: FieldDType, + keys_sorted: bool, +} + +impl PartialEq for MapDTypeInner { + fn eq(&self, other: &Self) -> bool { + self.key == other.key && self.value == other.value && self.keys_sorted == other.keys_sorted + } +} + +impl Eq for MapDTypeInner {} + +impl Hash for MapDTypeInner { + fn hash(&self, state: &mut H) { + self.key.hash(state); + self.value.hash(state); + self.keys_sorted.hash(state); + } +} + +impl MapDType { + /// Creates a map dtype from its key and value dtypes. + /// + /// # Errors + /// + /// Returns an error when `key` is nullable. Arrow map keys cannot be null. + pub fn try_new(key: DType, value: DType, keys_sorted: bool) -> VortexResult { + Self::try_from_fields(key.into(), value.into(), keys_sorted) + } + + pub(crate) fn try_from_fields( + key: FieldDType, + value: FieldDType, + keys_sorted: bool, + ) -> VortexResult { + vortex_ensure!( + !key.value()?.is_nullable(), + "map key dtype must be non-nullable" + ); + + Ok(Self(Arc::new(MapDTypeInner { + key, + value, + keys_sorted, + }))) + } + + /// Returns the dtype of the map keys. + pub fn key_dtype(&self) -> DType { + self.0 + .key + .value() + .vortex_expect("map key dtype must be valid") + } + + /// Returns the dtype of the map values. + pub fn value_dtype(&self) -> DType { + self.0 + .value + .value() + .vortex_expect("map value dtype must be valid") + } + + /// Returns whether producers assert that keys are sorted within every map value. + pub fn keys_sorted(&self) -> bool { + self.0.keys_sorted + } + + /// Returns the non-nullable `{key, value}` struct dtype used for map entries. + pub fn entries_dtype(&self) -> DType { + DType::struct_( + [("key", self.key_dtype()), ("value", self.value_dtype())], + Nullability::NonNullable, + ) + } +} + +#[cfg(test)] +mod tests { + use vortex_error::VortexResult; + + use crate::dtype::DType; + use crate::dtype::MapDType; + use crate::dtype::Nullability; + use crate::dtype::PType; + + #[test] + fn rejects_nullable_keys() { + let result = MapDType::try_new( + DType::Primitive(PType::I32, Nullability::Nullable), + DType::Utf8(Nullability::Nullable), + false, + ); + + assert!(result.is_err()); + } + + #[test] + fn accepts_nullable_values() -> VortexResult<()> { + let dtype = MapDType::try_new( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + )?; + + assert_eq!( + dtype.entries_dtype(), + DType::struct_( + [ + ( + "key", + DType::Primitive(PType::I32, Nullability::NonNullable) + ), + ("value", DType::Utf8(Nullability::Nullable)), + ], + Nullability::NonNullable, + ) + ); + assert!(dtype.keys_sorted()); + assert_eq!(dtype.to_string(), "map(i32, utf8?, keys_sorted=true)"); + + Ok(()) + } + + #[test] + fn outer_nullability_is_independent_of_map_details() -> VortexResult<()> { + let dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::NonNullable, + )?; + let nullable = dtype.as_nullable(); + + assert!(dtype.is_map()); + assert!(!dtype.is_nullable()); + assert!(nullable.is_nullable()); + assert!(dtype.eq_ignore_nullability(&nullable)); + assert_eq!(dtype.as_map_opt(), nullable.as_map_opt()); + assert!(nullable.as_map_opt().unwrap().keys_sorted()); + + Ok(()) + } +} diff --git a/vortex-array/src/dtype/mod.rs b/vortex-array/src/dtype/mod.rs index 0160b4c36c7..749b12e2fd8 100644 --- a/vortex-array/src/dtype/mod.rs +++ b/vortex-array/src/dtype/mod.rs @@ -24,6 +24,7 @@ mod f16; mod field; mod field_mask; mod field_names; +mod map; mod native_dtype; mod nullability; mod ptype; @@ -102,6 +103,12 @@ pub enum DType { /// well as a `u32` size that determines the fixed length of each `FixedSizeList` scalar. FixedSizeList(Arc, u32, Nullability), + /// A logical map type. + /// + /// Map keys are non-nullable, values may be nullable, and [`MapDType`] stores Arrow's + /// `keys_sorted` assertion. + Map(MapDType, Nullability), + /// A logical struct type. /// /// A `Struct` type is composed of an ordered list of fields, each with a corresponding name and @@ -149,6 +156,7 @@ impl PartialEq for DType { (Self::FixedSizeList(da, sa, na), Self::FixedSizeList(db, sb, nb)) => { sa == sb && na == nb && (Arc::ptr_eq(da, db) || da == db) } + (Self::Map(ma, na), Self::Map(mb, nb)) => na == nb && ma == mb, // StructFields handles its own Arc::ptr_eq in its PartialEq impl. (Self::Struct(a, na), Self::Struct(b, nb)) => na == nb && a == b, // UnionVariants handles its own Arc::ptr_eq in its PartialEq impl. @@ -165,6 +173,7 @@ impl PartialEq for DType { | (Self::Binary(_), _) | (Self::List(..), _) | (Self::FixedSizeList(..), _) + | (Self::Map(..), _) | (Self::Struct(..), _) | (Self::Union(..), _) | (Self::Variant(_), _) @@ -181,6 +190,7 @@ pub use field::*; pub use field_mask::*; pub use field_names::*; pub use half; +pub use map::*; pub use nullability::*; pub use ptype::*; pub use struct_::*; diff --git a/vortex-array/src/dtype/serde/flatbuffers.rs b/vortex-array/src/dtype/serde/flatbuffers.rs index eef15d59c57..ceb3e48a5a4 100644 --- a/vortex-array/src/dtype/serde/flatbuffers.rs +++ b/vortex-array/src/dtype/serde/flatbuffers.rs @@ -21,6 +21,7 @@ use vortex_session::VortexSession; use crate::dtype::DType; use crate::dtype::DecimalDType; use crate::dtype::FieldDType; +use crate::dtype::MapDType; use crate::dtype::PType; use crate::dtype::StructFields; use crate::dtype::UnionVariants; @@ -127,6 +128,32 @@ impl UnionVariants { } } +impl MapDType { + /// Creates a map dtype from a flatbuffer-defined object and its underlying buffer. + fn from_fb( + fb_map: fbd::Map<'_>, + buffer: FlatBuffer, + session: VortexSession, + ) -> VortexResult { + let key = fb_map + .key_type() + .ok_or_else(|| vortex_err!("failed to parse map key type from flatbuffer"))?; + let value = fb_map + .value_type() + .ok_or_else(|| vortex_err!("failed to parse map value type from flatbuffer"))?; + + MapDType::try_from_fields( + FieldDType::from(ViewedDType::from_fb_loc( + key._tab.loc(), + buffer.clone(), + session.clone(), + )), + FieldDType::from(ViewedDType::from_fb_loc(value._tab.loc(), buffer, session)), + fb_map.keys_sorted(), + ) + } +} + impl DType { /// Create a [`DType`] from a flatbuffer buffer. pub fn from_flatbuffer(buffer: FlatBuffer, session: &VortexSession) -> VortexResult { @@ -219,6 +246,13 @@ impl TryFrom for DType { fb_fixed_size_list.nullable().into(), )) } + fb::Type::Map => { + let fb_map = fb + .type__as_map() + .ok_or_else(|| vortex_err!("failed to parse map from flatbuffer"))?; + let map = MapDType::from_fb(fb_map, vfdt.buffer().clone(), vfdt.session.clone())?; + Ok(Self::Map(map, fb_map.nullable().into())) + } fb::Type::Struct_ => { let fb_struct = fb .type__as_struct_() @@ -356,6 +390,20 @@ impl WriteFlatBuffer for DType { ) .as_union_value() } + Self::Map(map, n) => { + let key_type = Some(map.key_dtype().write_flatbuffer(fbb)?); + let value_type = Some(map.value_dtype().write_flatbuffer(fbb)?); + fb::Map::create( + fbb, + &fb::MapArgs { + key_type, + value_type, + keys_sorted: map.keys_sorted(), + nullable: (*n).into(), + }, + ) + .as_union_value() + } Self::Struct(st, n) => { let names = st .names() @@ -438,6 +486,7 @@ impl WriteFlatBuffer for DType { Self::Binary(_) => fb::Type::Binary, Self::List(..) => fb::Type::List, Self::FixedSizeList(..) => fb::Type::FixedSizeList, + Self::Map(..) => fb::Type::Map, Self::Struct(..) => fb::Type::Struct_, Self::Union(..) => fb::Type::Union, Self::Variant(_) => fb::Type::Variant, @@ -559,6 +608,21 @@ mod test { ), Nullability::NonNullable, )); + let inner_map = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::NonNullable, + ) + .unwrap(); + let map = DType::map( + inner_map, + DType::Utf8(Nullability::Nullable), + false, + Nullability::Nullable, + ) + .unwrap(); + roundtrip_dtype(DType::struct_([("map", map)], Nullability::NonNullable)); roundtrip_dtype(DType::Variant(Nullability::Nullable)); } diff --git a/vortex-array/src/dtype/serde/mod.rs b/vortex-array/src/dtype/serde/mod.rs index 17e07c244cb..a08853086a8 100644 --- a/vortex-array/src/dtype/serde/mod.rs +++ b/vortex-array/src/dtype/serde/mod.rs @@ -202,4 +202,31 @@ mod test { assert_eq!(deserialized, dtype); assert_eq!(deserialized.nullability(), Nullability::Nullable); } + + #[test] + fn test_serde_nested_map_dtype_json_roundtrip() { + let inner_map = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::NonNullable, + ) + .unwrap(); + let map = DType::map( + inner_map, + DType::Utf8(Nullability::Nullable), + false, + Nullability::Nullable, + ) + .unwrap(); + let dtype = DType::struct_([("map", map)], Nullability::Nullable); + + let json = serde_json::to_string(&dtype).unwrap(); + let mut deserializer = serde_json::Deserializer::from_str(&json); + let deserialized: DType = DTypeSerde::::new(&SESSION) + .deserialize(&mut deserializer) + .unwrap(); + + assert_eq!(deserialized, dtype); + } } diff --git a/vortex-array/src/dtype/serde/proto.rs b/vortex-array/src/dtype/serde/proto.rs index e3dfb90557a..174582cf5a8 100644 --- a/vortex-array/src/dtype/serde/proto.rs +++ b/vortex-array/src/dtype/serde/proto.rs @@ -10,6 +10,7 @@ use vortex_session::VortexSession; use crate::dtype::DType; use crate::dtype::DecimalDType; +use crate::dtype::MapDType; use crate::dtype::PType; use crate::dtype::StructFields; use crate::dtype::UnionVariants; @@ -77,6 +78,26 @@ impl DType { nullable, )) } + DtypeType::Map(map) => Ok(Self::Map( + MapDType::try_new( + DType::from_proto( + map.key_type + .as_ref() + .ok_or_else(|| vortex_err!(Serde: "Invalid map key type"))? + .as_ref(), + session, + )?, + DType::from_proto( + map.value_type + .as_ref() + .ok_or_else(|| vortex_err!(Serde: "Invalid map value type"))? + .as_ref(), + session, + )?, + map.keys_sorted, + )?, + map.nullable.into(), + )), DtypeType::Struct(s) => Ok(Self::Struct( StructFields::new( s.names.iter().map(|s| s.as_str()).collect(), @@ -165,6 +186,16 @@ impl TryFrom<&DType> for pb::DType { nullable: (*null).into(), })) } + DType::Map(map, null) => { + let key_dtype = map.key_dtype(); + let value_dtype = map.value_dtype(); + DtypeType::Map(Box::new(pb::Map { + key_type: Some(Box::new(Self::try_from(&key_dtype)?)), + value_type: Some(Box::new(Self::try_from(&value_dtype)?)), + keys_sorted: map.keys_sorted(), + nullable: (*null).into(), + })) + } DType::Struct(s, null) => DtypeType::Struct(pb::Struct { names: s.names().iter().map(|s| s.as_ref().to_string()).collect(), dtypes: s @@ -392,6 +423,27 @@ mod tests { } } + #[test] + fn test_nested_map_round_trip() { + let inner_map = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::NonNullable, + ) + .unwrap(); + let map = DType::map( + inner_map, + DType::Utf8(Nullability::Nullable), + false, + Nullability::Nullable, + ) + .unwrap(); + let dtype = DType::struct_([("map", map)], Nullability::NonNullable); + + assert_eq!(round_trip_dtype(&dtype), dtype); + } + #[test] fn test_extension_round_trip() { let ext_dtype = diff --git a/vortex-array/src/dtype/serde/serde.rs b/vortex-array/src/dtype/serde/serde.rs index 1d386a34cbf..afc2ee76d7a 100644 --- a/vortex-array/src/dtype/serde/serde.rs +++ b/vortex-array/src/dtype/serde/serde.rs @@ -110,6 +110,14 @@ impl Serialize for DType { state.serialize_field(n)?; state.end() } + DType::Map(map, n) => { + let mut state = serializer.serialize_tuple_variant("DType", 12, "Map", 4)?; + state.serialize_field(&map.key_dtype())?; + state.serialize_field(&map.value_dtype())?; + state.serialize_field(&map.keys_sorted())?; + state.serialize_field(n)?; + state.end() + } DType::Struct(fields, n) => { let mut state = serializer.serialize_tuple_variant("DType", 8, "Struct", 2)?; state.serialize_field(&fields)?; @@ -176,6 +184,7 @@ impl<'de> DeserializeSeed<'de> for DTypeSerde<'_, DType> { "Union", "Variant", "Extension", + "Map", ]; struct DTypeVisitor<'a> { @@ -229,6 +238,9 @@ impl<'de> DeserializeSeed<'de> for DTypeSerde<'_, DType> { "FixedSizeList" => access.newtype_variant_seed(FixedSizeListFieldsSeed { session: self.session, }), + "Map" => access.newtype_variant_seed(MapFieldsSeed { + session: self.session, + }), "Struct" => access.newtype_variant_seed(StructFieldsSeed { session: self.session, }), @@ -259,6 +271,59 @@ impl<'de> DeserializeSeed<'de> for DTypeSerde<'_, DType> { } } +struct MapFieldsSeed<'a> { + session: &'a VortexSession, +} + +impl<'de> DeserializeSeed<'de> for MapFieldsSeed<'_> { + type Value = DType; + + fn deserialize(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MapVisitor<'a> { + session: &'a VortexSession, + } + + impl<'de> Visitor<'de> for MapVisitor<'_> { + type Value = DType; + + fn expecting(&self, f: &mut Formatter) -> fmt::Result { + f.write_str("Map tuple (key_dtype, value_dtype, keys_sorted, nullability)") + } + + fn visit_seq(self, mut seq: A) -> Result + where + A: SeqAccess<'de>, + { + let key = seq + .next_element_seed(DTypeSerde::::new(self.session))? + .ok_or_else(|| de::Error::invalid_length(0, &self))?; + let value = seq + .next_element_seed(DTypeSerde::::new(self.session))? + .ok_or_else(|| de::Error::invalid_length(1, &self))?; + let keys_sorted = seq + .next_element()? + .ok_or_else(|| de::Error::invalid_length(2, &self))?; + let nullability = seq + .next_element()? + .ok_or_else(|| de::Error::invalid_length(3, &self))?; + + DType::map(key, value, keys_sorted, nullability) + .map_err(|error| de::Error::custom(error.to_string())) + } + } + + deserializer.deserialize_tuple( + 4, + MapVisitor { + session: self.session, + }, + ) + } +} + // ============================================================================ // Helper seeds for nested DType variants (with session) // ============================================================================ diff --git a/vortex-array/src/scalar/arbitrary.rs b/vortex-array/src/scalar/arbitrary.rs index 8424f74b175..fd762b0daae 100644 --- a/vortex-array/src/scalar/arbitrary.rs +++ b/vortex-array/src/scalar/arbitrary.rs @@ -86,6 +86,23 @@ pub fn random_scalar(u: &mut Unstructured, dtype: &DType) -> Result { )), ) .vortex_expect("unable to construct random `Scalar`_"), + DType::Map(map, _) => Scalar::try_new( + dtype.clone(), + Some(ScalarValue::Tuple( + iter::from_fn(|| { + u.arbitrary().unwrap_or(false).then(|| { + let key = random_scalar(u, &map.key_dtype())?; + let value = random_scalar(u, &map.value_dtype())?; + Ok(Some(ScalarValue::Tuple(vec![ + key.into_value(), + value.into_value(), + ]))) + }) + }) + .collect::>>()?, + )), + ) + .vortex_expect("unable to construct random `Scalar`_"), DType::Struct(sdt, _) => Scalar::try_new( dtype.clone(), Some(ScalarValue::Tuple( diff --git a/vortex-array/src/scalar/cast.rs b/vortex-array/src/scalar/cast.rs index fd3678a74e6..07df9953fb6 100644 --- a/vortex-array/src/scalar/cast.rs +++ b/vortex-array/src/scalar/cast.rs @@ -57,6 +57,7 @@ impl Scalar { DType::Utf8(_) => self.as_utf8().cast(target_dtype), DType::Binary(_) => self.as_binary().cast(target_dtype), DType::List(..) | DType::FixedSizeList(..) => self.as_list().cast(target_dtype), + DType::Map(..) => self.as_map().cast(target_dtype), DType::Struct(..) => self.as_struct().cast(target_dtype), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => vortex_bail!("Variant scalars can't be cast to {target_dtype}"), diff --git a/vortex-array/src/scalar/constructor.rs b/vortex-array/src/scalar/constructor.rs index 16c87ca27a6..207db9b56e1 100644 --- a/vortex-array/src/scalar/constructor.rs +++ b/vortex-array/src/scalar/constructor.rs @@ -8,6 +8,8 @@ use std::sync::Arc; use vortex_buffer::BufferString; use vortex_buffer::ByteBuffer; use vortex_error::VortexExpect; +use vortex_error::VortexResult; +use vortex_error::vortex_bail; use vortex_error::vortex_panic; use crate::dtype::DType; @@ -134,6 +136,58 @@ impl Scalar { Self::create_list(element_dtype, children, nullability, ListKind::FixedSize) } + /// Creates a map scalar with the given dtype and ordered key/value entries. + /// + /// # Panics + /// + /// Panics when `dtype` is not a map or an entry has an incompatible key or value dtype. + pub fn map(dtype: DType, entries: impl IntoIterator) -> Self { + Self::try_map(dtype, entries).vortex_expect("unable to construct a map `Scalar`") + } + + /// Attempts to create a map scalar with the given dtype and ordered key/value entries. + /// + /// # Errors + /// + /// Returns an error when `dtype` is not a map or an entry has an incompatible key or value + /// dtype. + pub fn try_map( + dtype: DType, + entries: impl IntoIterator, + ) -> VortexResult { + let map = dtype + .as_map_opt() + .ok_or_else(|| vortex_error::vortex_err!("Expected map dtype, found {dtype}"))?; + let key_dtype = map.key_dtype(); + let value_dtype = map.value_dtype(); + + let entries = entries + .into_iter() + .enumerate() + .map(|(index, (key, value))| { + if key.dtype() != &key_dtype { + vortex_bail!( + "map entry {index} expected key dtype {key_dtype}, got {}", + key.dtype() + ); + } + if value.dtype() != &value_dtype { + vortex_bail!( + "map entry {index} expected value dtype {value_dtype}, got {}", + value.dtype() + ); + } + + Ok(Some(ScalarValue::Tuple(vec![ + key.into_value(), + value.into_value(), + ]))) + }) + .collect::>>()?; + + Self::try_new(dtype, Some(ScalarValue::Tuple(entries))) + } + /// Creates a list [`Scalar`] from an element dtype, children, nullability, and list kind. fn create_list( element_dtype: impl Into>, diff --git a/vortex-array/src/scalar/convert/from_scalar.rs b/vortex-array/src/scalar/convert/from_scalar.rs index 32753dea1dc..77b35ad3f28 100644 --- a/vortex-array/src/scalar/convert/from_scalar.rs +++ b/vortex-array/src/scalar/convert/from_scalar.rs @@ -14,6 +14,7 @@ use crate::scalar::BoolScalar; use crate::scalar::DecimalScalar; use crate::scalar::ExtScalar; use crate::scalar::ListScalar; +use crate::scalar::MapScalar; use crate::scalar::PrimitiveScalar; use crate::scalar::Scalar; use crate::scalar::StructScalar; @@ -95,6 +96,16 @@ impl<'a> TryFrom<&'a Scalar> for ListScalar<'a> { } } +impl<'a> TryFrom<&'a Scalar> for MapScalar<'a> { + type Error = VortexError; + + fn try_from(value: &'a Scalar) -> VortexResult { + value + .as_map_opt() + .ok_or_else(|| vortex_err!("Expected map scalar, found {}", value.dtype())) + } +} + impl<'a> TryFrom<&'a Scalar> for ExtScalar<'a> { type Error = VortexError; diff --git a/vortex-array/src/scalar/display.rs b/vortex-array/src/scalar/display.rs index 3e3aa56b8c3..f8be85335e9 100644 --- a/vortex-array/src/scalar/display.rs +++ b/vortex-array/src/scalar/display.rs @@ -19,6 +19,7 @@ impl Display for Scalar { DType::Utf8(_) => write!(f, "{}", self.as_utf8()), DType::Binary(_) => write!(f, "{}", self.as_binary()), DType::List(..) | DType::FixedSizeList(..) => write!(f, "{}", self.as_list()), + DType::Map(..) => write!(f, "{}", self.as_map()), DType::Struct(..) => write!(f, "{}", self.as_struct()), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => write!(f, "{}", self.as_variant()), diff --git a/vortex-array/src/scalar/downcast.rs b/vortex-array/src/scalar/downcast.rs index 1276141fc35..59ccb90fa50 100644 --- a/vortex-array/src/scalar/downcast.rs +++ b/vortex-array/src/scalar/downcast.rs @@ -14,6 +14,7 @@ use crate::scalar::DecimalScalar; use crate::scalar::DecimalValue; use crate::scalar::ExtScalar; use crate::scalar::ListScalar; +use crate::scalar::MapScalar; use crate::scalar::PValue; use crate::scalar::PrimitiveScalar; use crate::scalar::Scalar; @@ -135,6 +136,21 @@ impl Scalar { ListScalar::try_new(self.dtype(), self.value()).ok() } + /// Returns a view of the scalar as a map scalar. + /// + /// # Panics + /// + /// Panics if the scalar does not have a [`Map`](crate::dtype::DType::Map) type. + pub fn as_map(&self) -> MapScalar<'_> { + self.as_map_opt() + .vortex_expect("Failed to convert scalar to map") + } + + /// Returns a view of the scalar as a map scalar if it has a map type. + pub fn as_map_opt(&self) -> Option> { + MapScalar::try_new(self.dtype(), self.value()).ok() + } + /// Returns a view of the scalar as an extension scalar. /// /// # Panics diff --git a/vortex-array/src/scalar/proto.rs b/vortex-array/src/scalar/proto.rs index f172d5491f3..62c5d956469 100644 --- a/vortex-array/src/scalar/proto.rs +++ b/vortex-array/src/scalar/proto.rs @@ -12,6 +12,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_ensure; +use vortex_error::vortex_ensure_eq; use vortex_error::vortex_err; use vortex_proto::scalar as pb; use vortex_proto::scalar::ListValue; @@ -441,23 +442,39 @@ fn list_from_proto( dtype: &DType, session: &VortexSession, ) -> VortexResult { - let element_dtype = match dtype { - DType::List(edt, _) => edt, - DType::FixedSizeList(edt, ..) => edt, - _ => { - vortex_bail!(Serde: "expected List or FixedSizeList dtype for ListValue, got {dtype}") + let values = match dtype { + DType::List(element_dtype, _) | DType::FixedSizeList(element_dtype, ..) => v + .values + .iter() + .map(|value| ScalarValue::from_proto(value, element_dtype, session)) + .collect::>>()?, + DType::Struct(fields, _) => { + vortex_ensure_eq!( + v.values.len(), + fields.nfields(), + Serde: "expected {} struct fields for ListValue, got {}", + fields.nfields(), + v.values.len(), + ); + + v.values + .iter() + .zip(fields.fields()) + .map(|(value, field_dtype)| ScalarValue::from_proto(value, &field_dtype, session)) + .collect::>>()? + } + DType::Map(map, _) => { + let entry_dtype = map.entries_dtype(); + v.values + .iter() + .map(|entry| ScalarValue::from_proto(entry, &entry_dtype, session)) + .collect::>>()? } + _ => vortex_bail!( + Serde: "expected a tuple-backed dtype for ListValue, got {dtype}" + ), }; - let mut values = Vec::with_capacity(v.values.len()); - for elem in v.values.iter() { - values.push(ScalarValue::from_proto( - elem, - element_dtype.as_ref(), - session, - )?); - } - Ok(ScalarValue::Tuple(values)) } @@ -544,6 +561,34 @@ mod tests { )); } + #[test] + fn test_map() { + let dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::Nullable, + ) + .unwrap(); + round_trip( + Scalar::try_map( + dtype.clone(), + [ + ( + Scalar::primitive(1i32, Nullability::NonNullable), + Scalar::utf8("one", Nullability::Nullable), + ), + ( + Scalar::primitive(2i32, Nullability::NonNullable), + Scalar::null(DType::Utf8(Nullability::Nullable)), + ), + ], + ) + .unwrap(), + ); + round_trip(Scalar::null(dtype)); + } + #[test] fn test_f16() { round_trip(Scalar::primitive( diff --git a/vortex-array/src/scalar/scalar_impl.rs b/vortex-array/src/scalar/scalar_impl.rs index 60a675e42b9..e23b7ca74d5 100644 --- a/vortex-array/src/scalar/scalar_impl.rs +++ b/vortex-array/src/scalar/scalar_impl.rs @@ -123,6 +123,7 @@ impl Scalar { /// - `Utf8`: `""` /// - `Binary`: An empty buffer /// - `List`: An empty list + /// - `Map`: An empty map /// - `FixedSizeList`: A list (with correct size) of zero values, which is determined by the /// element [`DType`] /// - `Struct`: A struct where each field has a zero value, which is determined by the field @@ -188,6 +189,7 @@ impl Scalar { DType::Utf8(_) => value.as_utf8().is_empty(), DType::Binary(_) => value.as_binary().is_empty(), DType::List(..) => value.as_list().is_empty(), + DType::Map(..) => self.as_map().is_empty(), // A fixed-size list is zero only if it has the expected number of elements and every // element is itself a non-null zero value. DType::FixedSizeList(_, list_size, _) => { @@ -265,6 +267,11 @@ impl Scalar { .elements() .map(|fields| fields.into_iter().map(|f| f.approx_nbytes()).sum::()) .unwrap_or_default(), + DType::Map(..) => self + .as_map() + .entries() + .map(|(key, value)| key.approx_nbytes() + value.approx_nbytes()) + .sum(), DType::Struct(..) => self .as_struct() .fields_iter() @@ -395,6 +402,7 @@ fn partial_cmp_tuple_values( partial_cmp_list_values(element_dtype, lhs, rhs) } DType::Struct(fields, _) => partial_cmp_struct_values(fields, lhs, rhs), + DType::Map(..) => None, DType::Extension(ext_dtype) => { partial_cmp_tuple_values(ext_dtype.storage_dtype(), lhs, rhs) } diff --git a/vortex-array/src/scalar/scalar_value.rs b/vortex-array/src/scalar/scalar_value.rs index ebc2101fac6..c004cf6de97 100644 --- a/vortex-array/src/scalar/scalar_value.rs +++ b/vortex-array/src/scalar/scalar_value.rs @@ -34,7 +34,7 @@ pub enum ScalarValue { Binary(ByteBuffer), /// A tuple of potentially null scalar values. /// - /// Used as the underlying representation for list, fixed-size list, and struct scalars. + /// Used as the underlying representation for list, fixed-size list, map, and struct scalars. Tuple(Vec>), /// A row-specific scalar wrapped by `DType::Variant`. Variant(Box), @@ -51,6 +51,7 @@ impl ScalarValue { DType::Utf8(_) => Self::Utf8(BufferString::empty()), DType::Binary(_) => Self::Binary(ByteBuffer::empty()), DType::List(..) => Self::Tuple(vec![]), + DType::Map(..) => Self::Tuple(vec![]), DType::FixedSizeList(edt, size, _) => { let elements = (0..*size).map(|_| Some(Self::zero_value(edt))).collect(); Self::Tuple(elements) @@ -92,6 +93,7 @@ impl ScalarValue { DType::Utf8(_) => Self::Utf8(BufferString::empty()), DType::Binary(_) => Self::Binary(ByteBuffer::empty()), DType::List(..) => Self::Tuple(vec![]), + DType::Map(..) => Self::Tuple(vec![]), DType::FixedSizeList(edt, size, _) => { let elements = (0..*size).map(|_| Self::default_value(edt)).collect(); Self::Tuple(elements) diff --git a/vortex-array/src/scalar/typed_view/map.rs b/vortex-array/src/scalar/typed_view/map.rs new file mode 100644 index 00000000000..f2eadd5c2b9 --- /dev/null +++ b/vortex-array/src/scalar/typed_view/map.rs @@ -0,0 +1,334 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! [`MapScalar`] typed view implementation. + +use std::fmt::Display; +use std::fmt::Formatter; +use std::hash::Hash; + +use itertools::Itertools; +use vortex_error::VortexExpect; +use vortex_error::VortexResult; +use vortex_error::vortex_bail; +use vortex_error::vortex_err; + +use crate::dtype::DType; +use crate::dtype::MapDType; +use crate::scalar::Scalar; +use crate::scalar::ScalarValue; + +/// A scalar value representing an ordered sequence of map key/value entries. +/// +/// Map keys are non-null and each entry has exactly one key and one value. Duplicate keys are +/// preserved because map logical types do not enforce key uniqueness. +#[derive(Debug, Clone, Copy)] +pub struct MapScalar<'a> { + dtype: &'a DType, + entries: Option<&'a [Option]>, +} + +impl Display for MapScalar<'_> { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + if self.is_null() { + return write!(f, "null"); + } + + write!( + f, + "{{{}}}", + self.entries() + .map(|(key, value)| format!("{key}: {value}")) + .format(", ") + ) + } +} + +impl PartialEq for MapScalar<'_> { + fn eq(&self, other: &Self) -> bool { + self.dtype.eq_ignore_nullability(other.dtype) && self.entries == other.entries + } +} + +impl Eq for MapScalar<'_> {} + +impl Hash for MapScalar<'_> { + fn hash(&self, state: &mut H) { + self.dtype.as_nonnullable().hash(state); + self.entries.hash(state); + } +} + +impl<'a> MapScalar<'a> { + /// Creates a map scalar view from a dtype and optional scalar value. + /// + /// # Errors + /// + /// Returns an error when `dtype` is not [`DType::Map`]. + pub fn try_new(dtype: &'a DType, value: Option<&'a ScalarValue>) -> VortexResult { + if !dtype.is_map() { + vortex_bail!("Expected map scalar, found {dtype}") + } + + Ok(Self { + dtype, + entries: value.map(ScalarValue::as_list), + }) + } + + /// Returns the map dtype. + #[inline] + pub fn dtype(&self) -> &'a DType { + self.dtype + } + + /// Returns the map type details. + #[inline] + pub fn map_dtype(&self) -> &'a MapDType { + self.dtype + .as_map_opt() + .vortex_expect("MapScalar always has a map dtype") + } + + /// Returns the number of entries, or zero for a null map. + #[inline] + pub fn len(&self) -> usize { + self.entries.map_or(0, <[Option]>::len) + } + + /// Returns whether the map has no entries or is null. + #[inline] + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns whether the entire map scalar is null. + #[inline] + pub fn is_null(&self) -> bool { + self.entries.is_none() + } + + /// Returns the entry at `index`, or `None` when the map is null or the index is out of bounds. + pub fn entry(&self, index: usize) -> Option<(Scalar, Scalar)> { + let values = self.entries?.get(index)?.as_ref()?.as_list(); + Some(self.entry_scalars(values)) + } + + /// Iterates over `(key, value)` entries. A null map yields no entries. + pub fn entries(&self) -> impl Iterator + '_ { + self.entries.into_iter().flatten().map(|entry| { + self.entry_scalars( + entry + .as_ref() + .vortex_expect("map entry is non-null") + .as_list(), + ) + }) + } + + /// Iterates over map keys. A null map yields no keys. + pub fn keys(&self) -> impl Iterator + '_ { + self.entries().map(|(key, _)| key) + } + + /// Iterates over map values. A null map yields no values. + pub fn values(&self) -> impl Iterator + '_ { + self.entries().map(|(_, value)| value) + } + + /// Casts this map scalar to another map dtype. + /// + /// # Errors + /// + /// Returns an error when `dtype` is not a map, its key/value dtypes cannot be cast, or the + /// target claims sorted keys when this scalar's dtype does not make that assertion. + pub(crate) fn cast(&self, dtype: &DType) -> VortexResult { + let target = dtype + .as_map_opt() + .ok_or_else(|| vortex_err!("Cannot cast map to {dtype}: target must be a map"))?; + + if target.keys_sorted() && !self.map_dtype().keys_sorted() { + vortex_bail!( + "Cannot cast {} to {dtype}: source does not assert sorted map keys", + self.dtype + ); + } + + let Some(entries) = self.entries else { + return Ok(Scalar::null(dtype.clone())); + }; + + let target_key = target.key_dtype(); + let target_value = target.value_dtype(); + let entries = entries + .iter() + .map(|entry| { + let (key, value) = self.entry_scalars( + entry + .as_ref() + .vortex_expect("map entry is non-null") + .as_list(), + ); + Ok(Some(ScalarValue::Tuple(vec![ + key.cast(&target_key)?.into_value(), + value.cast(&target_value)?.into_value(), + ]))) + }) + .collect::>>()?; + + Scalar::try_new(dtype.clone(), Some(ScalarValue::Tuple(entries))) + } + + fn entry_scalars(&self, values: &[Option]) -> (Scalar, Scalar) { + let key = values.first().vortex_expect("map entry has a key").clone(); + let value = values.get(1).vortex_expect("map entry has a value").clone(); + + // SAFETY: MapScalar only views a Scalar that has passed Scalar::validate, which enforces + // the entry shape and the key/value dtypes. + ( + unsafe { Scalar::new_unchecked(self.map_dtype().key_dtype(), key) }, + unsafe { Scalar::new_unchecked(self.map_dtype().value_dtype(), value) }, + ) + } +} + +#[cfg(test)] +mod tests { + use vortex_error::VortexResult; + + use crate::dtype::DType; + use crate::dtype::Nullability; + use crate::dtype::PType; + use crate::scalar::Scalar; + use crate::scalar::ScalarValue; + + fn dtype() -> VortexResult { + DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + false, + Nullability::Nullable, + ) + } + + #[test] + fn entries_and_display() -> VortexResult<()> { + let scalar = Scalar::try_map( + dtype()?, + [ + ( + Scalar::primitive(1i32, Nullability::NonNullable), + Scalar::utf8("one", Nullability::Nullable), + ), + ( + Scalar::primitive(2i32, Nullability::NonNullable), + Scalar::null(DType::Utf8(Nullability::Nullable)), + ), + ], + )?; + + let map = scalar.as_map(); + assert_eq!(map.len(), 2); + assert_eq!(map.keys().count(), 2); + assert_eq!(map.values().count(), 2); + assert_eq!( + map.entry(0).unwrap().0, + Scalar::primitive(1i32, Nullability::NonNullable) + ); + assert_eq!(format!("{map}"), "{1i32: \"one\", 2i32: null}"); + + Ok(()) + } + + #[test] + fn null_map_is_distinct_from_empty_map() -> VortexResult<()> { + let dtype = dtype()?; + let empty = Scalar::try_map(dtype.clone(), [])?; + let null = Scalar::null(dtype); + + assert!(empty.as_map().is_empty()); + assert!(!empty.as_map().is_null()); + assert!(null.as_map().is_null()); + assert_ne!(empty, null); + + Ok(()) + } + + #[test] + fn rejects_malformed_entries() -> VortexResult<()> { + let dtype = dtype()?; + let malformed = Scalar::try_new( + dtype, + Some(ScalarValue::Tuple(vec![Some(ScalarValue::Tuple(vec![ + Some(ScalarValue::Primitive(1i32.into())), + ]))])), + ); + + assert!(malformed.is_err()); + Ok(()) + } + + #[test] + fn rejects_null_keys() -> VortexResult<()> { + let malformed = Scalar::try_new( + dtype()?, + Some(ScalarValue::Tuple(vec![Some(ScalarValue::Tuple(vec![ + None, + Some(ScalarValue::Utf8("value".into())), + ]))])), + ); + + assert!(malformed.is_err()); + Ok(()) + } + + #[test] + fn cast_can_drop_a_sortedness_assertion() -> VortexResult<()> { + let source_dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::NonNullable, + )?; + let target_dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + false, + Nullability::Nullable, + )?; + let scalar = Scalar::try_map( + source_dtype, + [( + Scalar::primitive(1i32, Nullability::NonNullable), + Scalar::utf8("one", Nullability::Nullable), + )], + )?; + + let cast = scalar.cast(&target_dtype)?; + assert_eq!(cast.dtype(), &target_dtype); + assert_eq!(cast.as_map().entry(0), scalar.as_map().entry(0)); + + Ok(()) + } + + #[test] + fn cast_cannot_create_a_sortedness_assertion() -> VortexResult<()> { + let target_dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::Nullable, + )?; + let scalar = Scalar::try_map( + dtype()?, + [( + Scalar::primitive(1i32, Nullability::NonNullable), + Scalar::utf8("one", Nullability::Nullable), + )], + )?; + + assert!(scalar.cast(&target_dtype).is_err()); + + Ok(()) + } +} diff --git a/vortex-array/src/scalar/typed_view/mod.rs b/vortex-array/src/scalar/typed_view/mod.rs index 639288bd8fc..f817390da48 100644 --- a/vortex-array/src/scalar/typed_view/mod.rs +++ b/vortex-array/src/scalar/typed_view/mod.rs @@ -20,6 +20,7 @@ mod bool; mod decimal; mod extension; mod list; +mod map; mod primitive; mod struct_; mod utf8; @@ -30,6 +31,7 @@ pub use bool::*; pub use decimal::*; pub use extension::*; pub use list::*; +pub use map::*; pub use primitive::*; pub use struct_::*; pub use utf8::*; diff --git a/vortex-array/src/scalar/validate.rs b/vortex-array/src/scalar/validate.rs index 1423605b1d1..60b0c5da11a 100644 --- a/vortex-array/src/scalar/validate.rs +++ b/vortex-array/src/scalar/validate.rs @@ -101,6 +101,37 @@ impl Scalar { })?; } } + DType::Map(map, _) => { + let ScalarValue::Tuple(entries) = value else { + vortex_bail!("map dtype expected Tuple value, got {value}"); + }; + let key_dtype = map.key_dtype(); + let value_dtype = map.value_dtype(); + + for (index, entry) in entries.iter().enumerate() { + let entry = entry.as_ref().ok_or_else(|| { + vortex_error::vortex_err!("map entry at index {index} cannot be null") + })?; + let ScalarValue::Tuple(values) = entry else { + vortex_bail!( + "map entry at index {index} expected Tuple value, got {entry}" + ); + }; + vortex_ensure_eq!( + values.len(), + 2, + "map entry at index {index} expected 2 values, got {}", + values.len(), + ); + + Self::validate(&key_dtype, values[0].as_ref()).map_err(|error| { + vortex_error::vortex_err!("map key at entry {index}: {error}") + })?; + Self::validate(&value_dtype, values[1].as_ref()).map_err(|error| { + vortex_error::vortex_err!("map value at entry {index}: {error}") + })?; + } + } DType::Struct(fields, _) => { let ScalarValue::Tuple(values) = value else { vortex_bail!("struct dtype expected Tuple value, got {value}"); diff --git a/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs b/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs index 70e98639b54..0452f4a3156 100644 --- a/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs @@ -217,7 +217,7 @@ fn compare_arrays( DType::Struct(..) | DType::List(..) | DType::FixedSizeList(..) => { nested::compare_nested(lhs, rhs, op, nullability, ctx) } - DType::Union(..) | DType::Variant(_) | DType::Extension(_) => { + DType::Map(..) | DType::Union(..) | DType::Variant(_) | DType::Extension(_) => { vortex_bail!("compare is not supported for dtype {}", lhs.dtype()) } } diff --git a/vortex-array/src/scalar_fn/fns/binary/compare/nested.rs b/vortex-array/src/scalar_fn/fns/binary/compare/nested.rs index 56d8cbf0496..c9d5317d6ea 100644 --- a/vortex-array/src/scalar_fn/fns/binary/compare/nested.rs +++ b/vortex-array/src/scalar_fn/fns/binary/compare/nested.rs @@ -213,7 +213,7 @@ fn build_values_comparator( let rhs = rhs.clone().execute::(ctx)?; build_comparator(lhs.storage_array(), rhs.storage_array(), ctx)? } - DType::Union(..) | DType::Variant(_) => { + DType::Map(..) | DType::Union(..) | DType::Variant(_) => { vortex_bail!("compare is not supported for dtype {}", lhs.dtype()) } }) diff --git a/vortex-arrow/src/convert.rs b/vortex-arrow/src/convert.rs index 0bab0937a8a..b6de42d760f 100644 --- a/vortex-arrow/src/convert.rs +++ b/vortex-arrow/src/convert.rs @@ -546,6 +546,9 @@ impl FromArrowArray<&dyn ArrowArray> for ArrayRef { DataType::ListView(_) => Self::from_arrow(array.as_list_view::(), nullable), DataType::LargeListView(_) => Self::from_arrow(array.as_list_view::(), nullable), DataType::FixedSizeList(..) => Self::from_arrow(array.as_fixed_size_list(), nullable), + DataType::Map(..) => { + vortex_bail!("Arrow MapArray conversion is not yet supported") + } DataType::Null => Self::from_arrow(as_null_array(array), nullable), DataType::Timestamp(u, _) => match u { ArrowTimeUnit::Second => { diff --git a/vortex-arrow/src/dtype.rs b/vortex-arrow/src/dtype.rs index a87c931f3df..9c8be4840ae 100644 --- a/vortex-arrow/src/dtype.rs +++ b/vortex-arrow/src/dtype.rs @@ -38,6 +38,8 @@ use vortex_array::extension::datetime::Timestamp; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; +use vortex_error::vortex_ensure; +use vortex_error::vortex_ensure_eq; use vortex_error::vortex_err; use vortex_error::vortex_panic; @@ -224,6 +226,35 @@ impl TryFromArrowType<(&DataType, Nullability)> for DType { nullability, ), DataType::Struct(f) => DType::Struct(StructFields::try_from_arrow(f)?, nullability), + DataType::Map(entries, keys_sorted) => { + vortex_ensure!( + !entries.is_nullable(), + "Arrow map entries field must be non-nullable" + ); + let DataType::Struct(fields) = entries.data_type() else { + vortex_bail!( + "Arrow map entries field must have Struct type, got {:?}", + entries.data_type() + ); + }; + vortex_ensure_eq!( + fields.len(), + 2, + InvalidArgument: "Arrow map entries struct must contain exactly two fields" + ); + let key = &fields[0]; + let value = &fields[1]; + vortex_ensure!( + !key.is_nullable(), + "Arrow map key field must be non-nullable" + ); + DType::map( + Self::try_from_arrow(key.as_ref())?, + Self::try_from_arrow(value.as_ref())?, + *keys_sorted, + nullability, + )? + } DataType::Dictionary(_, value_type) => { Self::try_from_arrow((value_type.as_ref(), nullability))? } @@ -368,6 +399,17 @@ pub(crate) fn to_data_type_naive(dtype: &DType) -> VortexResult { )), *size as i32, ), + DType::Map(map_dtype, _) => { + let key = Field::new("key", to_data_type_naive(&map_dtype.key_dtype())?, false); + let value_dtype = map_dtype.value_dtype(); + let value = Field::new( + "value", + to_data_type_naive(&value_dtype)?, + value_dtype.is_nullable(), + ); + let entries = Field::new_struct("entries", Fields::from(vec![key, value]), false); + DataType::Map(FieldRef::new(entries), map_dtype.keys_sorted()) + } DType::Struct(struct_dtype, _) => { let mut fields = Vec::with_capacity(struct_dtype.names().len()); for (field_name, field_dt) in struct_dtype.names().iter().zip(struct_dtype.fields()) { @@ -638,6 +680,92 @@ mod test { assert_eq!(original_dtype, roundtripped_dtype); } + #[test] + fn map_dtype_roundtrip_uses_conventional_export_names_and_positional_import() -> VortexResult<()> + { + let dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::Nullable, + )?; + + let arrow = dtype.to_arrow_dtype()?; + let DataType::Map(entries, keys_sorted) = &arrow else { + panic!("expected Map, got {arrow:?}"); + }; + assert!(*keys_sorted); + assert_eq!(entries.name(), "entries"); + assert!(!entries.is_nullable()); + let DataType::Struct(fields) = entries.data_type() else { + panic!("expected map entries to be a struct"); + }; + assert_eq!(fields[0].name(), "key"); + assert!(!fields[0].is_nullable()); + assert_eq!(fields[1].name(), "value"); + assert!(fields[1].is_nullable()); + assert_eq!( + DType::try_from_arrow((&arrow, Nullability::Nullable))?, + dtype + ); + + let positional = DataType::Map( + Arc::new(Field::new_struct( + "anything", + Fields::from(vec![ + Field::new("first", DataType::Int32, false), + Field::new("second", DataType::Utf8, true), + ]), + false, + )), + false, + ); + assert_eq!( + DType::try_from_arrow((&positional, Nullability::NonNullable))?, + DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + false, + Nullability::NonNullable, + )? + ); + + Ok(()) + } + + #[test] + fn map_dtype_import_rejects_invalid_arrow_shape() { + let invalid_entries = [ + Field::new_struct( + "entries", + Fields::from(vec![ + Field::new("key", DataType::Int32, false), + Field::new("value", DataType::Utf8, true), + ]), + true, + ), + Field::new("entries", DataType::Int32, false), + Field::new_struct( + "entries", + Fields::from(vec![Field::new("key", DataType::Int32, false)]), + false, + ), + Field::new_struct( + "entries", + Fields::from(vec![ + Field::new("key", DataType::Int32, true), + Field::new("value", DataType::Utf8, true), + ]), + false, + ), + ]; + + for entries in invalid_entries { + let data_type = DataType::Map(Arc::new(entries), false); + assert!(DType::try_from_arrow((&data_type, Nullability::NonNullable)).is_err()); + } + } + // Regression test for https://github.com/vortex-data/vortex/issues/8346: unsupported Arrow // types must return an error instead of panicking with `unimplemented!`. #[rstest] diff --git a/vortex-arrow/src/executor/mod.rs b/vortex-arrow/src/executor/mod.rs index 875577788b4..520f7a7a3a5 100644 --- a/vortex-arrow/src/executor/mod.rs +++ b/vortex-arrow/src/executor/mod.rs @@ -191,8 +191,8 @@ pub(crate) fn execute_arrow_naive( dt @ (DataType::Date32 | DataType::Date64) => to_arrow_date(array, dt, ctx), dt @ (DataType::Time32(_) | DataType::Time64(_)) => to_arrow_time(array, dt, ctx), dt @ DataType::Timestamp(..) => to_arrow_timestamp(array, dt, ctx), + DataType::Map(..) => vortex_bail!("Arrow MapArray conversion is not yet supported"), DataType::FixedSizeBinary(_) - | DataType::Map(..) | DataType::Duration(_) | DataType::Interval(_) | DataType::Union(..) => { diff --git a/vortex-arrow/src/scalar.rs b/vortex-arrow/src/scalar.rs index aeac56f43d3..1b8f2c01ed1 100644 --- a/vortex-arrow/src/scalar.rs +++ b/vortex-arrow/src/scalar.rs @@ -7,6 +7,10 @@ use std::sync::Arc; use arrow_array::Scalar as ArrowScalar; use arrow_array::*; +use arrow_buffer::NullBuffer; +use arrow_buffer::OffsetBuffer; +use arrow_schema::Field; +use arrow_schema::Fields; use vortex_array::dtype::DType; use vortex_array::dtype::PType; use vortex_array::extension::datetime::AnyTemporal; @@ -17,6 +21,7 @@ use vortex_array::scalar::BoolScalar; use vortex_array::scalar::DecimalScalar; use vortex_array::scalar::DecimalValue; use vortex_array::scalar::ExtScalar; +use vortex_array::scalar::MapScalar; use vortex_array::scalar::PrimitiveScalar; use vortex_array::scalar::Scalar; use vortex_array::scalar::Utf8Scalar; @@ -24,6 +29,8 @@ use vortex_error::VortexError; use vortex_error::vortex_bail; use vortex_error::vortex_err; +use crate::dtype::to_data_type_naive; + /// Arrow represents scalars as single-element arrays. This constant is the length of those arrays. const SCALAR_ARRAY_LEN: usize = 1; @@ -70,6 +77,7 @@ impl ToArrowDatum for Scalar { DType::Binary(_) => binary_to_arrow(value.as_binary()), DType::List(..) => unimplemented!("list scalar conversion"), DType::FixedSizeList(..) => unimplemented!("fixed-size list scalar conversion"), + DType::Map(..) => map_to_arrow(value.as_map()), DType::Struct(..) => unimplemented!("struct scalar conversion"), DType::Union(..) => unimplemented!("union scalar conversion"), DType::Variant(_) => unimplemented!("Variant scalar conversion"), @@ -126,6 +134,69 @@ fn binary_to_arrow(scalar: BinaryScalar<'_>) -> Result, VortexErr value_to_arrow_scalar!(scalar.value(), BinaryViewArray) } +/// Convert a [`MapScalar`] to an Arrow [`Datum`]. +fn map_to_arrow(scalar: MapScalar<'_>) -> Result, VortexError> { + let map_dtype = scalar.map_dtype(); + let key_dtype = map_dtype.key_dtype(); + let value_dtype = map_dtype.value_dtype(); + let key_field = Field::new("key", to_data_type_naive(&key_dtype)?, false); + let value_field = Field::new( + "value", + to_data_type_naive(&value_dtype)?, + value_dtype.is_nullable(), + ); + let fields = Fields::from(vec![key_field, value_field]); + + let entries = scalar.entries().collect::>(); + let keys = entries + .iter() + .map(|(key, _)| key.to_arrow_datum()) + .collect::, _>>()?; + let values = entries + .iter() + .map(|(_, value)| value.to_arrow_datum()) + .collect::, _>>()?; + + let key_array = concat_scalar_arrays(&keys, &key_dtype)?; + let value_array = concat_scalar_arrays(&values, &value_dtype)?; + let entries = StructArray::new(fields.clone(), vec![key_array, value_array], None); + + let entries_len = entries.len(); + let entries_len = i32::try_from(entries_len).map_err(|_| { + vortex_err!( + "Cannot convert map scalar with {entries_len} entries to Arrow: MapArray offsets are i32" + ) + })?; + let offsets = OffsetBuffer::new(vec![0_i32, entries_len].into()); + let entries_field = Arc::new(Field::new_struct("entries", fields, false)); + let nulls = scalar + .is_null() + .then(|| NullBuffer::new_null(SCALAR_ARRAY_LEN)); + let map = MapArray::try_new( + entries_field, + offsets, + entries, + nulls, + map_dtype.keys_sorted(), + )?; + Ok(Arc::new(ArrowScalar::new(map))) +} + +fn concat_scalar_arrays( + scalars: &[Arc], + dtype: &DType, +) -> Result { + if scalars.is_empty() { + return Ok(new_empty_array(&to_data_type_naive(dtype)?)); + } + + let arrays = scalars + .iter() + .map(|scalar| scalar.get().0) + .collect::>(); + Ok(arrow_select::concat::concat(&arrays)?) +} + /// Convert an [`ExtScalar`] to an Arrow [`Datum`]. /// /// Currently only temporal extension types (timestamps, dates, and times) are supported. @@ -199,6 +270,10 @@ fn extension_to_arrow(scalar: ExtScalar<'_>) -> Result, VortexErr mod tests { use std::sync::Arc; + use arrow_array::Array; + use arrow_array::Int32Array; + use arrow_array::MapArray; + use arrow_array::StringViewArray; use rstest::rstest; use vortex_array::dtype::DType; use vortex_array::dtype::DecimalDType; @@ -419,6 +494,57 @@ mod tests { assert!(result.is_ok()); } + #[test] + fn test_map_scalar_to_arrow() -> VortexResult<()> { + let dtype = DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::Nullable, + )?; + let scalar = Scalar::try_map( + dtype, + [ + ( + Scalar::primitive(1i32, Nullability::NonNullable), + Scalar::utf8("one", Nullability::Nullable), + ), + ( + Scalar::primitive(2i32, Nullability::NonNullable), + Scalar::null(DType::Utf8(Nullability::Nullable)), + ), + ], + )?; + + let datum = scalar.to_arrow_datum()?; + let (array, is_scalar) = datum.get(); + assert!(is_scalar); + let map = array + .as_any() + .downcast_ref::() + .expect("map scalar should convert to MapArray"); + assert_eq!(map.len(), 1); + assert_eq!(map.value_offsets(), &[0, 2]); + assert!(map.is_valid(0)); + assert_eq!( + map.keys() + .as_any() + .downcast_ref::() + .expect("map key array should be Int32") + .values(), + &[1, 2] + ); + let values = map + .values() + .as_any() + .downcast_ref::() + .expect("map value array should be StringView"); + assert_eq!(values.value(0), "one"); + assert!(values.is_null(1)); + + Ok(()) + } + #[test] #[should_panic(expected = "struct scalar conversion")] fn test_struct_scalar_to_arrow_todo() { diff --git a/vortex-arrow/src/session.rs b/vortex-arrow/src/session.rs index 745e8afeb47..6161c3dcbe7 100644 --- a/vortex-arrow/src/session.rs +++ b/vortex-arrow/src/session.rs @@ -240,6 +240,16 @@ impl ArrowSession { nullability.is_nullable(), )) } + DType::Map(map_dtype, nullability) => { + let key = self.to_arrow_field("key", &map_dtype.key_dtype())?; + let value = self.to_arrow_field("value", &map_dtype.value_dtype())?; + let entries = Field::new_struct("entries", Fields::from(vec![key, value]), false); + Ok(Field::new( + name, + DataType::Map(Arc::new(entries), map_dtype.keys_sorted()), + nullability.is_nullable(), + )) + } DType::Struct(fields, nullability) => { let arrow_fields = Fields::from_iter( fields @@ -339,6 +349,32 @@ impl ArrowSession { *size as u32, nullability, ), + DataType::Map(entries, keys_sorted) => { + vortex_ensure!( + !entries.is_nullable(), + "Arrow map entries field must be non-nullable" + ); + let DataType::Struct(fields) = entries.data_type() else { + vortex_bail!( + "Arrow map entries field must have Struct type, got {:?}", + entries.data_type() + ); + }; + vortex_ensure!( + fields.len() == 2, + "Arrow map entries struct must contain exactly two fields" + ); + vortex_ensure!( + !fields[0].is_nullable(), + "Arrow map key field must be non-nullable" + ); + DType::map( + self.from_arrow_field(fields[0].as_ref())?, + self.from_arrow_field(fields[1].as_ref())?, + *keys_sorted, + nullability, + )? + } DataType::Struct(fields) => { let entries = fields .iter() @@ -577,6 +613,9 @@ impl ArrowSession { let validity = nulls(list.nulls(), field.is_nullable())?; Ok(ListViewArray::try_new(elements, offsets, sizes, validity)?.into_array()) } + DataType::Map(..) => { + vortex_bail!("Arrow MapArray conversion is not yet supported") + } _ => ArrayRef::from_arrow(array.as_ref(), field.is_nullable()), } } @@ -702,6 +741,40 @@ mod tests { Ok(()) } + #[test] + fn schema_roundtrip_preserves_map_uuid_fields() -> VortexResult<()> { + let session = ArrowSession::default(); + let map = DType::map( + uuid_dtype(false), + uuid_dtype(true), + true, + Nullability::Nullable, + )?; + let dtype = DType::Struct( + StructFields::from_iter([(FieldName::from("ids"), map)]), + Nullability::NonNullable, + ); + + let schema = session.to_arrow_schema(&dtype)?; + let field = schema.field(0); + let DataType::Map(entries, keys_sorted) = field.data_type() else { + panic!("expected Map, got {:?}", field.data_type()); + }; + assert!(*keys_sorted); + assert_eq!(entries.name(), "entries"); + assert!(!entries.is_nullable()); + let DataType::Struct(fields) = entries.data_type() else { + panic!("expected map entries struct, got {:?}", entries.data_type()); + }; + assert!(has_valid_extension_type::(&fields[0])); + assert!(has_valid_extension_type::(&fields[1])); + assert!(!fields[0].is_nullable()); + assert!(fields[1].is_nullable()); + + assert_eq!(session.from_arrow_schema(&schema)?, dtype); + Ok(()) + } + #[test] fn to_arrow_schema_struct_of_struct_uuid() -> VortexResult<()> { let session = ArrowSession::default(); diff --git a/vortex-datafusion/src/convert/scalars.rs b/vortex-datafusion/src/convert/scalars.rs index e72a1f9ace3..f159411286d 100644 --- a/vortex-datafusion/src/convert/scalars.rs +++ b/vortex-datafusion/src/convert/scalars.rs @@ -125,6 +125,9 @@ impl TryToDataFusion for Scalar { dtype @ DType::FixedSizeList(..) => vortex_bail!( "cannot convert Vortex scalar dtype {dtype} to DataFusion ScalarValue: unsupported scalar type" ), + dtype @ DType::Map(..) => vortex_bail!( + "cannot convert Vortex scalar dtype {dtype} to DataFusion ScalarValue: unsupported scalar type" + ), DType::Struct(..) => struct_to_df(self)?, dtype @ DType::Union(..) => vortex_bail!( "cannot convert Vortex scalar dtype {dtype} to DataFusion ScalarValue: unsupported scalar type" diff --git a/vortex-datafusion/src/convert/schema.rs b/vortex-datafusion/src/convert/schema.rs index 2ec17758593..08f4ebdb658 100644 --- a/vortex-datafusion/src/convert/schema.rs +++ b/vortex-datafusion/src/convert/schema.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use std::sync::Arc; + use arrow_schema::DataType; use arrow_schema::Field; use arrow_schema::Schema; @@ -175,6 +177,52 @@ fn calculate_physical_field_type( } } + // Map field names and child metadata come from the reference schema, while child + // types are recursively reconciled so nested extension metadata is preserved. + DataType::Map(logical_entries, keys_sorted) => { + let DType::Map(map_dtype, _) = dtype else { + return Err(exec_datafusion_err!( + "Failed to convert dtype to arrow: Vortex DType is {dtype} which is not compatible with {logical_type}" + )); + }; + let DataType::Struct(logical_fields) = logical_entries.data_type() else { + return Err(exec_datafusion_err!( + "Failed to convert dtype to arrow: Arrow Map entries must be a Struct, got {:?}", + logical_entries.data_type() + )); + }; + if logical_fields.len() != 2 { + return Err(exec_datafusion_err!( + "Failed to convert dtype to arrow: Arrow Map entries must contain exactly two fields" + )); + } + + let key = Field::new( + logical_fields[0].name(), + calculate_physical_field_type( + &map_dtype.key_dtype(), + logical_fields[0].data_type(), + arrow_session, + )?, + false, + ) + .with_metadata(logical_fields[0].metadata().clone()); + let value = Field::new( + logical_fields[1].name(), + calculate_physical_field_type( + &map_dtype.value_dtype(), + logical_fields[1].data_type(), + arrow_session, + )?, + logical_fields[1].is_nullable(), + ) + .with_metadata(logical_fields[1].metadata().clone()); + let entries = Field::new_struct(logical_entries.name(), vec![key, value], false) + .with_metadata(logical_entries.metadata().clone()); + + DataType::Map(Arc::new(entries), *keys_sorted) + } + // For list view types, recursively check the element type DataType::ListView(logical_elem) | DataType::LargeListView(logical_elem) => { if let DType::List(elem_dtype, _) = dtype { @@ -409,6 +457,65 @@ mod tests { } } + #[test] + fn test_map_schema_conversion_preserves_reference_fields() { + let key = Field::new("custom_key", DataType::Int32, false) + .with_metadata([("key_metadata".to_owned(), "key_value".to_owned())].into()); + let value = Field::new("custom_value", DataType::Utf8, true) + .with_metadata([("value_metadata".to_owned(), "value_value".to_owned())].into()); + let entries = Field::new_struct("custom_entries", vec![key, value], false) + .with_metadata([("entries_metadata".to_owned(), "entries_value".to_owned())].into()); + let logical_schema = Schema::new(vec![Field::new( + "map_col", + DataType::Map(Arc::new(entries), true), + true, + )]); + let dtype = DType::Struct( + StructFields::from_iter([( + "map_col", + DType::map( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + Nullability::Nullable, + ) + .unwrap(), + )]), + Nullability::NonNullable, + ); + + let physical_schema = + calculate_physical_schema(&dtype, &logical_schema, &ArrowSession::default()).unwrap(); + let field = physical_schema.field(0); + assert!(field.is_nullable()); + let DataType::Map(entries, keys_sorted) = field.data_type() else { + panic!("expected Map type, got {:?}", field.data_type()); + }; + assert!(*keys_sorted); + assert_eq!(entries.name(), "custom_entries"); + assert_eq!( + entries.metadata().get("entries_metadata"), + Some(&"entries_value".to_owned()) + ); + let DataType::Struct(fields) = entries.data_type() else { + panic!("expected map entries struct, got {:?}", entries.data_type()); + }; + assert_eq!(fields[0].name(), "custom_key"); + assert_eq!(fields[0].data_type(), &DataType::Int32); + assert!(!fields[0].is_nullable()); + assert_eq!( + fields[0].metadata().get("key_metadata"), + Some(&"key_value".to_owned()) + ); + assert_eq!(fields[1].name(), "custom_value"); + assert_eq!(fields[1].data_type(), &DataType::Utf8); + assert!(fields[1].is_nullable()); + assert_eq!( + fields[1].metadata().get("value_metadata"), + Some(&"value_value".to_owned()) + ); + } + #[test] fn test_non_struct_dtype_error() { // Test that non-struct DType produces an error diff --git a/vortex-duckdb/src/convert/dtype.rs b/vortex-duckdb/src/convert/dtype.rs index 138a6f1bc69..85e6ba3af22 100644 --- a/vortex-duckdb/src/convert/dtype.rs +++ b/vortex-duckdb/src/convert/dtype.rs @@ -24,6 +24,7 @@ //! | `Struct` | `STRUCT` | //! | `Decimal` | `DECIMAL` | //! | `List` | `LIST` | +//! | `Map` | `MAP` | //! | `Date` | `DATE` | //! | `Time` | `TIME` | //! | `Timestamp` | `TIMESTAMP` | @@ -155,6 +156,12 @@ impl FromLogicalType for DType { nullability, ) } + DUCKDB_TYPE::DUCKDB_TYPE_MAP => DType::map( + DType::from_logical_type(&logical_type.map_key_type(), Nullability::NonNullable)?, + DType::from_logical_type(&logical_type.map_value_type(), Nullability::Nullable)?, + false, + nullability, + )?, DUCKDB_TYPE::DUCKDB_TYPE_STRUCT => DType::Struct( (0..logical_type.struct_type_child_count()) .map(|i| { @@ -182,7 +189,6 @@ impl FromLogicalType for DType { other @ (DUCKDB_TYPE::DUCKDB_TYPE_TIME_TZ | DUCKDB_TYPE::DUCKDB_TYPE_INTERVAL | DUCKDB_TYPE::DUCKDB_TYPE_ENUM - | DUCKDB_TYPE::DUCKDB_TYPE_MAP | DUCKDB_TYPE::DUCKDB_TYPE_UUID | DUCKDB_TYPE::DUCKDB_TYPE_UNION | DUCKDB_TYPE::DUCKDB_TYPE_BIT @@ -240,6 +246,12 @@ impl TryFrom<&DType> for LogicalType { let element_logical_type = LogicalType::try_from(element_dtype.as_ref())?; return LogicalType::array_type(element_logical_type, *list_size); } + DType::Map(map_dtype, _) => { + return LogicalType::map_type( + LogicalType::try_from(&map_dtype.key_dtype())?, + LogicalType::try_from(&map_dtype.value_dtype())?, + ); + } DType::Struct(struct_type, _) => { return LogicalType::try_from(struct_type); } @@ -514,6 +526,31 @@ mod tests { ); } + #[test] + fn test_map_type_roundtrip() -> VortexResult<()> { + let key = DType::Primitive(PType::I32, Nullability::NonNullable); + let value = DType::Utf8(Nullability::Nullable); + let dtype = DType::map(key.clone(), value.clone(), true, Nullability::Nullable)?; + + let logical_type = LogicalType::try_from(&dtype)?; + assert_eq!(logical_type.as_type_id(), cpp::DUCKDB_TYPE::DUCKDB_TYPE_MAP); + assert_eq!( + logical_type.map_key_type().as_type_id(), + cpp::DUCKDB_TYPE::DUCKDB_TYPE_INTEGER + ); + assert_eq!( + logical_type.map_value_type().as_type_id(), + cpp::DUCKDB_TYPE::DUCKDB_TYPE_VARCHAR + ); + + assert_eq!( + DType::from_logical_type(&logical_type, Nullability::Nullable)?, + DType::map(key, value, false, Nullability::Nullable)? + ); + + Ok(()) + } + #[test] fn test_date_extension_type() { use vortex::extension::datetime::TimeUnit; diff --git a/vortex-duckdb/src/convert/scalar.rs b/vortex-duckdb/src/convert/scalar.rs index 7ad12e89ca3..c9cc6100a1d 100644 --- a/vortex-duckdb/src/convert/scalar.rs +++ b/vortex-duckdb/src/convert/scalar.rs @@ -82,6 +82,7 @@ impl ToDuckDBScalar for Scalar { DType::FixedSizeList(..) => { vortex_bail!("Vortex FixedSizeList scalars aren't supported") } + DType::Map(..) => vortex_bail!("Vortex Map scalars aren't supported"), DType::Variant(_) => vortex_bail!("Vortex Variant scalars aren't supported"), DType::Struct(..) => vortex_bail!("Vortex Struct scalars aren't supported"), // TODO(connor): Union diff --git a/vortex-duckdb/src/duckdb/logical_type.rs b/vortex-duckdb/src/duckdb/logical_type.rs index 28c17cbcf02..4b98c17dfd3 100644 --- a/vortex-duckdb/src/duckdb/logical_type.rs +++ b/vortex-duckdb/src/duckdb/logical_type.rs @@ -16,6 +16,7 @@ use crate::cpp::duckdb_create_array_type; use crate::cpp::duckdb_create_decimal_type; use crate::cpp::duckdb_create_list_type; use crate::cpp::duckdb_create_logical_type; +use crate::cpp::duckdb_create_map_type; use crate::cpp::duckdb_create_struct_type; use crate::cpp::duckdb_decimal_scale; use crate::cpp::duckdb_decimal_width; @@ -114,6 +115,17 @@ impl LogicalType { Ok(unsafe { Self::own(ptr) }) } + /// Creates a DuckDB map logical type from its key and value types. + pub fn map_type(key_type: LogicalType, value_type: LogicalType) -> VortexResult { + let ptr = unsafe { duckdb_create_map_type(key_type.as_ptr(), value_type.as_ptr()) }; + + if ptr.is_null() { + vortex_bail!("Failed to create map logical type"); + } + + Ok(unsafe { Self::own(ptr) }) + } + /// Creates a DuckDB fixed-size list logical type with the specified element type and list size. /// /// Note that DuckDB calls what we call a fixed-size list the ARRAY type. diff --git a/vortex-ffi/cinclude/vortex.h b/vortex-ffi/cinclude/vortex.h index 1c2caa6fad8..b0c8ddfa96a 100644 --- a/vortex-ffi/cinclude/vortex.h +++ b/vortex-ffi/cinclude/vortex.h @@ -111,6 +111,10 @@ typedef enum { * Nested fixed-size list type. */ DTYPE_FIXED_SIZE_LIST = 9, + /** + * Nested map type. + */ + DTYPE_MAP = 10, } vx_dtype_variant; /** @@ -1075,6 +1079,23 @@ const vx_dtype *vx_dtype_fixed_size_list_element(const vx_dtype *dtype); */ uint32_t vx_dtype_fixed_size_list_size(const vx_dtype *dtype); +/** + * If "dtype" is DTYPE_MAP, return its owned key dtype, return NULL otherwise. + * Returned dtype must be released with vx_dtype_free. + */ +const vx_dtype *vx_dtype_map_key_type(const vx_dtype *dtype); + +/** + * If "dtype" is DTYPE_MAP, return its owned value dtype, return NULL otherwise. + * Returned dtype must be released with vx_dtype_free. + */ +const vx_dtype *vx_dtype_map_value_type(const vx_dtype *dtype); + +/** + * Returns whether "dtype" is a map that asserts sorted keys. + */ +bool vx_dtype_map_keys_sorted(const vx_dtype *dtype); + /** * Checks if the type is time. */ diff --git a/vortex-ffi/src/dtype.rs b/vortex-ffi/src/dtype.rs index d38a8c62ec8..25ca947b006 100644 --- a/vortex-ffi/src/dtype.rs +++ b/vortex-ffi/src/dtype.rs @@ -62,6 +62,8 @@ pub enum vx_dtype_variant { DTYPE_DECIMAL = 8, /// Nested fixed-size list type. DTYPE_FIXED_SIZE_LIST = 9, + /// Nested map type. + DTYPE_MAP = 10, } // TODO(connor)[Union]: Do we need to add union and variant here? @@ -76,6 +78,7 @@ impl From<&DType> for vx_dtype_variant { DType::Binary(_) => vx_dtype_variant::DTYPE_BINARY, DType::List(..) => vx_dtype_variant::DTYPE_LIST, DType::FixedSizeList(..) => vx_dtype_variant::DTYPE_FIXED_SIZE_LIST, + DType::Map(..) => vx_dtype_variant::DTYPE_MAP, DType::Struct(..) => vx_dtype_variant::DTYPE_STRUCT, DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => vortex_panic!("Variant DType is not supported in FFI yet"), @@ -254,6 +257,36 @@ pub unsafe extern "C-unwind" fn vx_dtype_fixed_size_list_size(dtype: *const vx_d } } +/// If `dtype` is `DTYPE_MAP`, return its owned key dtype. Otherwise return `NULL`. +/// +/// Returned dtypes must be released with [`vx_dtype_free`]. +#[unsafe(no_mangle)] +pub unsafe extern "C-unwind" fn vx_dtype_map_key_type(dtype: *const vx_dtype) -> *const vx_dtype { + let Some(map_dtype) = vx_dtype::as_ref(dtype).as_map_opt() else { + return ptr::null(); + }; + vx_dtype::new(Arc::new(map_dtype.key_dtype())) +} + +/// If `dtype` is `DTYPE_MAP`, return its owned value dtype. Otherwise return `NULL`. +/// +/// Returned dtypes must be released with [`vx_dtype_free`]. +#[unsafe(no_mangle)] +pub unsafe extern "C-unwind" fn vx_dtype_map_value_type(dtype: *const vx_dtype) -> *const vx_dtype { + let Some(map_dtype) = vx_dtype::as_ref(dtype).as_map_opt() else { + return ptr::null(); + }; + vx_dtype::new(Arc::new(map_dtype.value_dtype())) +} + +/// Returns whether `dtype` is a map that asserts sorted keys. +#[unsafe(no_mangle)] +pub unsafe extern "C-unwind" fn vx_dtype_map_keys_sorted(dtype: *const vx_dtype) -> bool { + vx_dtype::as_ref(dtype) + .as_map_opt() + .is_some_and(|map_dtype| map_dtype.keys_sorted()) +} + /// Checks if the type is time. #[unsafe(no_mangle)] pub unsafe extern "C-unwind" fn vx_dtype_is_time(dtype: *const DType) -> bool { @@ -570,6 +603,44 @@ mod tests { } } + #[test] + fn test_map_introspection() { + unsafe { + let map_dtype = vx_dtype::new(Arc::new( + DType::map( + DType::Primitive(vortex::dtype::PType::I32, false.into()), + DType::Utf8(true.into()), + true, + true.into(), + ) + .unwrap(), + )); + + assert_eq!(vx_dtype_get_variant(map_dtype), vx_dtype_variant::DTYPE_MAP); + assert!(vx_dtype_is_nullable(map_dtype)); + assert!(vx_dtype_map_keys_sorted(map_dtype)); + + let key = vx_dtype_map_key_type(map_dtype); + assert_eq!(vx_dtype_get_variant(key), vx_dtype_variant::DTYPE_PRIMITIVE); + assert_eq!(vx_dtype_primitive_ptype(key), vx_ptype::PTYPE_I32); + assert!(!vx_dtype_is_nullable(key)); + + let value = vx_dtype_map_value_type(map_dtype); + assert_eq!(vx_dtype_get_variant(value), vx_dtype_variant::DTYPE_UTF8); + assert!(vx_dtype_is_nullable(value)); + + let non_map = vx_dtype_new_bool(false); + assert!(vx_dtype_map_key_type(non_map).is_null()); + assert!(vx_dtype_map_value_type(non_map).is_null()); + assert!(!vx_dtype_map_keys_sorted(non_map)); + + vx_dtype_free(non_map); + vx_dtype_free(value); + vx_dtype_free(key); + vx_dtype_free(map_dtype); + } + } + #[test] fn test_nested_fixed_size_lists() { unsafe { @@ -661,6 +732,13 @@ mod tests { 4, true.into(), ), + DType::map( + DType::Primitive(vortex::dtype::PType::I32, false.into()), + DType::Utf8(true.into()), + true, + true.into(), + ) + .unwrap(), ]; for dtype in dtypes { @@ -675,6 +753,7 @@ mod tests { DType::FixedSizeList(..) => { assert_eq!(variant, vx_dtype_variant::DTYPE_FIXED_SIZE_LIST) } + DType::Map(..) => assert_eq!(variant, vx_dtype_variant::DTYPE_MAP), _ => {} } } diff --git a/vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs b/vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs index add1ae63e2e..270de4f6b73 100644 --- a/vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs +++ b/vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs @@ -73,6 +73,13 @@ table Union { type_ids: [byte]; // length must equal dtypes.len() } +table Map { + key_type: DType; + value_type: DType; + keys_sorted: bool; + nullable: bool; +} + union Type { Null = 1, Bool = 2, @@ -86,6 +93,7 @@ union Type { FixedSizeList = 10, // This is after `Extension` for backwards compatibility. Variant = 11, Union = 12, + Map = 13, } table DType { diff --git a/vortex-flatbuffers/src/generated/array.rs b/vortex-flatbuffers/src/generated/array.rs index 6d903a56aa5..78471c013c4 100644 --- a/vortex-flatbuffers/src/generated/array.rs +++ b/vortex-flatbuffers/src/generated/array.rs @@ -1,7 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify + + // @generated -extern crate alloc; +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_COMPRESSION: u8 = 0; @@ -38,8 +44,8 @@ impl Compression { } } } -impl ::core::fmt::Debug for Compression { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for Compression { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -47,24 +53,24 @@ impl ::core::fmt::Debug for Compression { } } } -impl<'a> ::flatbuffers::Follow<'a> for Compression { +impl<'a> flatbuffers::Follow<'a> for Compression { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for Compression { +impl flatbuffers::Push for Compression { type Output = Compression; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for Compression { +impl flatbuffers::EndianScalar for Compression { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -78,16 +84,17 @@ impl ::flatbuffers::EndianScalar for Compression { } } -impl<'a> ::flatbuffers::Verifiable for Compression { +impl<'a> flatbuffers::Verifiable for Compression { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for Compression {} +impl flatbuffers::SimpleToVerifyInSlice for Compression {} #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_PRECISION: u8 = 0; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] @@ -122,8 +129,8 @@ impl Precision { } } } -impl ::core::fmt::Debug for Precision { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for Precision { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -131,24 +138,24 @@ impl ::core::fmt::Debug for Precision { } } } -impl<'a> ::flatbuffers::Follow<'a> for Precision { +impl<'a> flatbuffers::Follow<'a> for Precision { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for Precision { +impl flatbuffers::Push for Precision { type Output = Precision; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for Precision { +impl flatbuffers::EndianScalar for Precision { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -162,16 +169,17 @@ impl ::flatbuffers::EndianScalar for Precision { } } -impl<'a> ::flatbuffers::Verifiable for Precision { +impl<'a> flatbuffers::Verifiable for Precision { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for Precision {} +impl flatbuffers::SimpleToVerifyInSlice for Precision {} /// A Buffer describes the location of a data buffer in the byte stream as a packed 64-bit struct. // struct Buffer, aligned to 4 #[repr(transparent)] @@ -182,8 +190,8 @@ impl Default for Buffer { Self([0; 8]) } } -impl ::core::fmt::Debug for Buffer { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for Buffer { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("Buffer") .field("padding", &self.padding()) .field("alignment_exponent", &self.alignment_exponent()) @@ -193,39 +201,40 @@ impl ::core::fmt::Debug for Buffer { } } -impl ::flatbuffers::SimpleToVerifyInSlice for Buffer {} -impl<'a> ::flatbuffers::Follow<'a> for Buffer { +impl flatbuffers::SimpleToVerifyInSlice for Buffer {} +impl<'a> flatbuffers::Follow<'a> for Buffer { type Inner = &'a Buffer; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { unsafe { <&'a Buffer>::follow(buf, loc) } } } -impl<'a> ::flatbuffers::Follow<'a> for &'a Buffer { +impl<'a> flatbuffers::Follow<'a> for &'a Buffer { type Inner = &'a Buffer; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { ::flatbuffers::follow_cast_ref::(buf, loc) } + unsafe { flatbuffers::follow_cast_ref::(buf, loc) } } } -impl<'b> ::flatbuffers::Push for Buffer { +impl<'b> flatbuffers::Push for Buffer { type Output = Buffer; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = unsafe { ::core::slice::from_raw_parts(self as *const Buffer as *const u8, ::size()) }; + let src = unsafe { ::core::slice::from_raw_parts(self as *const Buffer as *const u8, ::size()) }; dst.copy_from_slice(src); } #[inline] - fn alignment() -> ::flatbuffers::PushAlignment { - ::flatbuffers::PushAlignment::new(4) + fn alignment() -> flatbuffers::PushAlignment { + flatbuffers::PushAlignment::new(4) } } -impl<'a> ::flatbuffers::Verifiable for Buffer { +impl<'a> flatbuffers::Verifiable for Buffer { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -248,120 +257,120 @@ impl<'a> Buffer { /// The length of any padding bytes written immediately before the buffer. pub fn padding(&self) -> u16 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[0..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_padding(&mut self, x: u16) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[0..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } /// The minimum alignment of the buffer, stored as an exponent of 2. pub fn alignment_exponent(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[2..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_alignment_exponent(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[2..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } /// The compression algorithm used to compress the buffer. pub fn compression(&self) -> Compression { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[3..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_compression(&mut self, x: Compression) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[3..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } /// The length of the buffer in bytes. pub fn length(&self) -> u32 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[4..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_length(&mut self, x: u32) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[4..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } @@ -374,30 +383,30 @@ pub enum ArrayOffset {} /// An Array describes the hierarchy of an array as well as the locations of the data buffers that appear /// immediately after the message in the byte stream. pub struct Array<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Array<'a> { +impl<'a> flatbuffers::Follow<'a> for Array<'a> { type Inner = Array<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Array<'a> { - pub const VT_ROOT: ::flatbuffers::VOffsetT = 4; - pub const VT_BUFFERS: ::flatbuffers::VOffsetT = 6; + pub const VT_ROOT: flatbuffers::VOffsetT = 4; + pub const VT_BUFFERS: flatbuffers::VOffsetT = 6; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Array { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ArrayArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ArrayBuilder::new(_fbb); if let Some(x) = args.buffers { builder.add_buffers(x); } if let Some(x) = args.root { builder.add_root(x); } @@ -411,33 +420,34 @@ impl<'a> Array<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Array::VT_ROOT, None)} + unsafe { self._tab.get::>(Array::VT_ROOT, None)} } /// The locations of the data buffers of the array #[inline] - pub fn buffers(&self) -> Option<::flatbuffers::Vector<'a, Buffer>> { + pub fn buffers(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Buffer>>>(Array::VT_BUFFERS, None)} + unsafe { self._tab.get::>>(Array::VT_BUFFERS, None)} } } -impl ::flatbuffers::Verifiable for Array<'_> { +impl flatbuffers::Verifiable for Array<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("root", Self::VT_ROOT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Buffer>>>("buffers", Self::VT_BUFFERS, false)? + .visit_field::>("root", Self::VT_ROOT, false)? + .visit_field::>>("buffers", Self::VT_BUFFERS, false)? .finish(); Ok(()) } } pub struct ArrayArgs<'a> { - pub root: Option<::flatbuffers::WIPOffset>>, - pub buffers: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Buffer>>>, + pub root: Option>>, + pub buffers: Option>>, } impl<'a> Default for ArrayArgs<'a> { #[inline] @@ -449,21 +459,21 @@ impl<'a> Default for ArrayArgs<'a> { } } -pub struct ArrayBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ArrayBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayBuilder<'a, 'b, A> { #[inline] - pub fn add_root(&mut self, root: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Array::VT_ROOT, root); + pub fn add_root(&mut self, root: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Array::VT_ROOT, root); } #[inline] - pub fn add_buffers(&mut self, buffers: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Buffer>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Array::VT_BUFFERS, buffers); + pub fn add_buffers(&mut self, buffers: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Array::VT_BUFFERS, buffers); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArrayBuilder { fbb_: _fbb, @@ -471,14 +481,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Array<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Array<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Array"); ds.field("root", &self.root()); ds.field("buffers", &self.buffers()); @@ -489,33 +499,33 @@ pub enum ArrayNodeOffset {} #[derive(Copy, Clone, PartialEq)] pub struct ArrayNode<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for ArrayNode<'a> { +impl<'a> flatbuffers::Follow<'a> for ArrayNode<'a> { type Inner = ArrayNode<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> ArrayNode<'a> { - pub const VT_ENCODING: ::flatbuffers::VOffsetT = 4; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 6; - pub const VT_CHILDREN: ::flatbuffers::VOffsetT = 8; - pub const VT_BUFFERS: ::flatbuffers::VOffsetT = 10; - pub const VT_STATS: ::flatbuffers::VOffsetT = 12; + pub const VT_ENCODING: flatbuffers::VOffsetT = 4; + pub const VT_METADATA: flatbuffers::VOffsetT = 6; + pub const VT_CHILDREN: flatbuffers::VOffsetT = 8; + pub const VT_BUFFERS: flatbuffers::VOffsetT = 10; + pub const VT_STATS: flatbuffers::VOffsetT = 12; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { ArrayNode { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ArrayNodeArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ArrayNodeBuilder::new(_fbb); if let Some(x) = args.stats { builder.add_stats(x); } if let Some(x) = args.buffers { builder.add_buffers(x); } @@ -534,56 +544,57 @@ impl<'a> ArrayNode<'a> { unsafe { self._tab.get::(ArrayNode::VT_ENCODING, Some(0)).unwrap()} } #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn metadata(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayNode::VT_METADATA, None)} + unsafe { self._tab.get::>>(ArrayNode::VT_METADATA, None)} } #[inline] - pub fn children(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn children(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(ArrayNode::VT_CHILDREN, None)} + unsafe { self._tab.get::>>>(ArrayNode::VT_CHILDREN, None)} } #[inline] - pub fn buffers(&self) -> Option<::flatbuffers::Vector<'a, u16>> { + pub fn buffers(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u16>>>(ArrayNode::VT_BUFFERS, None)} + unsafe { self._tab.get::>>(ArrayNode::VT_BUFFERS, None)} } #[inline] pub fn stats(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(ArrayNode::VT_STATS, None)} + unsafe { self._tab.get::>(ArrayNode::VT_STATS, None)} } } -impl ::flatbuffers::Verifiable for ArrayNode<'_> { +impl flatbuffers::Verifiable for ArrayNode<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("encoding", Self::VT_ENCODING, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("children", Self::VT_CHILDREN, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u16>>>("buffers", Self::VT_BUFFERS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("stats", Self::VT_STATS, false)? + .visit_field::>>("metadata", Self::VT_METADATA, false)? + .visit_field::>>>("children", Self::VT_CHILDREN, false)? + .visit_field::>>("buffers", Self::VT_BUFFERS, false)? + .visit_field::>("stats", Self::VT_STATS, false)? .finish(); Ok(()) } } pub struct ArrayNodeArgs<'a> { pub encoding: u16, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub children: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub buffers: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u16>>>, - pub stats: Option<::flatbuffers::WIPOffset>>, + pub metadata: Option>>, + pub children: Option>>>>, + pub buffers: Option>>, + pub stats: Option>>, } impl<'a> Default for ArrayNodeArgs<'a> { #[inline] @@ -598,33 +609,33 @@ impl<'a> Default for ArrayNodeArgs<'a> { } } -pub struct ArrayNodeBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ArrayNodeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayNodeBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayNodeBuilder<'a, 'b, A> { #[inline] pub fn add_encoding(&mut self, encoding: u16) { self.fbb_.push_slot::(ArrayNode::VT_ENCODING, encoding, 0); } #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_METADATA, metadata); + pub fn add_metadata(&mut self, metadata: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayNode::VT_METADATA, metadata); } #[inline] - pub fn add_children(&mut self, children: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_CHILDREN, children); + pub fn add_children(&mut self, children: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(ArrayNode::VT_CHILDREN, children); } #[inline] - pub fn add_buffers(&mut self, buffers: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u16>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_BUFFERS, buffers); + pub fn add_buffers(&mut self, buffers: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayNode::VT_BUFFERS, buffers); } #[inline] - pub fn add_stats(&mut self, stats: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(ArrayNode::VT_STATS, stats); + pub fn add_stats(&mut self, stats: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayNode::VT_STATS, stats); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayNodeBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayNodeBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArrayNodeBuilder { fbb_: _fbb, @@ -632,14 +643,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayNodeBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for ArrayNode<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for ArrayNode<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("ArrayNode"); ds.field("encoding", &self.encoding()); ds.field("metadata", &self.metadata()); @@ -653,39 +664,39 @@ pub enum ArrayStatsOffset {} #[derive(Copy, Clone, PartialEq)] pub struct ArrayStats<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for ArrayStats<'a> { +impl<'a> flatbuffers::Follow<'a> for ArrayStats<'a> { type Inner = ArrayStats<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> ArrayStats<'a> { - pub const VT_MIN: ::flatbuffers::VOffsetT = 4; - pub const VT_MIN_PRECISION: ::flatbuffers::VOffsetT = 6; - pub const VT_MAX: ::flatbuffers::VOffsetT = 8; - pub const VT_MAX_PRECISION: ::flatbuffers::VOffsetT = 10; - pub const VT_SUM: ::flatbuffers::VOffsetT = 12; - pub const VT_IS_SORTED: ::flatbuffers::VOffsetT = 14; - pub const VT_IS_STRICT_SORTED: ::flatbuffers::VOffsetT = 16; - pub const VT_IS_CONSTANT: ::flatbuffers::VOffsetT = 18; - pub const VT_NULL_COUNT: ::flatbuffers::VOffsetT = 20; - pub const VT_UNCOMPRESSED_SIZE_IN_BYTES: ::flatbuffers::VOffsetT = 22; - pub const VT_NAN_COUNT: ::flatbuffers::VOffsetT = 24; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub const VT_MIN: flatbuffers::VOffsetT = 4; + pub const VT_MIN_PRECISION: flatbuffers::VOffsetT = 6; + pub const VT_MAX: flatbuffers::VOffsetT = 8; + pub const VT_MAX_PRECISION: flatbuffers::VOffsetT = 10; + pub const VT_SUM: flatbuffers::VOffsetT = 12; + pub const VT_IS_SORTED: flatbuffers::VOffsetT = 14; + pub const VT_IS_STRICT_SORTED: flatbuffers::VOffsetT = 16; + pub const VT_IS_CONSTANT: flatbuffers::VOffsetT = 18; + pub const VT_NULL_COUNT: flatbuffers::VOffsetT = 20; + pub const VT_UNCOMPRESSED_SIZE_IN_BYTES: flatbuffers::VOffsetT = 22; + pub const VT_NAN_COUNT: flatbuffers::VOffsetT = 24; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { ArrayStats { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ArrayStatsArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ArrayStatsBuilder::new(_fbb); if let Some(x) = args.nan_count { builder.add_nan_count(x); } if let Some(x) = args.uncompressed_size_in_bytes { builder.add_uncompressed_size_in_bytes(x); } @@ -704,11 +715,11 @@ impl<'a> ArrayStats<'a> { /// Protobuf serialized ScalarValue #[inline] - pub fn min(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn min(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_MIN, None)} + unsafe { self._tab.get::>>(ArrayStats::VT_MIN, None)} } #[inline] pub fn min_precision(&self) -> Precision { @@ -718,11 +729,11 @@ impl<'a> ArrayStats<'a> { unsafe { self._tab.get::(ArrayStats::VT_MIN_PRECISION, Some(Precision::Inexact)).unwrap()} } #[inline] - pub fn max(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn max(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_MAX, None)} + unsafe { self._tab.get::>>(ArrayStats::VT_MAX, None)} } #[inline] pub fn max_precision(&self) -> Precision { @@ -732,11 +743,11 @@ impl<'a> ArrayStats<'a> { unsafe { self._tab.get::(ArrayStats::VT_MAX_PRECISION, Some(Precision::Inexact)).unwrap()} } #[inline] - pub fn sum(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn sum(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_SUM, None)} + unsafe { self._tab.get::>>(ArrayStats::VT_SUM, None)} } #[inline] pub fn is_sorted(&self) -> Option { @@ -782,17 +793,18 @@ impl<'a> ArrayStats<'a> { } } -impl ::flatbuffers::Verifiable for ArrayStats<'_> { +impl flatbuffers::Verifiable for ArrayStats<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("min", Self::VT_MIN, false)? + .visit_field::>>("min", Self::VT_MIN, false)? .visit_field::("min_precision", Self::VT_MIN_PRECISION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("max", Self::VT_MAX, false)? + .visit_field::>>("max", Self::VT_MAX, false)? .visit_field::("max_precision", Self::VT_MAX_PRECISION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("sum", Self::VT_SUM, false)? + .visit_field::>>("sum", Self::VT_SUM, false)? .visit_field::("is_sorted", Self::VT_IS_SORTED, false)? .visit_field::("is_strict_sorted", Self::VT_IS_STRICT_SORTED, false)? .visit_field::("is_constant", Self::VT_IS_CONSTANT, false)? @@ -804,11 +816,11 @@ impl ::flatbuffers::Verifiable for ArrayStats<'_> { } } pub struct ArrayStatsArgs<'a> { - pub min: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub min: Option>>, pub min_precision: Precision, - pub max: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub max: Option>>, pub max_precision: Precision, - pub sum: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub sum: Option>>, pub is_sorted: Option, pub is_strict_sorted: Option, pub is_constant: Option, @@ -835,30 +847,30 @@ impl<'a> Default for ArrayStatsArgs<'a> { } } -pub struct ArrayStatsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ArrayStatsBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayStatsBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayStatsBuilder<'a, 'b, A> { #[inline] - pub fn add_min(&mut self, min: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_MIN, min); + pub fn add_min(&mut self, min: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayStats::VT_MIN, min); } #[inline] pub fn add_min_precision(&mut self, min_precision: Precision) { self.fbb_.push_slot::(ArrayStats::VT_MIN_PRECISION, min_precision, Precision::Inexact); } #[inline] - pub fn add_max(&mut self, max: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_MAX, max); + pub fn add_max(&mut self, max: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayStats::VT_MAX, max); } #[inline] pub fn add_max_precision(&mut self, max_precision: Precision) { self.fbb_.push_slot::(ArrayStats::VT_MAX_PRECISION, max_precision, Precision::Inexact); } #[inline] - pub fn add_sum(&mut self, sum: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_SUM, sum); + pub fn add_sum(&mut self, sum: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(ArrayStats::VT_SUM, sum); } #[inline] pub fn add_is_sorted(&mut self, is_sorted: bool) { @@ -885,7 +897,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayStatsBuilder<'a, 'b, A> self.fbb_.push_slot_always::(ArrayStats::VT_NAN_COUNT, nan_count); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayStatsBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayStatsBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArrayStatsBuilder { fbb_: _fbb, @@ -893,14 +905,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayStatsBuilder<'a, 'b, A> } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for ArrayStats<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for ArrayStats<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("ArrayStats"); ds.field("min", &self.min()); ds.field("min_precision", &self.min_precision()); @@ -923,8 +935,8 @@ impl ::core::fmt::Debug for ArrayStats<'_> { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_array_unchecked`. -pub fn root_as_array(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) +pub fn root_as_array(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -933,8 +945,8 @@ pub fn root_as_array(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlat /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_array_unchecked`. -pub fn size_prefixed_root_as_array(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_array(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -944,10 +956,10 @@ pub fn size_prefixed_root_as_array(buf: &[u8]) -> Result, ::flatbuffer /// previous, unchecked, behavior use /// `root_as_array_unchecked`. pub fn root_as_array_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -957,33 +969,33 @@ pub fn root_as_array_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_array_unchecked`. pub fn size_prefixed_root_as_array_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Array and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Array`. -pub unsafe fn root_as_array_unchecked(buf: &[u8]) -> Array<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } +pub unsafe fn root_as_array_unchecked(buf: &[u8]) -> Array { + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Array and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Array`. -pub unsafe fn size_prefixed_root_as_array_unchecked(buf: &[u8]) -> Array<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } +pub unsafe fn size_prefixed_root_as_array_unchecked(buf: &[u8]) -> Array { + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] -pub fn finish_array_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { +pub fn finish_array_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_array_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_array_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/vortex-flatbuffers/src/generated/dtype.rs b/vortex-flatbuffers/src/generated/dtype.rs index 953e826da82..bf8c8747b32 100644 --- a/vortex-flatbuffers/src/generated/dtype.rs +++ b/vortex-flatbuffers/src/generated/dtype.rs @@ -1,7 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify + + // @generated -extern crate alloc; +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_PTYPE: u8 = 0; @@ -73,8 +79,8 @@ impl PType { } } } -impl ::core::fmt::Debug for PType { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for PType { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -82,24 +88,24 @@ impl ::core::fmt::Debug for PType { } } } -impl<'a> ::flatbuffers::Follow<'a> for PType { +impl<'a> flatbuffers::Follow<'a> for PType { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for PType { +impl flatbuffers::Push for PType { type Output = PType; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for PType { +impl flatbuffers::EndianScalar for PType { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -113,23 +119,24 @@ impl ::flatbuffers::EndianScalar for PType { } } -impl<'a> ::flatbuffers::Verifiable for PType { +impl<'a> flatbuffers::Verifiable for PType { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for PType {} +impl flatbuffers::SimpleToVerifyInSlice for PType {} #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_TYPE: u8 = 0; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_TYPE: u8 = 12; +pub const ENUM_MAX_TYPE: u8 = 13; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)] -pub const ENUM_VALUES_TYPE: [Type; 13] = [ +pub const ENUM_VALUES_TYPE: [Type; 14] = [ Type::NONE, Type::Null, Type::Bool, @@ -143,6 +150,7 @@ pub const ENUM_VALUES_TYPE: [Type; 13] = [ Type::FixedSizeList, Type::Variant, Type::Union, + Type::Map, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] @@ -163,9 +171,10 @@ impl Type { pub const FixedSizeList: Self = Self(10); pub const Variant: Self = Self(11); pub const Union: Self = Self(12); + pub const Map: Self = Self(13); pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 12; + pub const ENUM_MAX: u8 = 13; pub const ENUM_VALUES: &'static [Self] = &[ Self::NONE, Self::Null, @@ -180,6 +189,7 @@ impl Type { Self::FixedSizeList, Self::Variant, Self::Union, + Self::Map, ]; /// Returns the variant's name or "" if unknown. pub fn variant_name(self) -> Option<&'static str> { @@ -197,12 +207,13 @@ impl Type { Self::FixedSizeList => Some("FixedSizeList"), Self::Variant => Some("Variant"), Self::Union => Some("Union"), + Self::Map => Some("Map"), _ => None, } } } -impl ::core::fmt::Debug for Type { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for Type { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -210,24 +221,24 @@ impl ::core::fmt::Debug for Type { } } } -impl<'a> ::flatbuffers::Follow<'a> for Type { +impl<'a> flatbuffers::Follow<'a> for Type { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for Type { +impl flatbuffers::Push for Type { type Output = Type; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for Type { +impl flatbuffers::EndianScalar for Type { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -241,55 +252,57 @@ impl ::flatbuffers::EndianScalar for Type { } } -impl<'a> ::flatbuffers::Verifiable for Type { +impl<'a> flatbuffers::Verifiable for Type { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for Type {} +impl flatbuffers::SimpleToVerifyInSlice for Type {} pub struct TypeUnionTableOffset {} pub enum NullOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Null<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Null<'a> { +impl<'a> flatbuffers::Follow<'a> for Null<'a> { type Inner = Null<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Null<'a> { #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Null { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, _args: &'args NullArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = NullBuilder::new(_fbb); builder.finish() } } -impl ::flatbuffers::Verifiable for Null<'_> { +impl flatbuffers::Verifiable for Null<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .finish(); Ok(()) @@ -305,13 +318,13 @@ impl<'a> Default for NullArgs { } } -pub struct NullBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct NullBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> NullBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> NullBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> NullBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> NullBuilder<'a, 'b, A> { let start = _fbb.start_table(); NullBuilder { fbb_: _fbb, @@ -319,14 +332,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> NullBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Null<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Null<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Null"); ds.finish() } @@ -335,29 +348,29 @@ pub enum BoolOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Bool<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Bool<'a> { +impl<'a> flatbuffers::Follow<'a> for Bool<'a> { type Inner = Bool<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Bool<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Bool { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args BoolArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = BoolBuilder::new(_fbb); builder.add_nullable(args.nullable); builder.finish() @@ -373,11 +386,12 @@ impl<'a> Bool<'a> { } } -impl ::flatbuffers::Verifiable for Bool<'_> { +impl flatbuffers::Verifiable for Bool<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); @@ -396,17 +410,17 @@ impl<'a> Default for BoolArgs { } } -pub struct BoolBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct BoolBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BoolBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BoolBuilder<'a, 'b, A> { #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(Bool::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BoolBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BoolBuilder<'a, 'b, A> { let start = _fbb.start_table(); BoolBuilder { fbb_: _fbb, @@ -414,14 +428,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BoolBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Bool<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Bool<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Bool"); ds.field("nullable", &self.nullable()); ds.finish() @@ -431,30 +445,30 @@ pub enum PrimitiveOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Primitive<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Primitive<'a> { +impl<'a> flatbuffers::Follow<'a> for Primitive<'a> { type Inner = Primitive<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Primitive<'a> { - pub const VT_PTYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 6; + pub const VT_PTYPE: flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 6; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Primitive { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args PrimitiveArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = PrimitiveBuilder::new(_fbb); builder.add_nullable(args.nullable); builder.add_ptype(args.ptype); @@ -478,11 +492,12 @@ impl<'a> Primitive<'a> { } } -impl ::flatbuffers::Verifiable for Primitive<'_> { +impl flatbuffers::Verifiable for Primitive<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("ptype", Self::VT_PTYPE, false)? .visit_field::("nullable", Self::VT_NULLABLE, false)? @@ -504,11 +519,11 @@ impl<'a> Default for PrimitiveArgs { } } -pub struct PrimitiveBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct PrimitiveBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PrimitiveBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PrimitiveBuilder<'a, 'b, A> { #[inline] pub fn add_ptype(&mut self, ptype: PType) { self.fbb_.push_slot::(Primitive::VT_PTYPE, ptype, PType::U8); @@ -518,7 +533,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PrimitiveBuilder<'a, 'b, A> { self.fbb_.push_slot::(Primitive::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PrimitiveBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PrimitiveBuilder<'a, 'b, A> { let start = _fbb.start_table(); PrimitiveBuilder { fbb_: _fbb, @@ -526,14 +541,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PrimitiveBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Primitive<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Primitive<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Primitive"); ds.field("ptype", &self.ptype()); ds.field("nullable", &self.nullable()); @@ -544,31 +559,31 @@ pub enum DecimalOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Decimal<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Decimal<'a> { +impl<'a> flatbuffers::Follow<'a> for Decimal<'a> { type Inner = Decimal<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Decimal<'a> { - pub const VT_PRECISION: ::flatbuffers::VOffsetT = 4; - pub const VT_SCALE: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; + pub const VT_PRECISION: flatbuffers::VOffsetT = 4; + pub const VT_SCALE: flatbuffers::VOffsetT = 6; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 8; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Decimal { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args DecimalArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = DecimalBuilder::new(_fbb); builder.add_nullable(args.nullable); builder.add_scale(args.scale); @@ -600,11 +615,12 @@ impl<'a> Decimal<'a> { } } -impl ::flatbuffers::Verifiable for Decimal<'_> { +impl flatbuffers::Verifiable for Decimal<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("precision", Self::VT_PRECISION, false)? .visit_field::("scale", Self::VT_SCALE, false)? @@ -629,11 +645,11 @@ impl<'a> Default for DecimalArgs { } } -pub struct DecimalBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct DecimalBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DecimalBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DecimalBuilder<'a, 'b, A> { #[inline] pub fn add_precision(&mut self, precision: u8) { self.fbb_.push_slot::(Decimal::VT_PRECISION, precision, 0); @@ -647,7 +663,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DecimalBuilder<'a, 'b, A> { self.fbb_.push_slot::(Decimal::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DecimalBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DecimalBuilder<'a, 'b, A> { let start = _fbb.start_table(); DecimalBuilder { fbb_: _fbb, @@ -655,14 +671,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DecimalBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Decimal<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Decimal<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Decimal"); ds.field("precision", &self.precision()); ds.field("scale", &self.scale()); @@ -674,29 +690,29 @@ pub enum Utf8Offset {} #[derive(Copy, Clone, PartialEq)] pub struct Utf8<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Utf8<'a> { +impl<'a> flatbuffers::Follow<'a> for Utf8<'a> { type Inner = Utf8<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Utf8<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Utf8 { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args Utf8Args - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = Utf8Builder::new(_fbb); builder.add_nullable(args.nullable); builder.finish() @@ -712,11 +728,12 @@ impl<'a> Utf8<'a> { } } -impl ::flatbuffers::Verifiable for Utf8<'_> { +impl flatbuffers::Verifiable for Utf8<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); @@ -735,17 +752,17 @@ impl<'a> Default for Utf8Args { } } -pub struct Utf8Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct Utf8Builder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Utf8Builder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> Utf8Builder<'a, 'b, A> { #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(Utf8::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Utf8Builder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> Utf8Builder<'a, 'b, A> { let start = _fbb.start_table(); Utf8Builder { fbb_: _fbb, @@ -753,14 +770,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Utf8Builder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Utf8<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Utf8<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Utf8"); ds.field("nullable", &self.nullable()); ds.finish() @@ -770,29 +787,29 @@ pub enum BinaryOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Binary<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Binary<'a> { +impl<'a> flatbuffers::Follow<'a> for Binary<'a> { type Inner = Binary<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Binary<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Binary { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args BinaryArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = BinaryBuilder::new(_fbb); builder.add_nullable(args.nullable); builder.finish() @@ -808,11 +825,12 @@ impl<'a> Binary<'a> { } } -impl ::flatbuffers::Verifiable for Binary<'_> { +impl flatbuffers::Verifiable for Binary<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); @@ -831,17 +849,17 @@ impl<'a> Default for BinaryArgs { } } -pub struct BinaryBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct BinaryBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BinaryBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BinaryBuilder<'a, 'b, A> { #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(Binary::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BinaryBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BinaryBuilder<'a, 'b, A> { let start = _fbb.start_table(); BinaryBuilder { fbb_: _fbb, @@ -849,14 +867,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BinaryBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Binary<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Binary<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Binary"); ds.field("nullable", &self.nullable()); ds.finish() @@ -866,31 +884,31 @@ pub enum Struct_Offset {} #[derive(Copy, Clone, PartialEq)] pub struct Struct_<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Struct_<'a> { +impl<'a> flatbuffers::Follow<'a> for Struct_<'a> { type Inner = Struct_<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Struct_<'a> { - pub const VT_NAMES: ::flatbuffers::VOffsetT = 4; - pub const VT_DTYPES: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; + pub const VT_NAMES: flatbuffers::VOffsetT = 4; + pub const VT_DTYPES: flatbuffers::VOffsetT = 6; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 8; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Struct_ { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args Struct_Args<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = Struct_Builder::new(_fbb); if let Some(x) = args.dtypes { builder.add_dtypes(x); } if let Some(x) = args.names { builder.add_names(x); } @@ -900,18 +918,18 @@ impl<'a> Struct_<'a> { #[inline] - pub fn names(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { + pub fn names(&self) -> Option>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Struct_::VT_NAMES, None)} + unsafe { self._tab.get::>>>(Struct_::VT_NAMES, None)} } #[inline] - pub fn dtypes(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn dtypes(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Struct_::VT_DTYPES, None)} + unsafe { self._tab.get::>>>(Struct_::VT_DTYPES, None)} } #[inline] pub fn nullable(&self) -> bool { @@ -922,22 +940,23 @@ impl<'a> Struct_<'a> { } } -impl ::flatbuffers::Verifiable for Struct_<'_> { +impl flatbuffers::Verifiable for Struct_<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("names", Self::VT_NAMES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("dtypes", Self::VT_DTYPES, false)? + .visit_field::>>>("names", Self::VT_NAMES, false)? + .visit_field::>>>("dtypes", Self::VT_DTYPES, false)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); Ok(()) } } pub struct Struct_Args<'a> { - pub names: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, - pub dtypes: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, + pub names: Option>>>, + pub dtypes: Option>>>>, pub nullable: bool, } impl<'a> Default for Struct_Args<'a> { @@ -951,25 +970,25 @@ impl<'a> Default for Struct_Args<'a> { } } -pub struct Struct_Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct Struct_Builder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Struct_Builder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> Struct_Builder<'a, 'b, A> { #[inline] - pub fn add_names(&mut self, names: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Struct_::VT_NAMES, names); + pub fn add_names(&mut self, names: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Struct_::VT_NAMES, names); } #[inline] - pub fn add_dtypes(&mut self, dtypes: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Struct_::VT_DTYPES, dtypes); + pub fn add_dtypes(&mut self, dtypes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Struct_::VT_DTYPES, dtypes); } #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(Struct_::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Struct_Builder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> Struct_Builder<'a, 'b, A> { let start = _fbb.start_table(); Struct_Builder { fbb_: _fbb, @@ -977,14 +996,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Struct_Builder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Struct_<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Struct_<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Struct_"); ds.field("names", &self.names()); ds.field("dtypes", &self.dtypes()); @@ -996,30 +1015,30 @@ pub enum ListOffset {} #[derive(Copy, Clone, PartialEq)] pub struct List<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for List<'a> { +impl<'a> flatbuffers::Follow<'a> for List<'a> { type Inner = List<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> List<'a> { - pub const VT_ELEMENT_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 6; + pub const VT_ELEMENT_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 6; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { List { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ListArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ListBuilder::new(_fbb); if let Some(x) = args.element_type { builder.add_element_type(x); } builder.add_nullable(args.nullable); @@ -1032,7 +1051,7 @@ impl<'a> List<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(List::VT_ELEMENT_TYPE, None)} + unsafe { self._tab.get::>(List::VT_ELEMENT_TYPE, None)} } #[inline] pub fn nullable(&self) -> bool { @@ -1043,20 +1062,21 @@ impl<'a> List<'a> { } } -impl ::flatbuffers::Verifiable for List<'_> { +impl flatbuffers::Verifiable for List<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("element_type", Self::VT_ELEMENT_TYPE, false)? + .visit_field::>("element_type", Self::VT_ELEMENT_TYPE, false)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); Ok(()) } } pub struct ListArgs<'a> { - pub element_type: Option<::flatbuffers::WIPOffset>>, + pub element_type: Option>>, pub nullable: bool, } impl<'a> Default for ListArgs<'a> { @@ -1069,21 +1089,21 @@ impl<'a> Default for ListArgs<'a> { } } -pub struct ListBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ListBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ListBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ListBuilder<'a, 'b, A> { #[inline] - pub fn add_element_type(&mut self, element_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(List::VT_ELEMENT_TYPE, element_type); + pub fn add_element_type(&mut self, element_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(List::VT_ELEMENT_TYPE, element_type); } #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(List::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ListBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ListBuilder<'a, 'b, A> { let start = _fbb.start_table(); ListBuilder { fbb_: _fbb, @@ -1091,14 +1111,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ListBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for List<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for List<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("List"); ds.field("element_type", &self.element_type()); ds.field("nullable", &self.nullable()); @@ -1109,31 +1129,31 @@ pub enum FixedSizeListOffset {} #[derive(Copy, Clone, PartialEq)] pub struct FixedSizeList<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for FixedSizeList<'a> { +impl<'a> flatbuffers::Follow<'a> for FixedSizeList<'a> { type Inner = FixedSizeList<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> FixedSizeList<'a> { - pub const VT_ELEMENT_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_SIZE: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; + pub const VT_ELEMENT_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_SIZE: flatbuffers::VOffsetT = 6; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 8; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { FixedSizeList { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args FixedSizeListArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = FixedSizeListBuilder::new(_fbb); builder.add_size(args.size); if let Some(x) = args.element_type { builder.add_element_type(x); } @@ -1147,7 +1167,7 @@ impl<'a> FixedSizeList<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(FixedSizeList::VT_ELEMENT_TYPE, None)} + unsafe { self._tab.get::>(FixedSizeList::VT_ELEMENT_TYPE, None)} } #[inline] pub fn size(&self) -> u32 { @@ -1165,13 +1185,14 @@ impl<'a> FixedSizeList<'a> { } } -impl ::flatbuffers::Verifiable for FixedSizeList<'_> { +impl flatbuffers::Verifiable for FixedSizeList<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("element_type", Self::VT_ELEMENT_TYPE, false)? + .visit_field::>("element_type", Self::VT_ELEMENT_TYPE, false)? .visit_field::("size", Self::VT_SIZE, false)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); @@ -1179,7 +1200,7 @@ impl ::flatbuffers::Verifiable for FixedSizeList<'_> { } } pub struct FixedSizeListArgs<'a> { - pub element_type: Option<::flatbuffers::WIPOffset>>, + pub element_type: Option>>, pub size: u32, pub nullable: bool, } @@ -1194,14 +1215,14 @@ impl<'a> Default for FixedSizeListArgs<'a> { } } -pub struct FixedSizeListBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct FixedSizeListBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FixedSizeListBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FixedSizeListBuilder<'a, 'b, A> { #[inline] - pub fn add_element_type(&mut self, element_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(FixedSizeList::VT_ELEMENT_TYPE, element_type); + pub fn add_element_type(&mut self, element_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(FixedSizeList::VT_ELEMENT_TYPE, element_type); } #[inline] pub fn add_size(&mut self, size: u32) { @@ -1212,7 +1233,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FixedSizeListBuilder<'a, 'b, self.fbb_.push_slot::(FixedSizeList::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FixedSizeListBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FixedSizeListBuilder<'a, 'b, A> { let start = _fbb.start_table(); FixedSizeListBuilder { fbb_: _fbb, @@ -1220,14 +1241,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FixedSizeListBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for FixedSizeList<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for FixedSizeList<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("FixedSizeList"); ds.field("element_type", &self.element_type()); ds.field("size", &self.size()); @@ -1239,31 +1260,31 @@ pub enum ExtensionOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Extension<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Extension<'a> { +impl<'a> flatbuffers::Follow<'a> for Extension<'a> { type Inner = Extension<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Extension<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; - pub const VT_STORAGE_DTYPE: ::flatbuffers::VOffsetT = 6; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 8; + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_STORAGE_DTYPE: flatbuffers::VOffsetT = 6; + pub const VT_METADATA: flatbuffers::VOffsetT = 8; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Extension { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ExtensionArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ExtensionBuilder::new(_fbb); if let Some(x) = args.metadata { builder.add_metadata(x); } if let Some(x) = args.storage_dtype { builder.add_storage_dtype(x); } @@ -1277,41 +1298,42 @@ impl<'a> Extension<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Extension::VT_ID, None)} + unsafe { self._tab.get::>(Extension::VT_ID, None)} } #[inline] pub fn storage_dtype(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Extension::VT_STORAGE_DTYPE, None)} + unsafe { self._tab.get::>(Extension::VT_STORAGE_DTYPE, None)} } #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn metadata(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Extension::VT_METADATA, None)} + unsafe { self._tab.get::>>(Extension::VT_METADATA, None)} } } -impl ::flatbuffers::Verifiable for Extension<'_> { +impl flatbuffers::Verifiable for Extension<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("storage_dtype", Self::VT_STORAGE_DTYPE, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? + .visit_field::>("id", Self::VT_ID, false)? + .visit_field::>("storage_dtype", Self::VT_STORAGE_DTYPE, false)? + .visit_field::>>("metadata", Self::VT_METADATA, false)? .finish(); Ok(()) } } pub struct ExtensionArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, - pub storage_dtype: Option<::flatbuffers::WIPOffset>>, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub id: Option>, + pub storage_dtype: Option>>, + pub metadata: Option>>, } impl<'a> Default for ExtensionArgs<'a> { #[inline] @@ -1324,25 +1346,25 @@ impl<'a> Default for ExtensionArgs<'a> { } } -pub struct ExtensionBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ExtensionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ExtensionBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ExtensionBuilder<'a, 'b, A> { #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Extension::VT_ID, id); + pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Extension::VT_ID, id); } #[inline] - pub fn add_storage_dtype(&mut self, storage_dtype: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Extension::VT_STORAGE_DTYPE, storage_dtype); + pub fn add_storage_dtype(&mut self, storage_dtype: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Extension::VT_STORAGE_DTYPE, storage_dtype); } #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Extension::VT_METADATA, metadata); + pub fn add_metadata(&mut self, metadata: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Extension::VT_METADATA, metadata); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ExtensionBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ExtensionBuilder<'a, 'b, A> { let start = _fbb.start_table(); ExtensionBuilder { fbb_: _fbb, @@ -1350,14 +1372,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ExtensionBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Extension<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Extension<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Extension"); ds.field("id", &self.id()); ds.field("storage_dtype", &self.storage_dtype()); @@ -1369,29 +1391,29 @@ pub enum VariantOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Variant<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Variant<'a> { +impl<'a> flatbuffers::Follow<'a> for Variant<'a> { type Inner = Variant<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Variant<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Variant { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args VariantArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = VariantBuilder::new(_fbb); builder.add_nullable(args.nullable); builder.finish() @@ -1407,11 +1429,12 @@ impl<'a> Variant<'a> { } } -impl ::flatbuffers::Verifiable for Variant<'_> { +impl flatbuffers::Verifiable for Variant<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("nullable", Self::VT_NULLABLE, false)? .finish(); @@ -1430,17 +1453,17 @@ impl<'a> Default for VariantArgs { } } -pub struct VariantBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct VariantBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> VariantBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> VariantBuilder<'a, 'b, A> { #[inline] pub fn add_nullable(&mut self, nullable: bool) { self.fbb_.push_slot::(Variant::VT_NULLABLE, nullable, false); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> VariantBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> VariantBuilder<'a, 'b, A> { let start = _fbb.start_table(); VariantBuilder { fbb_: _fbb, @@ -1448,14 +1471,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> VariantBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Variant<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Variant<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Variant"); ds.field("nullable", &self.nullable()); ds.finish() @@ -1465,31 +1488,31 @@ pub enum UnionOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Union<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Union<'a> { +impl<'a> flatbuffers::Follow<'a> for Union<'a> { type Inner = Union<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Union<'a> { - pub const VT_NAMES: ::flatbuffers::VOffsetT = 4; - pub const VT_DTYPES: ::flatbuffers::VOffsetT = 6; - pub const VT_TYPE_IDS: ::flatbuffers::VOffsetT = 8; + pub const VT_NAMES: flatbuffers::VOffsetT = 4; + pub const VT_DTYPES: flatbuffers::VOffsetT = 6; + pub const VT_TYPE_IDS: flatbuffers::VOffsetT = 8; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Union { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args UnionArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = UnionBuilder::new(_fbb); if let Some(x) = args.type_ids { builder.add_type_ids(x); } if let Some(x) = args.dtypes { builder.add_dtypes(x); } @@ -1499,45 +1522,46 @@ impl<'a> Union<'a> { #[inline] - pub fn names(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { + pub fn names(&self) -> Option>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Union::VT_NAMES, None)} + unsafe { self._tab.get::>>>(Union::VT_NAMES, None)} } #[inline] - pub fn dtypes(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn dtypes(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Union::VT_DTYPES, None)} + unsafe { self._tab.get::>>>(Union::VT_DTYPES, None)} } #[inline] - pub fn type_ids(&self) -> Option<::flatbuffers::Vector<'a, i8>> { + pub fn type_ids(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(Union::VT_TYPE_IDS, None)} + unsafe { self._tab.get::>>(Union::VT_TYPE_IDS, None)} } } -impl ::flatbuffers::Verifiable for Union<'_> { +impl flatbuffers::Verifiable for Union<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("names", Self::VT_NAMES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("dtypes", Self::VT_DTYPES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i8>>>("type_ids", Self::VT_TYPE_IDS, false)? + .visit_field::>>>("names", Self::VT_NAMES, false)? + .visit_field::>>>("dtypes", Self::VT_DTYPES, false)? + .visit_field::>>("type_ids", Self::VT_TYPE_IDS, false)? .finish(); Ok(()) } } pub struct UnionArgs<'a> { - pub names: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, - pub dtypes: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub type_ids: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>, + pub names: Option>>>, + pub dtypes: Option>>>>, + pub type_ids: Option>>, } impl<'a> Default for UnionArgs<'a> { #[inline] @@ -1550,25 +1574,25 @@ impl<'a> Default for UnionArgs<'a> { } } -pub struct UnionBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct UnionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { #[inline] - pub fn add_names(&mut self, names: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_NAMES, names); + pub fn add_names(&mut self, names: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Union::VT_NAMES, names); } #[inline] - pub fn add_dtypes(&mut self, dtypes: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_DTYPES, dtypes); + pub fn add_dtypes(&mut self, dtypes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Union::VT_DTYPES, dtypes); } #[inline] - pub fn add_type_ids(&mut self, type_ids: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_TYPE_IDS, type_ids); + pub fn add_type_ids(&mut self, type_ids: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Union::VT_TYPE_IDS, type_ids); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UnionBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UnionBuilder<'a, 'b, A> { let start = _fbb.start_table(); UnionBuilder { fbb_: _fbb, @@ -1576,14 +1600,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Union<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Union<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Union"); ds.field("names", &self.names()); ds.field("dtypes", &self.dtypes()); @@ -1591,34 +1615,182 @@ impl ::core::fmt::Debug for Union<'_> { ds.finish() } } +pub enum MapOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Map<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Map<'a> { + type Inner = Map<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } + } +} + +impl<'a> Map<'a> { + pub const VT_KEY_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_VALUE_TYPE: flatbuffers::VOffsetT = 6; + pub const VT_KEYS_SORTED: flatbuffers::VOffsetT = 8; + pub const VT_NULLABLE: flatbuffers::VOffsetT = 10; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Map { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, + args: &'args MapArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = MapBuilder::new(_fbb); + if let Some(x) = args.value_type { builder.add_value_type(x); } + if let Some(x) = args.key_type { builder.add_key_type(x); } + builder.add_nullable(args.nullable); + builder.add_keys_sorted(args.keys_sorted); + builder.finish() + } + + + #[inline] + pub fn key_type(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Map::VT_KEY_TYPE, None)} + } + #[inline] + pub fn value_type(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Map::VT_VALUE_TYPE, None)} + } + #[inline] + pub fn keys_sorted(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Map::VT_KEYS_SORTED, Some(false)).unwrap()} + } + #[inline] + pub fn nullable(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Map::VT_NULLABLE, Some(false)).unwrap()} + } +} + +impl flatbuffers::Verifiable for Map<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("key_type", Self::VT_KEY_TYPE, false)? + .visit_field::>("value_type", Self::VT_VALUE_TYPE, false)? + .visit_field::("keys_sorted", Self::VT_KEYS_SORTED, false)? + .visit_field::("nullable", Self::VT_NULLABLE, false)? + .finish(); + Ok(()) + } +} +pub struct MapArgs<'a> { + pub key_type: Option>>, + pub value_type: Option>>, + pub keys_sorted: bool, + pub nullable: bool, +} +impl<'a> Default for MapArgs<'a> { + #[inline] + fn default() -> Self { + MapArgs { + key_type: None, + value_type: None, + keys_sorted: false, + nullable: false, + } + } +} + +pub struct MapBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MapBuilder<'a, 'b, A> { + #[inline] + pub fn add_key_type(&mut self, key_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Map::VT_KEY_TYPE, key_type); + } + #[inline] + pub fn add_value_type(&mut self, value_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Map::VT_VALUE_TYPE, value_type); + } + #[inline] + pub fn add_keys_sorted(&mut self, keys_sorted: bool) { + self.fbb_.push_slot::(Map::VT_KEYS_SORTED, keys_sorted, false); + } + #[inline] + pub fn add_nullable(&mut self, nullable: bool) { + self.fbb_.push_slot::(Map::VT_NULLABLE, nullable, false); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> MapBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + MapBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Map<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Map"); + ds.field("key_type", &self.key_type()); + ds.field("value_type", &self.value_type()); + ds.field("keys_sorted", &self.keys_sorted()); + ds.field("nullable", &self.nullable()); + ds.finish() + } +} pub enum DTypeOffset {} #[derive(Copy, Clone, PartialEq)] pub struct DType<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for DType<'a> { +impl<'a> flatbuffers::Follow<'a> for DType<'a> { type Inner = DType<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> DType<'a> { - pub const VT_TYPE_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_TYPE_: ::flatbuffers::VOffsetT = 6; + pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_TYPE_: flatbuffers::VOffsetT = 6; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { DType { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args DTypeArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = DTypeBuilder::new(_fbb); if let Some(x) = args.type_ { builder.add_type_(x); } builder.add_type_type(args.type_type); @@ -1634,11 +1806,11 @@ impl<'a> DType<'a> { unsafe { self._tab.get::(DType::VT_TYPE_TYPE, Some(Type::NONE)).unwrap()} } #[inline] - pub fn type_(&self) -> Option<::flatbuffers::Table<'a>> { + pub fn type_(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(DType::VT_TYPE_, None)} + unsafe { self._tab.get::>>(DType::VT_TYPE_, None)} } #[inline] #[allow(non_snake_case)] @@ -1820,28 +1992,45 @@ impl<'a> DType<'a> { } } + #[inline] + #[allow(non_snake_case)] + pub fn type__as_map(&self) -> Option> { + if self.type_type() == Type::Map { + self.type_().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { Map::init_from_table(t) } + }) + } else { + None + } + } + } -impl ::flatbuffers::Verifiable for DType<'_> { +impl flatbuffers::Verifiable for DType<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_union::("type_type", Self::VT_TYPE_TYPE, "type_", Self::VT_TYPE_, false, |key, v, pos| { match key { - Type::Null => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Null", pos), - Type::Bool => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Bool", pos), - Type::Primitive => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Primitive", pos), - Type::Decimal => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Decimal", pos), - Type::Utf8 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Utf8", pos), - Type::Binary => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Binary", pos), - Type::Struct_ => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Struct_", pos), - Type::List => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::List", pos), - Type::Extension => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Extension", pos), - Type::FixedSizeList => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::FixedSizeList", pos), - Type::Variant => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Variant", pos), - Type::Union => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Union", pos), + Type::Null => v.verify_union_variant::>("Type::Null", pos), + Type::Bool => v.verify_union_variant::>("Type::Bool", pos), + Type::Primitive => v.verify_union_variant::>("Type::Primitive", pos), + Type::Decimal => v.verify_union_variant::>("Type::Decimal", pos), + Type::Utf8 => v.verify_union_variant::>("Type::Utf8", pos), + Type::Binary => v.verify_union_variant::>("Type::Binary", pos), + Type::Struct_ => v.verify_union_variant::>("Type::Struct_", pos), + Type::List => v.verify_union_variant::>("Type::List", pos), + Type::Extension => v.verify_union_variant::>("Type::Extension", pos), + Type::FixedSizeList => v.verify_union_variant::>("Type::FixedSizeList", pos), + Type::Variant => v.verify_union_variant::>("Type::Variant", pos), + Type::Union => v.verify_union_variant::>("Type::Union", pos), + Type::Map => v.verify_union_variant::>("Type::Map", pos), _ => Ok(()), } })? @@ -1851,7 +2040,7 @@ impl ::flatbuffers::Verifiable for DType<'_> { } pub struct DTypeArgs { pub type_type: Type, - pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub type_: Option>, } impl<'a> Default for DTypeArgs { #[inline] @@ -1863,21 +2052,21 @@ impl<'a> Default for DTypeArgs { } } -pub struct DTypeBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct DTypeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DTypeBuilder<'a, 'b, A> { #[inline] pub fn add_type_type(&mut self, type_type: Type) { self.fbb_.push_slot::(DType::VT_TYPE_TYPE, type_type, Type::NONE); } #[inline] - pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(DType::VT_TYPE_, type_); + pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset) { + self.fbb_.push_slot_always::>(DType::VT_TYPE_, type_); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeBuilder<'a, 'b, A> { let start = _fbb.start_table(); DTypeBuilder { fbb_: _fbb, @@ -1885,14 +2074,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for DType<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for DType<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("DType"); ds.field("type_type", &self.type_type()); match self.type_type() { @@ -1980,6 +2169,13 @@ impl ::core::fmt::Debug for DType<'_> { ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") } }, + Type::Map => { + if let Some(x) = self.type__as_map() { + ds.field("type_", &x) + } else { + ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, _ => { let x: Option<()> = None; ds.field("type_", &x) @@ -1995,8 +2191,8 @@ impl ::core::fmt::Debug for DType<'_> { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_dtype_unchecked`. -pub fn root_as_dtype(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) +pub fn root_as_dtype(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -2005,8 +2201,8 @@ pub fn root_as_dtype(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlat /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_dtype_unchecked`. -pub fn size_prefixed_root_as_dtype(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_dtype(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -2016,10 +2212,10 @@ pub fn size_prefixed_root_as_dtype(buf: &[u8]) -> Result, ::flatbuffer /// previous, unchecked, behavior use /// `root_as_dtype_unchecked`. pub fn root_as_dtype_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -2029,33 +2225,33 @@ pub fn root_as_dtype_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_dtype_unchecked`. pub fn size_prefixed_root_as_dtype_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a DType and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `DType`. -pub unsafe fn root_as_dtype_unchecked(buf: &[u8]) -> DType<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } +pub unsafe fn root_as_dtype_unchecked(buf: &[u8]) -> DType { + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed DType and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `DType`. -pub unsafe fn size_prefixed_root_as_dtype_unchecked(buf: &[u8]) -> DType<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } +pub unsafe fn size_prefixed_root_as_dtype_unchecked(buf: &[u8]) -> DType { + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] -pub fn finish_dtype_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { +pub fn finish_dtype_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_dtype_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_dtype_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/vortex-flatbuffers/src/generated/footer.rs b/vortex-flatbuffers/src/generated/footer.rs index 842a151edc7..ef0da9dca5d 100644 --- a/vortex-flatbuffers/src/generated/footer.rs +++ b/vortex-flatbuffers/src/generated/footer.rs @@ -1,9 +1,15 @@ // automatically generated by the FlatBuffers compiler, do not modify + + // @generated -extern crate alloc; use crate::array::*; use crate::layout::*; +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_COMPRESSION_SCHEME: u8 = 0; @@ -47,8 +53,8 @@ impl CompressionScheme { } } } -impl ::core::fmt::Debug for CompressionScheme { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for CompressionScheme { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -56,24 +62,24 @@ impl ::core::fmt::Debug for CompressionScheme { } } } -impl<'a> ::flatbuffers::Follow<'a> for CompressionScheme { +impl<'a> flatbuffers::Follow<'a> for CompressionScheme { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for CompressionScheme { +impl flatbuffers::Push for CompressionScheme { type Output = CompressionScheme; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for CompressionScheme { +impl flatbuffers::EndianScalar for CompressionScheme { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -87,16 +93,17 @@ impl ::flatbuffers::EndianScalar for CompressionScheme { } } -impl<'a> ::flatbuffers::Verifiable for CompressionScheme { +impl<'a> flatbuffers::Verifiable for CompressionScheme { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for CompressionScheme {} +impl flatbuffers::SimpleToVerifyInSlice for CompressionScheme {} /// A `SegmentSpec` acts as the locator for a buffer within the file. // struct SegmentSpec, aligned to 8 #[repr(transparent)] @@ -107,8 +114,8 @@ impl Default for SegmentSpec { Self([0; 16]) } } -impl ::core::fmt::Debug for SegmentSpec { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for SegmentSpec { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("SegmentSpec") .field("offset", &self.offset()) .field("length", &self.length()) @@ -119,39 +126,40 @@ impl ::core::fmt::Debug for SegmentSpec { } } -impl ::flatbuffers::SimpleToVerifyInSlice for SegmentSpec {} -impl<'a> ::flatbuffers::Follow<'a> for SegmentSpec { +impl flatbuffers::SimpleToVerifyInSlice for SegmentSpec {} +impl<'a> flatbuffers::Follow<'a> for SegmentSpec { type Inner = &'a SegmentSpec; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { unsafe { <&'a SegmentSpec>::follow(buf, loc) } } } -impl<'a> ::flatbuffers::Follow<'a> for &'a SegmentSpec { +impl<'a> flatbuffers::Follow<'a> for &'a SegmentSpec { type Inner = &'a SegmentSpec; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { ::flatbuffers::follow_cast_ref::(buf, loc) } + unsafe { flatbuffers::follow_cast_ref::(buf, loc) } } } -impl<'b> ::flatbuffers::Push for SegmentSpec { +impl<'b> flatbuffers::Push for SegmentSpec { type Output = SegmentSpec; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = unsafe { ::core::slice::from_raw_parts(self as *const SegmentSpec as *const u8, ::size()) }; + let src = unsafe { ::core::slice::from_raw_parts(self as *const SegmentSpec as *const u8, ::size()) }; dst.copy_from_slice(src); } #[inline] - fn alignment() -> ::flatbuffers::PushAlignment { - ::flatbuffers::PushAlignment::new(8) + fn alignment() -> flatbuffers::PushAlignment { + flatbuffers::PushAlignment::new(8) } } -impl<'a> ::flatbuffers::Verifiable for SegmentSpec { +impl<'a> flatbuffers::Verifiable for SegmentSpec { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -176,148 +184,148 @@ impl<'a> SegmentSpec { /// Offset relative to the start of the file. pub fn offset(&self) -> u64 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[0..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_offset(&mut self, x: u64) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[0..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } /// Length in bytes of the segment. pub fn length(&self) -> u32 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[8..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_length(&mut self, x: u32) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[8..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } /// Base-2 exponent of the alignment of the segment. pub fn alignment_exponent(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[12..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_alignment_exponent(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[12..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } pub fn _compression(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[13..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set__compression(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[13..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } pub fn _encryption(&self) -> u16 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( + EndianScalar::from_little_endian(unsafe { + core::ptr::copy_nonoverlapping( self.0[14..].as_ptr(), mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set__encryption(&mut self, x: u16) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); + let x_le = x.to_little_endian(); // Safety: // Created from a valid Table for this object // Which contains a valid value in this slot unsafe { - ::core::ptr::copy_nonoverlapping( + core::ptr::copy_nonoverlapping( &x_le as *const _ as *const u8, self.0[14..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), + core::mem::size_of::<::Scalar>(), ); } } @@ -343,32 +351,32 @@ pub enum PostscriptOffset {} /// The segments pointed to by the postscript have inline compression and encryption specs to avoid /// the need to fetch encryption schemes up-front. pub struct Postscript<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Postscript<'a> { +impl<'a> flatbuffers::Follow<'a> for Postscript<'a> { type Inner = Postscript<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Postscript<'a> { - pub const VT_DTYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_LAYOUT: ::flatbuffers::VOffsetT = 6; - pub const VT_STATISTICS: ::flatbuffers::VOffsetT = 8; - pub const VT_FOOTER: ::flatbuffers::VOffsetT = 10; + pub const VT_DTYPE: flatbuffers::VOffsetT = 4; + pub const VT_LAYOUT: flatbuffers::VOffsetT = 6; + pub const VT_STATISTICS: flatbuffers::VOffsetT = 8; + pub const VT_FOOTER: flatbuffers::VOffsetT = 10; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Postscript { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args PostscriptArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = PostscriptBuilder::new(_fbb); if let Some(x) = args.footer { builder.add_footer(x); } if let Some(x) = args.statistics { builder.add_statistics(x); } @@ -384,7 +392,7 @@ impl<'a> Postscript<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_DTYPE, None)} + unsafe { self._tab.get::>(Postscript::VT_DTYPE, None)} } /// Segment containing the root `Layout` flatbuffer (required). #[inline] @@ -392,7 +400,7 @@ impl<'a> Postscript<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_LAYOUT, None)} + unsafe { self._tab.get::>(Postscript::VT_LAYOUT, None)} } /// Segment containing the file-level `Statistics` flatbuffer. #[inline] @@ -400,7 +408,7 @@ impl<'a> Postscript<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_STATISTICS, None)} + unsafe { self._tab.get::>(Postscript::VT_STATISTICS, None)} } /// Segment containing the 'Footer' flatbuffer (required) #[inline] @@ -408,29 +416,30 @@ impl<'a> Postscript<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_FOOTER, None)} + unsafe { self._tab.get::>(Postscript::VT_FOOTER, None)} } } -impl ::flatbuffers::Verifiable for Postscript<'_> { +impl flatbuffers::Verifiable for Postscript<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("dtype", Self::VT_DTYPE, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("layout", Self::VT_LAYOUT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("statistics", Self::VT_STATISTICS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("footer", Self::VT_FOOTER, false)? + .visit_field::>("dtype", Self::VT_DTYPE, false)? + .visit_field::>("layout", Self::VT_LAYOUT, false)? + .visit_field::>("statistics", Self::VT_STATISTICS, false)? + .visit_field::>("footer", Self::VT_FOOTER, false)? .finish(); Ok(()) } } pub struct PostscriptArgs<'a> { - pub dtype: Option<::flatbuffers::WIPOffset>>, - pub layout: Option<::flatbuffers::WIPOffset>>, - pub statistics: Option<::flatbuffers::WIPOffset>>, - pub footer: Option<::flatbuffers::WIPOffset>>, + pub dtype: Option>>, + pub layout: Option>>, + pub statistics: Option>>, + pub footer: Option>>, } impl<'a> Default for PostscriptArgs<'a> { #[inline] @@ -444,29 +453,29 @@ impl<'a> Default for PostscriptArgs<'a> { } } -pub struct PostscriptBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct PostscriptBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PostscriptBuilder<'a, 'b, A> { #[inline] - pub fn add_dtype(&mut self, dtype: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_DTYPE, dtype); + pub fn add_dtype(&mut self, dtype: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Postscript::VT_DTYPE, dtype); } #[inline] - pub fn add_layout(&mut self, layout: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_LAYOUT, layout); + pub fn add_layout(&mut self, layout: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Postscript::VT_LAYOUT, layout); } #[inline] - pub fn add_statistics(&mut self, statistics: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_STATISTICS, statistics); + pub fn add_statistics(&mut self, statistics: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Postscript::VT_STATISTICS, statistics); } #[inline] - pub fn add_footer(&mut self, footer: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_FOOTER, footer); + pub fn add_footer(&mut self, footer: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Postscript::VT_FOOTER, footer); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptBuilder<'a, 'b, A> { let start = _fbb.start_table(); PostscriptBuilder { fbb_: _fbb, @@ -474,14 +483,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptBuilder<'a, 'b, A> } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Postscript<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Postscript<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Postscript"); ds.field("dtype", &self.dtype()); ds.field("layout", &self.layout()); @@ -496,33 +505,33 @@ pub enum PostscriptSegmentOffset {} /// A `PostscriptSegment` describes the location of a segment in the file without referencing any /// specification objects. That is, encryption and compression are defined inline. pub struct PostscriptSegment<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for PostscriptSegment<'a> { +impl<'a> flatbuffers::Follow<'a> for PostscriptSegment<'a> { type Inner = PostscriptSegment<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> PostscriptSegment<'a> { - pub const VT_OFFSET: ::flatbuffers::VOffsetT = 4; - pub const VT_LENGTH: ::flatbuffers::VOffsetT = 6; - pub const VT_ALIGNMENT_EXPONENT: ::flatbuffers::VOffsetT = 8; - pub const VT__COMPRESSION: ::flatbuffers::VOffsetT = 10; - pub const VT__ENCRYPTION: ::flatbuffers::VOffsetT = 12; + pub const VT_OFFSET: flatbuffers::VOffsetT = 4; + pub const VT_LENGTH: flatbuffers::VOffsetT = 6; + pub const VT_ALIGNMENT_EXPONENT: flatbuffers::VOffsetT = 8; + pub const VT__COMPRESSION: flatbuffers::VOffsetT = 10; + pub const VT__ENCRYPTION: flatbuffers::VOffsetT = 12; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { PostscriptSegment { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args PostscriptSegmentArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = PostscriptSegmentBuilder::new(_fbb); builder.add_offset(args.offset); if let Some(x) = args._encryption { builder.add__encryption(x); } @@ -559,28 +568,29 @@ impl<'a> PostscriptSegment<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(PostscriptSegment::VT__COMPRESSION, None)} + unsafe { self._tab.get::>(PostscriptSegment::VT__COMPRESSION, None)} } #[inline] pub fn _encryption(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(PostscriptSegment::VT__ENCRYPTION, None)} + unsafe { self._tab.get::>(PostscriptSegment::VT__ENCRYPTION, None)} } } -impl ::flatbuffers::Verifiable for PostscriptSegment<'_> { +impl flatbuffers::Verifiable for PostscriptSegment<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("offset", Self::VT_OFFSET, false)? .visit_field::("length", Self::VT_LENGTH, false)? .visit_field::("alignment_exponent", Self::VT_ALIGNMENT_EXPONENT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("_compression", Self::VT__COMPRESSION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("_encryption", Self::VT__ENCRYPTION, false)? + .visit_field::>("_compression", Self::VT__COMPRESSION, false)? + .visit_field::>("_encryption", Self::VT__ENCRYPTION, false)? .finish(); Ok(()) } @@ -589,8 +599,8 @@ pub struct PostscriptSegmentArgs<'a> { pub offset: u64, pub length: u32, pub alignment_exponent: u8, - pub _compression: Option<::flatbuffers::WIPOffset>>, - pub _encryption: Option<::flatbuffers::WIPOffset>>, + pub _compression: Option>>, + pub _encryption: Option>>, } impl<'a> Default for PostscriptSegmentArgs<'a> { #[inline] @@ -605,11 +615,11 @@ impl<'a> Default for PostscriptSegmentArgs<'a> { } } -pub struct PostscriptSegmentBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct PostscriptSegmentBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptSegmentBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PostscriptSegmentBuilder<'a, 'b, A> { #[inline] pub fn add_offset(&mut self, offset: u64) { self.fbb_.push_slot::(PostscriptSegment::VT_OFFSET, offset, 0); @@ -623,15 +633,15 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptSegmentBuilder<'a, self.fbb_.push_slot::(PostscriptSegment::VT_ALIGNMENT_EXPONENT, alignment_exponent, 0); } #[inline] - pub fn add__compression(&mut self, _compression: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(PostscriptSegment::VT__COMPRESSION, _compression); + pub fn add__compression(&mut self, _compression: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(PostscriptSegment::VT__COMPRESSION, _compression); } #[inline] - pub fn add__encryption(&mut self, _encryption: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(PostscriptSegment::VT__ENCRYPTION, _encryption); + pub fn add__encryption(&mut self, _encryption: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(PostscriptSegment::VT__ENCRYPTION, _encryption); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptSegmentBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptSegmentBuilder<'a, 'b, A> { let start = _fbb.start_table(); PostscriptSegmentBuilder { fbb_: _fbb, @@ -639,14 +649,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptSegmentBuilder<'a, } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for PostscriptSegment<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for PostscriptSegment<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("PostscriptSegment"); ds.field("offset", &self.offset()); ds.field("length", &self.length()); @@ -661,29 +671,29 @@ pub enum FileStatisticsOffset {} /// The `FileStatistics` object contains file-level statistics for the Vortex file. pub struct FileStatistics<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for FileStatistics<'a> { +impl<'a> flatbuffers::Follow<'a> for FileStatistics<'a> { type Inner = FileStatistics<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> FileStatistics<'a> { - pub const VT_FIELD_STATS: ::flatbuffers::VOffsetT = 4; + pub const VT_FIELD_STATS: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { FileStatistics { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args FileStatisticsArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = FileStatisticsBuilder::new(_fbb); if let Some(x) = args.field_stats { builder.add_field_stats(x); } builder.finish() @@ -693,27 +703,28 @@ impl<'a> FileStatistics<'a> { /// Statistics for each field in the root schema. If the root schema is not a struct, there will /// be a single entry in this array. #[inline] - pub fn field_stats(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn field_stats(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(FileStatistics::VT_FIELD_STATS, None)} + unsafe { self._tab.get::>>>(FileStatistics::VT_FIELD_STATS, None)} } } -impl ::flatbuffers::Verifiable for FileStatistics<'_> { +impl flatbuffers::Verifiable for FileStatistics<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("field_stats", Self::VT_FIELD_STATS, false)? + .visit_field::>>>("field_stats", Self::VT_FIELD_STATS, false)? .finish(); Ok(()) } } pub struct FileStatisticsArgs<'a> { - pub field_stats: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, + pub field_stats: Option>>>>, } impl<'a> Default for FileStatisticsArgs<'a> { #[inline] @@ -724,17 +735,17 @@ impl<'a> Default for FileStatisticsArgs<'a> { } } -pub struct FileStatisticsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct FileStatisticsBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FileStatisticsBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FileStatisticsBuilder<'a, 'b, A> { #[inline] - pub fn add_field_stats(&mut self, field_stats: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(FileStatistics::VT_FIELD_STATS, field_stats); + pub fn add_field_stats(&mut self, field_stats: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(FileStatistics::VT_FIELD_STATS, field_stats); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FileStatisticsBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FileStatisticsBuilder<'a, 'b, A> { let start = _fbb.start_table(); FileStatisticsBuilder { fbb_: _fbb, @@ -742,14 +753,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FileStatisticsBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for FileStatistics<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for FileStatistics<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("FileStatistics"); ds.field("field_stats", &self.field_stats()); ds.finish() @@ -761,33 +772,33 @@ pub enum FooterOffset {} /// The `Registry` object stores dictionary-encoded configuration for segments, /// compression schemes, encryption schemes, etc. pub struct Footer<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Footer<'a> { +impl<'a> flatbuffers::Follow<'a> for Footer<'a> { type Inner = Footer<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Footer<'a> { - pub const VT_ARRAY_SPECS: ::flatbuffers::VOffsetT = 4; - pub const VT_LAYOUT_SPECS: ::flatbuffers::VOffsetT = 6; - pub const VT_SEGMENT_SPECS: ::flatbuffers::VOffsetT = 8; - pub const VT_COMPRESSION_SPECS: ::flatbuffers::VOffsetT = 10; - pub const VT_ENCRYPTION_SPECS: ::flatbuffers::VOffsetT = 12; + pub const VT_ARRAY_SPECS: flatbuffers::VOffsetT = 4; + pub const VT_LAYOUT_SPECS: flatbuffers::VOffsetT = 6; + pub const VT_SEGMENT_SPECS: flatbuffers::VOffsetT = 8; + pub const VT_COMPRESSION_SPECS: flatbuffers::VOffsetT = 10; + pub const VT_ENCRYPTION_SPECS: flatbuffers::VOffsetT = 12; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Footer { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args FooterArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = FooterBuilder::new(_fbb); if let Some(x) = args.encryption_specs { builder.add_encryption_specs(x); } if let Some(x) = args.compression_specs { builder.add_compression_specs(x); } @@ -799,63 +810,64 @@ impl<'a> Footer<'a> { #[inline] - pub fn array_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn array_specs(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_ARRAY_SPECS, None)} + unsafe { self._tab.get::>>>(Footer::VT_ARRAY_SPECS, None)} } #[inline] - pub fn layout_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn layout_specs(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_LAYOUT_SPECS, None)} + unsafe { self._tab.get::>>>(Footer::VT_LAYOUT_SPECS, None)} } #[inline] - pub fn segment_specs(&self) -> Option<::flatbuffers::Vector<'a, SegmentSpec>> { + pub fn segment_specs(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, SegmentSpec>>>(Footer::VT_SEGMENT_SPECS, None)} + unsafe { self._tab.get::>>(Footer::VT_SEGMENT_SPECS, None)} } #[inline] - pub fn compression_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn compression_specs(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_COMPRESSION_SPECS, None)} + unsafe { self._tab.get::>>>(Footer::VT_COMPRESSION_SPECS, None)} } #[inline] - pub fn encryption_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn encryption_specs(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_ENCRYPTION_SPECS, None)} + unsafe { self._tab.get::>>>(Footer::VT_ENCRYPTION_SPECS, None)} } } -impl ::flatbuffers::Verifiable for Footer<'_> { +impl flatbuffers::Verifiable for Footer<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("array_specs", Self::VT_ARRAY_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("layout_specs", Self::VT_LAYOUT_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, SegmentSpec>>>("segment_specs", Self::VT_SEGMENT_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("compression_specs", Self::VT_COMPRESSION_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("encryption_specs", Self::VT_ENCRYPTION_SPECS, false)? + .visit_field::>>>("array_specs", Self::VT_ARRAY_SPECS, false)? + .visit_field::>>>("layout_specs", Self::VT_LAYOUT_SPECS, false)? + .visit_field::>>("segment_specs", Self::VT_SEGMENT_SPECS, false)? + .visit_field::>>>("compression_specs", Self::VT_COMPRESSION_SPECS, false)? + .visit_field::>>>("encryption_specs", Self::VT_ENCRYPTION_SPECS, false)? .finish(); Ok(()) } } pub struct FooterArgs<'a> { - pub array_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub layout_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub segment_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, SegmentSpec>>>, - pub compression_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub encryption_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, + pub array_specs: Option>>>>, + pub layout_specs: Option>>>>, + pub segment_specs: Option>>, + pub compression_specs: Option>>>>, + pub encryption_specs: Option>>>>, } impl<'a> Default for FooterArgs<'a> { #[inline] @@ -870,33 +882,33 @@ impl<'a> Default for FooterArgs<'a> { } } -pub struct FooterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct FooterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FooterBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FooterBuilder<'a, 'b, A> { #[inline] - pub fn add_array_specs(&mut self, array_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_ARRAY_SPECS, array_specs); + pub fn add_array_specs(&mut self, array_specs: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Footer::VT_ARRAY_SPECS, array_specs); } #[inline] - pub fn add_layout_specs(&mut self, layout_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_LAYOUT_SPECS, layout_specs); + pub fn add_layout_specs(&mut self, layout_specs: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Footer::VT_LAYOUT_SPECS, layout_specs); } #[inline] - pub fn add_segment_specs(&mut self, segment_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , SegmentSpec>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_SEGMENT_SPECS, segment_specs); + pub fn add_segment_specs(&mut self, segment_specs: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Footer::VT_SEGMENT_SPECS, segment_specs); } #[inline] - pub fn add_compression_specs(&mut self, compression_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_COMPRESSION_SPECS, compression_specs); + pub fn add_compression_specs(&mut self, compression_specs: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Footer::VT_COMPRESSION_SPECS, compression_specs); } #[inline] - pub fn add_encryption_specs(&mut self, encryption_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_ENCRYPTION_SPECS, encryption_specs); + pub fn add_encryption_specs(&mut self, encryption_specs: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Footer::VT_ENCRYPTION_SPECS, encryption_specs); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FooterBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FooterBuilder<'a, 'b, A> { let start = _fbb.start_table(); FooterBuilder { fbb_: _fbb, @@ -904,14 +916,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FooterBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Footer<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Footer<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Footer"); ds.field("array_specs", &self.array_specs()); ds.field("layout_specs", &self.layout_specs()); @@ -929,29 +941,29 @@ pub enum ArraySpecOffset {} /// These are identified by a globally unique string identifier, and looked up in the Vortex registry /// at read-time. pub struct ArraySpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for ArraySpec<'a> { +impl<'a> flatbuffers::Follow<'a> for ArraySpec<'a> { type Inner = ArraySpec<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> ArraySpec<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; + pub const VT_ID: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { ArraySpec { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ArraySpecArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ArraySpecBuilder::new(_fbb); if let Some(x) = args.id { builder.add_id(x); } builder.finish() @@ -963,23 +975,24 @@ impl<'a> ArraySpec<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(ArraySpec::VT_ID, None).unwrap()} + unsafe { self._tab.get::>(ArraySpec::VT_ID, None).unwrap()} } } -impl ::flatbuffers::Verifiable for ArraySpec<'_> { +impl flatbuffers::Verifiable for ArraySpec<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, true)? + .visit_field::>("id", Self::VT_ID, true)? .finish(); Ok(()) } } pub struct ArraySpecArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, + pub id: Option>, } impl<'a> Default for ArraySpecArgs<'a> { #[inline] @@ -990,17 +1003,17 @@ impl<'a> Default for ArraySpecArgs<'a> { } } -pub struct ArraySpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ArraySpecBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArraySpecBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArraySpecBuilder<'a, 'b, A> { #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArraySpec::VT_ID, id); + pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(ArraySpec::VT_ID, id); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArraySpecBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArraySpecBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArraySpecBuilder { fbb_: _fbb, @@ -1008,15 +1021,15 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArraySpecBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); self.fbb_.required(o, ArraySpec::VT_ID,"id"); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for ArraySpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for ArraySpec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("ArraySpec"); ds.field("id", &self.id()); ds.finish() @@ -1030,29 +1043,29 @@ pub enum LayoutSpecOffset {} /// These are identified by a globally unique string identifier, and looked up in the Vortex registry /// at read-time. pub struct LayoutSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for LayoutSpec<'a> { +impl<'a> flatbuffers::Follow<'a> for LayoutSpec<'a> { type Inner = LayoutSpec<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> LayoutSpec<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; + pub const VT_ID: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { LayoutSpec { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args LayoutSpecArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = LayoutSpecBuilder::new(_fbb); if let Some(x) = args.id { builder.add_id(x); } builder.finish() @@ -1064,23 +1077,24 @@ impl<'a> LayoutSpec<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(LayoutSpec::VT_ID, None).unwrap()} + unsafe { self._tab.get::>(LayoutSpec::VT_ID, None).unwrap()} } } -impl ::flatbuffers::Verifiable for LayoutSpec<'_> { +impl flatbuffers::Verifiable for LayoutSpec<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, true)? + .visit_field::>("id", Self::VT_ID, true)? .finish(); Ok(()) } } pub struct LayoutSpecArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, + pub id: Option>, } impl<'a> Default for LayoutSpecArgs<'a> { #[inline] @@ -1091,17 +1105,17 @@ impl<'a> Default for LayoutSpecArgs<'a> { } } -pub struct LayoutSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct LayoutSpecBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutSpecBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> LayoutSpecBuilder<'a, 'b, A> { #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(LayoutSpec::VT_ID, id); + pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(LayoutSpec::VT_ID, id); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutSpecBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutSpecBuilder<'a, 'b, A> { let start = _fbb.start_table(); LayoutSpecBuilder { fbb_: _fbb, @@ -1109,15 +1123,15 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutSpecBuilder<'a, 'b, A> } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); self.fbb_.required(o, LayoutSpec::VT_ID,"id"); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for LayoutSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for LayoutSpec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("LayoutSpec"); ds.field("id", &self.id()); ds.finish() @@ -1128,29 +1142,29 @@ pub enum CompressionSpecOffset {} /// Definition of a compression scheme. pub struct CompressionSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for CompressionSpec<'a> { +impl<'a> flatbuffers::Follow<'a> for CompressionSpec<'a> { type Inner = CompressionSpec<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> CompressionSpec<'a> { - pub const VT_SCHEME: ::flatbuffers::VOffsetT = 4; + pub const VT_SCHEME: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { CompressionSpec { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args CompressionSpecArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = CompressionSpecBuilder::new(_fbb); builder.add_scheme(args.scheme); builder.finish() @@ -1166,11 +1180,12 @@ impl<'a> CompressionSpec<'a> { } } -impl ::flatbuffers::Verifiable for CompressionSpec<'_> { +impl flatbuffers::Verifiable for CompressionSpec<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("scheme", Self::VT_SCHEME, false)? .finish(); @@ -1189,17 +1204,17 @@ impl<'a> Default for CompressionSpecArgs { } } -pub struct CompressionSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct CompressionSpecBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> CompressionSpecBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> CompressionSpecBuilder<'a, 'b, A> { #[inline] pub fn add_scheme(&mut self, scheme: CompressionScheme) { self.fbb_.push_slot::(CompressionSpec::VT_SCHEME, scheme, CompressionScheme::None); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> CompressionSpecBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> CompressionSpecBuilder<'a, 'b, A> { let start = _fbb.start_table(); CompressionSpecBuilder { fbb_: _fbb, @@ -1207,14 +1222,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> CompressionSpecBuilder<'a, 'b } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for CompressionSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for CompressionSpec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("CompressionSpec"); ds.field("scheme", &self.scheme()); ds.finish() @@ -1224,39 +1239,40 @@ pub enum EncryptionSpecOffset {} #[derive(Copy, Clone, PartialEq)] pub struct EncryptionSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for EncryptionSpec<'a> { +impl<'a> flatbuffers::Follow<'a> for EncryptionSpec<'a> { type Inner = EncryptionSpec<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> EncryptionSpec<'a> { #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { EncryptionSpec { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, _args: &'args EncryptionSpecArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = EncryptionSpecBuilder::new(_fbb); builder.finish() } } -impl ::flatbuffers::Verifiable for EncryptionSpec<'_> { +impl flatbuffers::Verifiable for EncryptionSpec<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .finish(); Ok(()) @@ -1272,13 +1288,13 @@ impl<'a> Default for EncryptionSpecArgs { } } -pub struct EncryptionSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct EncryptionSpecBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> EncryptionSpecBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EncryptionSpecBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> EncryptionSpecBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EncryptionSpecBuilder<'a, 'b, A> { let start = _fbb.start_table(); EncryptionSpecBuilder { fbb_: _fbb, @@ -1286,14 +1302,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> EncryptionSpecBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for EncryptionSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for EncryptionSpec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("EncryptionSpec"); ds.finish() } @@ -1305,8 +1321,8 @@ impl ::core::fmt::Debug for EncryptionSpec<'_> { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_postscript_unchecked`. -pub fn root_as_postscript(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) +pub fn root_as_postscript(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -1315,8 +1331,8 @@ pub fn root_as_postscript(buf: &[u8]) -> Result, ::flatbuffers::I /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_postscript_unchecked`. -pub fn size_prefixed_root_as_postscript(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_postscript(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -1326,10 +1342,10 @@ pub fn size_prefixed_root_as_postscript(buf: &[u8]) -> Result, :: /// previous, unchecked, behavior use /// `root_as_postscript_unchecked`. pub fn root_as_postscript_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -1339,33 +1355,33 @@ pub fn root_as_postscript_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_postscript_unchecked`. pub fn size_prefixed_root_as_postscript_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Postscript and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Postscript`. -pub unsafe fn root_as_postscript_unchecked(buf: &[u8]) -> Postscript<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } +pub unsafe fn root_as_postscript_unchecked(buf: &[u8]) -> Postscript { + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Postscript and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Postscript`. -pub unsafe fn size_prefixed_root_as_postscript_unchecked(buf: &[u8]) -> Postscript<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } +pub unsafe fn size_prefixed_root_as_postscript_unchecked(buf: &[u8]) -> Postscript { + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] -pub fn finish_postscript_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { +pub fn finish_postscript_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_postscript_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_postscript_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/vortex-flatbuffers/src/generated/layout.rs b/vortex-flatbuffers/src/generated/layout.rs index 0c7c7557b74..37395e5a428 100644 --- a/vortex-flatbuffers/src/generated/layout.rs +++ b/vortex-flatbuffers/src/generated/layout.rs @@ -1,7 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify + + // @generated -extern crate alloc; +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; pub enum LayoutOffset {} #[derive(Copy, Clone, PartialEq)] @@ -21,33 +27,33 @@ pub enum LayoutOffset {} /// uses the first byte of the `metadata` array as a boolean to indicate whether the first child Layout represents /// the statistics table for the other chunks. pub struct Layout<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Layout<'a> { +impl<'a> flatbuffers::Follow<'a> for Layout<'a> { type Inner = Layout<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Layout<'a> { - pub const VT_ENCODING: ::flatbuffers::VOffsetT = 4; - pub const VT_ROW_COUNT: ::flatbuffers::VOffsetT = 6; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 8; - pub const VT_CHILDREN: ::flatbuffers::VOffsetT = 10; - pub const VT_SEGMENTS: ::flatbuffers::VOffsetT = 12; + pub const VT_ENCODING: flatbuffers::VOffsetT = 4; + pub const VT_ROW_COUNT: flatbuffers::VOffsetT = 6; + pub const VT_METADATA: flatbuffers::VOffsetT = 8; + pub const VT_CHILDREN: flatbuffers::VOffsetT = 10; + pub const VT_SEGMENTS: flatbuffers::VOffsetT = 12; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Layout { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args LayoutArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = LayoutBuilder::new(_fbb); builder.add_row_count(args.row_count); if let Some(x) = args.segments { builder.add_segments(x); } @@ -77,41 +83,42 @@ impl<'a> Layout<'a> { /// Any additional metadata this layout needs to interpret its children. /// This does not include data-specific metadata, which the layout should store in a segment. #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { + pub fn metadata(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Layout::VT_METADATA, None)} + unsafe { self._tab.get::>>(Layout::VT_METADATA, None)} } /// The children of this Layout. #[inline] - pub fn children(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { + pub fn children(&self) -> Option>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Layout::VT_CHILDREN, None)} + unsafe { self._tab.get::>>>(Layout::VT_CHILDREN, None)} } /// Identifiers for each `SegmentSpec` of data required by this layout. #[inline] - pub fn segments(&self) -> Option<::flatbuffers::Vector<'a, u32>> { + pub fn segments(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u32>>>(Layout::VT_SEGMENTS, None)} + unsafe { self._tab.get::>>(Layout::VT_SEGMENTS, None)} } } -impl ::flatbuffers::Verifiable for Layout<'_> { +impl flatbuffers::Verifiable for Layout<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("encoding", Self::VT_ENCODING, false)? .visit_field::("row_count", Self::VT_ROW_COUNT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("children", Self::VT_CHILDREN, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u32>>>("segments", Self::VT_SEGMENTS, false)? + .visit_field::>>("metadata", Self::VT_METADATA, false)? + .visit_field::>>>("children", Self::VT_CHILDREN, false)? + .visit_field::>>("segments", Self::VT_SEGMENTS, false)? .finish(); Ok(()) } @@ -119,9 +126,9 @@ impl ::flatbuffers::Verifiable for Layout<'_> { pub struct LayoutArgs<'a> { pub encoding: u16, pub row_count: u64, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub children: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub segments: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u32>>>, + pub metadata: Option>>, + pub children: Option>>>>, + pub segments: Option>>, } impl<'a> Default for LayoutArgs<'a> { #[inline] @@ -136,11 +143,11 @@ impl<'a> Default for LayoutArgs<'a> { } } -pub struct LayoutBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct LayoutBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> { #[inline] pub fn add_encoding(&mut self, encoding: u16) { self.fbb_.push_slot::(Layout::VT_ENCODING, encoding, 0); @@ -150,19 +157,19 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> { self.fbb_.push_slot::(Layout::VT_ROW_COUNT, row_count, 0); } #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_METADATA, metadata); + pub fn add_metadata(&mut self, metadata: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Layout::VT_METADATA, metadata); } #[inline] - pub fn add_children(&mut self, children: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_CHILDREN, children); + pub fn add_children(&mut self, children: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Layout::VT_CHILDREN, children); } #[inline] - pub fn add_segments(&mut self, segments: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u32>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_SEGMENTS, segments); + pub fn add_segments(&mut self, segments: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Layout::VT_SEGMENTS, segments); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutBuilder<'a, 'b, A> { let start = _fbb.start_table(); LayoutBuilder { fbb_: _fbb, @@ -170,14 +177,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Layout<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Layout<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Layout"); ds.field("encoding", &self.encoding()); ds.field("row_count", &self.row_count()); @@ -194,8 +201,8 @@ impl ::core::fmt::Debug for Layout<'_> { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_layout_unchecked`. -pub fn root_as_layout(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) +pub fn root_as_layout(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -204,8 +211,8 @@ pub fn root_as_layout(buf: &[u8]) -> Result, ::flatbuffers::InvalidFl /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_layout_unchecked`. -pub fn size_prefixed_root_as_layout(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_layout(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -215,10 +222,10 @@ pub fn size_prefixed_root_as_layout(buf: &[u8]) -> Result, ::flatbuff /// previous, unchecked, behavior use /// `root_as_layout_unchecked`. pub fn root_as_layout_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -228,33 +235,33 @@ pub fn root_as_layout_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_layout_unchecked`. pub fn size_prefixed_root_as_layout_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Layout and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Layout`. -pub unsafe fn root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } +pub unsafe fn root_as_layout_unchecked(buf: &[u8]) -> Layout { + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Layout and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Layout`. -pub unsafe fn size_prefixed_root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } +pub unsafe fn size_prefixed_root_as_layout_unchecked(buf: &[u8]) -> Layout { + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] -pub fn finish_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { +pub fn finish_layout_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_layout_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/vortex-flatbuffers/src/generated/message.rs b/vortex-flatbuffers/src/generated/message.rs index b3e4be76ef7..0748adec10a 100644 --- a/vortex-flatbuffers/src/generated/message.rs +++ b/vortex-flatbuffers/src/generated/message.rs @@ -1,9 +1,15 @@ // automatically generated by the FlatBuffers compiler, do not modify + + // @generated -extern crate alloc; use crate::array::*; use crate::dtype::*; +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_MESSAGE_VERSION: u8 = 0; @@ -35,8 +41,8 @@ impl MessageVersion { } } } -impl ::core::fmt::Debug for MessageVersion { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for MessageVersion { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -44,24 +50,24 @@ impl ::core::fmt::Debug for MessageVersion { } } } -impl<'a> ::flatbuffers::Follow<'a> for MessageVersion { +impl<'a> flatbuffers::Follow<'a> for MessageVersion { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for MessageVersion { +impl flatbuffers::Push for MessageVersion { type Output = MessageVersion; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for MessageVersion { +impl flatbuffers::EndianScalar for MessageVersion { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -75,16 +81,17 @@ impl ::flatbuffers::EndianScalar for MessageVersion { } } -impl<'a> ::flatbuffers::Verifiable for MessageVersion { +impl<'a> flatbuffers::Verifiable for MessageVersion { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for MessageVersion {} +impl flatbuffers::SimpleToVerifyInSlice for MessageVersion {} #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_MESSAGE_HEADER: u8 = 0; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] @@ -127,8 +134,8 @@ impl MessageHeader { } } } -impl ::core::fmt::Debug for MessageHeader { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl core::fmt::Debug for MessageHeader { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -136,24 +143,24 @@ impl ::core::fmt::Debug for MessageHeader { } } } -impl<'a> ::flatbuffers::Follow<'a> for MessageHeader { +impl<'a> flatbuffers::Follow<'a> for MessageHeader { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; + let b = unsafe { flatbuffers::read_scalar_at::(buf, loc) }; Self(b) } } -impl ::flatbuffers::Push for MessageHeader { +impl flatbuffers::Push for MessageHeader { type Output = MessageHeader; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; + unsafe { flatbuffers::emplace_scalar::(dst, self.0); } } } -impl ::flatbuffers::EndianScalar for MessageHeader { +impl flatbuffers::EndianScalar for MessageHeader { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -167,16 +174,17 @@ impl ::flatbuffers::EndianScalar for MessageHeader { } } -impl<'a> ::flatbuffers::Verifiable for MessageHeader { +impl<'a> flatbuffers::Verifiable for MessageHeader { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; u8::run_verifier(v, pos) } } -impl ::flatbuffers::SimpleToVerifyInSlice for MessageHeader {} +impl flatbuffers::SimpleToVerifyInSlice for MessageHeader {} pub struct MessageHeaderUnionTableOffset {} pub enum ArrayMessageOffset {} @@ -184,30 +192,30 @@ pub enum ArrayMessageOffset {} /// Indicates the message body contains a flatbuffer Array message, followed by array buffers. pub struct ArrayMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for ArrayMessage<'a> { +impl<'a> flatbuffers::Follow<'a> for ArrayMessage<'a> { type Inner = ArrayMessage<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> ArrayMessage<'a> { - pub const VT_ROW_COUNT: ::flatbuffers::VOffsetT = 4; - pub const VT_ENCODINGS: ::flatbuffers::VOffsetT = 6; + pub const VT_ROW_COUNT: flatbuffers::VOffsetT = 4; + pub const VT_ENCODINGS: flatbuffers::VOffsetT = 6; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { ArrayMessage { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args ArrayMessageArgs<'args> - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = ArrayMessageBuilder::new(_fbb); if let Some(x) = args.encodings { builder.add_encodings(x); } builder.add_row_count(args.row_count); @@ -225,29 +233,30 @@ impl<'a> ArrayMessage<'a> { } /// The encodings referenced by the array. #[inline] - pub fn encodings(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { + pub fn encodings(&self) -> Option>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(ArrayMessage::VT_ENCODINGS, None)} + unsafe { self._tab.get::>>>(ArrayMessage::VT_ENCODINGS, None)} } } -impl ::flatbuffers::Verifiable for ArrayMessage<'_> { +impl flatbuffers::Verifiable for ArrayMessage<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("row_count", Self::VT_ROW_COUNT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("encodings", Self::VT_ENCODINGS, false)? + .visit_field::>>>("encodings", Self::VT_ENCODINGS, false)? .finish(); Ok(()) } } pub struct ArrayMessageArgs<'a> { pub row_count: u32, - pub encodings: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, + pub encodings: Option>>>, } impl<'a> Default for ArrayMessageArgs<'a> { #[inline] @@ -259,21 +268,21 @@ impl<'a> Default for ArrayMessageArgs<'a> { } } -pub struct ArrayMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct ArrayMessageBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayMessageBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayMessageBuilder<'a, 'b, A> { #[inline] pub fn add_row_count(&mut self, row_count: u32) { self.fbb_.push_slot::(ArrayMessage::VT_ROW_COUNT, row_count, 0); } #[inline] - pub fn add_encodings(&mut self, encodings: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayMessage::VT_ENCODINGS, encodings); + pub fn add_encodings(&mut self, encodings: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(ArrayMessage::VT_ENCODINGS, encodings); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayMessageBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayMessageBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArrayMessageBuilder { fbb_: _fbb, @@ -281,14 +290,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayMessageBuilder<'a, 'b, A } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for ArrayMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for ArrayMessage<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("ArrayMessage"); ds.field("row_count", &self.row_count()); ds.field("encodings", &self.encodings()); @@ -300,29 +309,29 @@ pub enum BufferMessageOffset {} /// Indicates the body contains a regular byte buffer. pub struct BufferMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for BufferMessage<'a> { +impl<'a> flatbuffers::Follow<'a> for BufferMessage<'a> { type Inner = BufferMessage<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> BufferMessage<'a> { - pub const VT_ALIGNMENT_EXPONENT: ::flatbuffers::VOffsetT = 4; + pub const VT_ALIGNMENT_EXPONENT: flatbuffers::VOffsetT = 4; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { BufferMessage { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args BufferMessageArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = BufferMessageBuilder::new(_fbb); builder.add_alignment_exponent(args.alignment_exponent); builder.finish() @@ -338,11 +347,12 @@ impl<'a> BufferMessage<'a> { } } -impl ::flatbuffers::Verifiable for BufferMessage<'_> { +impl flatbuffers::Verifiable for BufferMessage<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("alignment_exponent", Self::VT_ALIGNMENT_EXPONENT, false)? .finish(); @@ -361,17 +371,17 @@ impl<'a> Default for BufferMessageArgs { } } -pub struct BufferMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct BufferMessageBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BufferMessageBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BufferMessageBuilder<'a, 'b, A> { #[inline] pub fn add_alignment_exponent(&mut self, alignment_exponent: u8) { self.fbb_.push_slot::(BufferMessage::VT_ALIGNMENT_EXPONENT, alignment_exponent, 0); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BufferMessageBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BufferMessageBuilder<'a, 'b, A> { let start = _fbb.start_table(); BufferMessageBuilder { fbb_: _fbb, @@ -379,14 +389,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BufferMessageBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for BufferMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for BufferMessage<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("BufferMessage"); ds.field("alignment_exponent", &self.alignment_exponent()); ds.finish() @@ -397,39 +407,40 @@ pub enum DTypeMessageOffset {} /// Indicates the body contains a flatbuffer DType message. pub struct DTypeMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for DTypeMessage<'a> { +impl<'a> flatbuffers::Follow<'a> for DTypeMessage<'a> { type Inner = DTypeMessage<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> DTypeMessage<'a> { #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { DTypeMessage { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, _args: &'args DTypeMessageArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = DTypeMessageBuilder::new(_fbb); builder.finish() } } -impl ::flatbuffers::Verifiable for DTypeMessage<'_> { +impl flatbuffers::Verifiable for DTypeMessage<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .finish(); Ok(()) @@ -445,13 +456,13 @@ impl<'a> Default for DTypeMessageArgs { } } -pub struct DTypeMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct DTypeMessageBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeMessageBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DTypeMessageBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeMessageBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeMessageBuilder<'a, 'b, A> { let start = _fbb.start_table(); DTypeMessageBuilder { fbb_: _fbb, @@ -459,14 +470,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeMessageBuilder<'a, 'b, A } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for DTypeMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for DTypeMessage<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("DTypeMessage"); ds.finish() } @@ -475,32 +486,32 @@ pub enum MessageOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Message<'a> { - pub _tab: ::flatbuffers::Table<'a>, + pub _tab: flatbuffers::Table<'a>, } -impl<'a> ::flatbuffers::Follow<'a> for Message<'a> { +impl<'a> flatbuffers::Follow<'a> for Message<'a> { type Inner = Message<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } + Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } } } } impl<'a> Message<'a> { - pub const VT_VERSION: ::flatbuffers::VOffsetT = 4; - pub const VT_HEADER_TYPE: ::flatbuffers::VOffsetT = 6; - pub const VT_HEADER: ::flatbuffers::VOffsetT = 8; - pub const VT_BODY_SIZE: ::flatbuffers::VOffsetT = 10; + pub const VT_VERSION: flatbuffers::VOffsetT = 4; + pub const VT_HEADER_TYPE: flatbuffers::VOffsetT = 6; + pub const VT_HEADER: flatbuffers::VOffsetT = 8; + pub const VT_BODY_SIZE: flatbuffers::VOffsetT = 10; #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { Message { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, args: &'args MessageArgs - ) -> ::flatbuffers::WIPOffset> { + ) -> flatbuffers::WIPOffset> { let mut builder = MessageBuilder::new(_fbb); builder.add_body_size(args.body_size); if let Some(x) = args.header { builder.add_header(x); } @@ -525,11 +536,11 @@ impl<'a> Message<'a> { unsafe { self._tab.get::(Message::VT_HEADER_TYPE, Some(MessageHeader::NONE)).unwrap()} } #[inline] - pub fn header(&self) -> Option<::flatbuffers::Table<'a>> { + pub fn header(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Message::VT_HEADER, None)} + unsafe { self._tab.get::>>(Message::VT_HEADER, None)} } #[inline] pub fn body_size(&self) -> u64 { @@ -585,18 +596,19 @@ impl<'a> Message<'a> { } -impl ::flatbuffers::Verifiable for Message<'_> { +impl flatbuffers::Verifiable for Message<'_> { #[inline] fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::("version", Self::VT_VERSION, false)? .visit_union::("header_type", Self::VT_HEADER_TYPE, "header", Self::VT_HEADER, false, |key, v, pos| { match key { - MessageHeader::ArrayMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::ArrayMessage", pos), - MessageHeader::BufferMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::BufferMessage", pos), - MessageHeader::DTypeMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::DTypeMessage", pos), + MessageHeader::ArrayMessage => v.verify_union_variant::>("MessageHeader::ArrayMessage", pos), + MessageHeader::BufferMessage => v.verify_union_variant::>("MessageHeader::BufferMessage", pos), + MessageHeader::DTypeMessage => v.verify_union_variant::>("MessageHeader::DTypeMessage", pos), _ => Ok(()), } })? @@ -608,7 +620,7 @@ impl ::flatbuffers::Verifiable for Message<'_> { pub struct MessageArgs { pub version: MessageVersion, pub header_type: MessageHeader, - pub header: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub header: Option>, pub body_size: u64, } impl<'a> Default for MessageArgs { @@ -623,11 +635,11 @@ impl<'a> Default for MessageArgs { } } -pub struct MessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, +pub struct MessageBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MessageBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MessageBuilder<'a, 'b, A> { #[inline] pub fn add_version(&mut self, version: MessageVersion) { self.fbb_.push_slot::(Message::VT_VERSION, version, MessageVersion::V0); @@ -637,15 +649,15 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MessageBuilder<'a, 'b, A> { self.fbb_.push_slot::(Message::VT_HEADER_TYPE, header_type, MessageHeader::NONE); } #[inline] - pub fn add_header(&mut self, header: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Message::VT_HEADER, header); + pub fn add_header(&mut self, header: flatbuffers::WIPOffset) { + self.fbb_.push_slot_always::>(Message::VT_HEADER, header); } #[inline] pub fn add_body_size(&mut self, body_size: u64) { self.fbb_.push_slot::(Message::VT_BODY_SIZE, body_size, 0); } #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MessageBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> MessageBuilder<'a, 'b, A> { let start = _fbb.start_table(); MessageBuilder { fbb_: _fbb, @@ -653,14 +665,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MessageBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) + flatbuffers::WIPOffset::new(o.value()) } } -impl ::core::fmt::Debug for Message<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { +impl core::fmt::Debug for Message<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("Message"); ds.field("version", &self.version()); ds.field("header_type", &self.header_type()); @@ -702,8 +714,8 @@ impl ::core::fmt::Debug for Message<'_> { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_message_unchecked`. -pub fn root_as_message(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) +pub fn root_as_message(buf: &[u8]) -> Result { + flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -712,8 +724,8 @@ pub fn root_as_message(buf: &[u8]) -> Result, ::flatbuffers::Invalid /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `size_prefixed_root_as_message_unchecked`. -pub fn size_prefixed_root_as_message(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_message(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -723,10 +735,10 @@ pub fn size_prefixed_root_as_message(buf: &[u8]) -> Result, ::flatbu /// previous, unchecked, behavior use /// `root_as_message_unchecked`. pub fn root_as_message_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -736,33 +748,33 @@ pub fn root_as_message_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_message_unchecked`. pub fn size_prefixed_root_as_message_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, + opts: &'o flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a Message and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `Message`. -pub unsafe fn root_as_message_unchecked(buf: &[u8]) -> Message<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } +pub unsafe fn root_as_message_unchecked(buf: &[u8]) -> Message { + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed Message and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `Message`. -pub unsafe fn size_prefixed_root_as_message_unchecked(buf: &[u8]) -> Message<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } +pub unsafe fn size_prefixed_root_as_message_unchecked(buf: &[u8]) -> Message { + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] -pub fn finish_message_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { +pub fn finish_message_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { fbb.finish(root, None); } #[inline] -pub fn finish_size_prefixed_message_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_message_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/vortex-proto/proto/dtype.proto b/vortex-proto/proto/dtype.proto index decc2179080..8461be24002 100644 --- a/vortex-proto/proto/dtype.proto +++ b/vortex-proto/proto/dtype.proto @@ -80,6 +80,13 @@ message Union { repeated int32 type_ids = 3; // length must equal dtypes.len(); each value must fit in int8 } +message Map { + DType key_type = 1; + DType value_type = 2; + bool keys_sorted = 3; + bool nullable = 4; +} + message DType { oneof dtype_type { Null null = 1; @@ -94,6 +101,7 @@ message DType { FixedSizeList fixed_size_list = 10; // This is after `Extension` for backwards compatibility. Variant variant = 11; Union union = 12; + Map map = 13; } } diff --git a/vortex-proto/src/generated/vortex.dtype.rs b/vortex-proto/src/generated/vortex.dtype.rs index 4bffca278e2..817576e733f 100644 --- a/vortex-proto/src/generated/vortex.dtype.rs +++ b/vortex-proto/src/generated/vortex.dtype.rs @@ -82,8 +82,22 @@ pub struct Union { pub type_ids: ::prost::alloc::vec::Vec, } #[derive(Clone, PartialEq, ::prost::Message)] +pub struct Map { + #[prost(message, optional, boxed, tag = "1")] + pub key_type: ::core::option::Option<::prost::alloc::boxed::Box>, + #[prost(message, optional, boxed, tag = "2")] + pub value_type: ::core::option::Option<::prost::alloc::boxed::Box>, + #[prost(bool, tag = "3")] + pub keys_sorted: bool, + #[prost(bool, tag = "4")] + pub nullable: bool, +} +#[derive(Clone, PartialEq, ::prost::Message)] pub struct DType { - #[prost(oneof = "d_type::DtypeType", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12")] + #[prost( + oneof = "d_type::DtypeType", + tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13" + )] pub dtype_type: ::core::option::Option, } /// Nested message and enum types in `DType`. @@ -115,6 +129,8 @@ pub mod d_type { Variant(super::Variant), #[prost(message, tag = "12")] Union(super::Union), + #[prost(message, tag = "13")] + Map(::prost::alloc::boxed::Box), } } #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] diff --git a/vortex-python/python/vortex/__init__.py b/vortex-python/python/vortex/__init__.py index ce4e57064ff..157ea4add0b 100644 --- a/vortex-python/python/vortex/__init__.py +++ b/vortex-python/python/vortex/__init__.py @@ -41,6 +41,7 @@ ExtensionDType, FixedSizeListDType, ListDType, + MapDType, NullDType, PrimitiveDType, PType, @@ -54,6 +55,7 @@ float_, int_, list_, + map_, null, struct, time, @@ -72,6 +74,7 @@ # TODO(connor): Is this missing a `DecimalScalar`? ExtensionScalar, ListScalar, + MapScalar, NullScalar, PrimitiveScalar, Scalar, @@ -146,6 +149,7 @@ def cuda_extension_installed() -> bool: "BinaryDType", "StructDType", "ListDType", + "MapDType", "FixedSizeListDType", "ExtensionDType", "null", @@ -158,6 +162,7 @@ def cuda_extension_installed() -> bool: "binary", "struct", "list_", + "map_", "fixed_size_list", "date", "time", @@ -197,6 +202,7 @@ def cuda_extension_installed() -> bool: "BinaryScalar", "StructScalar", "ListScalar", + "MapScalar", "ExtensionScalar", # Serde "ArrayContext", diff --git a/vortex-python/python/vortex/_lib/dtype.pyi b/vortex-python/python/vortex/_lib/dtype.pyi index 9ba6489b0c5..e764dff06e2 100644 --- a/vortex-python/python/vortex/_lib/dtype.pyi +++ b/vortex-python/python/vortex/_lib/dtype.pyi @@ -47,6 +47,9 @@ class ListDType(DType): ... @final class FixedSizeListDType(DType): ... +@final +class MapDType(DType): ... + @final class ExtensionDType(DType): ... @@ -75,6 +78,7 @@ def binary(*, nullable: bool = False) -> DType: ... def struct(fields: dict[str, DType] | None = None, *, nullable: bool = False) -> DType: ... def list_(element: DType, *, nullable: bool = False) -> DType: ... def fixed_size_list(element: DType, size: int, *, nullable: bool = False) -> DType: ... +def map_(key: DType, value: DType, *, keys_sorted: bool = False, nullable: bool = False) -> DType: ... def date(unit: Literal["ms", "days"], *, nullable: bool = False) -> DType: ... def time(unit: Literal["s", "ms", "us", "ns"], *, nullable: bool = False) -> DType: ... def timestamp(unit: Literal["s", "ms", "us", "ns"], *, tz: str | None = None, nullable: bool = False) -> DType: ... diff --git a/vortex-python/python/vortex/_lib/scalar.pyi b/vortex-python/python/vortex/_lib/scalar.pyi index a35b64c8566..0c286083f48 100644 --- a/vortex-python/python/vortex/_lib/scalar.pyi +++ b/vortex-python/python/vortex/_lib/scalar.pyi @@ -4,6 +4,8 @@ from decimal import Decimal from typing import Any, TypeAlias, final +from typing_extensions import override + from .dtype import DType ScalarPyType: TypeAlias = None | int | float | str | Decimal | bytes | list[ScalarPyType] | dict[str, ScalarPyType] @@ -49,6 +51,12 @@ class ListScalar: def as_py(self) -> bool | None: ... def element(self, idx: int) -> Scalar: ... +@final +class MapScalar(Scalar): + @override + def as_py(self) -> ScalarPyType: ... + def entry(self, idx: int) -> tuple[ScalarPyType, ScalarPyType]: ... + @final class ExtensionScalar: def as_py(self) -> ScalarPyType: ... diff --git a/vortex-python/src/dtype/factory.rs b/vortex-python/src/dtype/factory.rs index e337aaf5aec..97c9005813e 100644 --- a/vortex-python/src/dtype/factory.rs +++ b/vortex-python/src/dtype/factory.rs @@ -459,6 +459,37 @@ pub(super) fn dtype_fixed_size_list<'py>( ) } +/// Construct a map data type. +/// +/// Parameters +/// ---------- +/// key : :class:`DType` +/// The non-nullable type of each map key. +/// value : :class:`DType` +/// The type of each map value. +/// keys_sorted : :class:`bool` +/// Whether producers assert that keys are sorted within every map value. +/// nullable : :class:`bool` +/// When :obj:`True`, :obj:`None` is a permissible map value. +#[pyfunction(name = "map_")] +#[pyo3(signature = (key, value, *, keys_sorted = false, nullable = false))] +pub(super) fn dtype_map<'py>( + key: &'py Bound<'py, PyDType>, + value: &'py Bound<'py, PyDType>, + keys_sorted: bool, + nullable: bool, +) -> PyVortexResult> { + Ok(PyDType::init( + key.py(), + DType::map( + key.get().inner().clone(), + value.get().inner().clone(), + keys_sorted, + nullable.into(), + )?, + )?) +} + fn parse_time_unit(unit: &str) -> PyResult { match unit { "ns" => Ok(TimeUnit::Nanoseconds), diff --git a/vortex-python/src/dtype/map.rs b/vortex-python/src/dtype/map.rs new file mode 100644 index 00000000000..39dc7b76cb0 --- /dev/null +++ b/vortex-python/src/dtype/map.rs @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use pyo3::prelude::*; + +use crate::dtype::PyDType; + +/// Concrete class for map dtypes. +#[pyclass(name = "MapDType", module = "vortex", extends=PyDType, frozen)] +pub(crate) struct PyMapDType; diff --git a/vortex-python/src/dtype/mod.rs b/vortex-python/src/dtype/mod.rs index ce18ceb6d83..ea39f3d310d 100644 --- a/vortex-python/src/dtype/mod.rs +++ b/vortex-python/src/dtype/mod.rs @@ -8,6 +8,7 @@ mod extension; mod factory; mod fixed_size_list; mod list; +mod map; mod null; mod primitive; mod ptype; @@ -46,6 +47,7 @@ use crate::dtype::decimal::PyDecimalDType; use crate::dtype::extension::PyExtensionDType; use crate::dtype::fixed_size_list::PyFixedSizeListDType; use crate::dtype::list::PyListDType; +use crate::dtype::map::PyMapDType; use crate::dtype::null::PyNullDType; use crate::dtype::primitive::PyPrimitiveDType; use crate::dtype::struct_::PyStructDType; @@ -73,6 +75,7 @@ pub(crate) fn init(py: Python, parent: &Bound) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; + m.add_class::()?; m.add_class::()?; // Register factory functions. @@ -87,6 +90,7 @@ pub(crate) fn init(py: Python, parent: &Bound) -> PyResult<()> { m.add_function(wrap_pyfunction!(factory::dtype_struct, &m)?)?; m.add_function(wrap_pyfunction!(factory::dtype_list, &m)?)?; m.add_function(wrap_pyfunction!(factory::dtype_fixed_size_list, &m)?)?; + m.add_function(wrap_pyfunction!(factory::dtype_map, &m)?)?; m.add_function(wrap_pyfunction!(factory::dtype_date, &m)?)?; m.add_function(wrap_pyfunction!(factory::dtype_time, &m)?)?; m.add_function(wrap_pyfunction!(factory::dtype_timestamp, &m)?)?; @@ -134,6 +138,7 @@ impl PyDType { DType::Binary(..) => Self::with_subclass(py, dtype, PyBinaryDType), DType::List(..) => Self::with_subclass(py, dtype, PyListDType), DType::FixedSizeList(..) => Self::with_subclass(py, dtype, PyFixedSizeListDType), + DType::Map(..) => Self::with_subclass(py, dtype, PyMapDType), DType::Struct(..) => Self::with_subclass(py, dtype, PyStructDType), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => Err(PyValueError::new_err( diff --git a/vortex-python/src/python_repr.rs b/vortex-python/src/python_repr.rs index 56819184dca..e01788e0f5c 100644 --- a/vortex-python/src/python_repr.rs +++ b/vortex-python/src/python_repr.rs @@ -80,6 +80,14 @@ impl Display for DTypePythonRepr<'_> { size, n.python_repr() ), + DType::Map(map, n) => write!( + f, + "map_({}, {}, keys_sorted={}, nullable={})", + map.key_dtype().python_repr(), + map.value_dtype().python_repr(), + if map.keys_sorted() { "True" } else { "False" }, + n.python_repr() + ), DType::Struct(st, n) => write!( f, "struct({{{}}}, nullable={})", diff --git a/vortex-python/src/scalar/factory.rs b/vortex-python/src/scalar/factory.rs index 90e1c2031f7..c2e0459ce19 100644 --- a/vortex-python/src/scalar/factory.rs +++ b/vortex-python/src/scalar/factory.rs @@ -13,6 +13,7 @@ use pyo3::types::PyFloat; use pyo3::types::PyInt; use pyo3::types::PyList; use pyo3::types::PyString; +use pyo3::types::PyTuple; use vortex::dtype::DType; use vortex::dtype::FieldName; use vortex::dtype::FieldNames; @@ -132,6 +133,20 @@ fn scalar_helper_inner(value: &Bound<'_, PyAny>, dtype: Option<&DType>) -> PyRes // dict if let Ok(dict) = value.cast::() { + if let Some(map_dtype @ DType::Map(map, _)) = dtype { + let entries = dict + .iter() + .map(|(key, value)| { + Ok(( + scalar_helper(&key, Some(&map.key_dtype()))?, + scalar_helper(&value, Some(&map.value_dtype()))?, + )) + }) + .collect::>>()?; + return Scalar::try_map(map_dtype.clone(), entries) + .map_err(|err| PyValueError::new_err(err.to_string())); + } + // Extract the field names from the dictionary keys let names: FieldNames = dict .keys() @@ -177,16 +192,31 @@ fn scalar_helper_inner(value: &Bound<'_, PyAny>, dtype: Option<&DType>) -> PyRes } if let Ok(list) = value.cast::() { + if let Some(map_dtype @ DType::Map(map, _)) = dtype { + let entries = list + .iter() + .map(|entry| { + let (key, value) = map_entry(&entry)?; + Ok(( + scalar_helper(&key, Some(&map.key_dtype()))?, + scalar_helper(&value, Some(&map.value_dtype()))?, + )) + }) + .collect::>>()?; + return Scalar::try_map(map_dtype.clone(), entries) + .map_err(|err| PyValueError::new_err(err.to_string())); + } + if let Some(DType::List(element_dtype, ..)) = dtype { let elements = list .iter() .map(|e| scalar_helper_inner(&e, Some(element_dtype))) .try_collect()?; - Scalar::list( + return Ok(Scalar::list( Arc::clone(element_dtype), elements, Nullability::NonNullable, - ); + )); } else { // If no dtype was provided, we need to infer the element dtype from the list contents. // We do this in a greedy way taking the first element dtype we find. @@ -217,3 +247,19 @@ fn scalar_helper_inner(value: &Bound<'_, PyAny>, dtype: Option<&DType>) -> PyRes value.get_type() ))) } + +fn map_entry<'py>(entry: &Bound<'py, PyAny>) -> PyResult<(Bound<'py, PyAny>, Bound<'py, PyAny>)> { + if let Ok(pair) = entry.cast::() + && pair.len() == 2 + { + return Ok((pair.get_item(0)?, pair.get_item(1)?)); + } + if let Ok(pair) = entry.cast::() + && pair.len() == 2 + { + return Ok((pair.get_item(0)?, pair.get_item(1)?)); + } + Err(PyValueError::new_err( + "Map scalars constructed from a list must contain two-item tuples or lists", + )) +} diff --git a/vortex-python/src/scalar/into_py.rs b/vortex-python/src/scalar/into_py.rs index a3b81ab6b2e..c4d1403246e 100644 --- a/vortex-python/src/scalar/into_py.rs +++ b/vortex-python/src/scalar/into_py.rs @@ -16,6 +16,7 @@ use pyo3::types::PyBytes; use pyo3::types::PyDict; use pyo3::types::PyList; use pyo3::types::PyString; +use pyo3::types::PyTuple; use vortex::array::match_each_decimal_value; use vortex::buffer::BufferString; use vortex::buffer::ByteBuffer; @@ -27,6 +28,7 @@ use vortex::error::VortexExpect; use vortex::error::vortex_err; use vortex::scalar::DecimalValue; use vortex::scalar::ListScalar; +use vortex::scalar::MapScalar; use vortex::scalar::Scalar; use vortex::scalar::StructScalar; @@ -83,6 +85,7 @@ impl<'py> IntoPyObject<'py> for PyVortex<&'_ Scalar> { DType::List(..) | DType::FixedSizeList(..) => { PyVortex(self.0.as_list()).into_pyobject(py) } + DType::Map(..) => PyVortex(self.0.as_map()).into_pyobject(py), DType::Struct(..) => PyVortex(self.0.as_struct()).into_pyobject(py), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => Err(PyValueError::new_err( @@ -148,6 +151,52 @@ impl<'py> IntoPyObject<'py> for PyVortex> { } } +impl<'py> IntoPyObject<'py> for PyVortex> { + type Target = PyAny; + type Output = Bound<'py, Self::Target>; + type Error = PyErr; + + fn into_pyobject(self, py: Python<'py>) -> Result { + if self.0.is_null() { + return Ok(py.None().into_pyobject(py)?); + } + + let entries = self + .0 + .entries() + .map(|(key, value)| { + Ok(( + PyVortex(&key).into_pyobject(py)?, + PyVortex(&value).into_pyobject(py)?, + )) + }) + .collect::>>()?; + + let dictionary = PyDict::new(py); + for (key, value) in &entries { + if dictionary.set_item(key, value).is_err() { + return map_entries_to_py_list(py, &entries); + } + } + if dictionary.len() == entries.len() { + return Ok(dictionary.into_any()); + } + + map_entries_to_py_list(py, &entries) + } +} + +fn map_entries_to_py_list<'py>( + py: Python<'py>, + entries: &[(Bound<'py, PyAny>, Bound<'py, PyAny>)], +) -> PyResult> { + let entries = entries + .iter() + .map(|(key, value)| PyTuple::new(py, [key.clone(), value.clone()])) + .collect::>>()?; + Ok(PyList::new(py, entries)?.into_any()) +} + trait DecimalIntoParts: Sized { /// Split an integer encoding a decimal with the given `scale` into a /// (whole number, decimal) parts. diff --git a/vortex-python/src/scalar/map.rs b/vortex-python/src/scalar/map.rs new file mode 100644 index 00000000000..0c4ef9ac87d --- /dev/null +++ b/vortex-python/src/scalar/map.rs @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use pyo3::IntoPyObject; +use pyo3::Py; +use pyo3::PyAny; +use pyo3::PyRef; +use pyo3::PyResult; +use pyo3::exceptions::PyIndexError; +use pyo3::pyclass; +use pyo3::pymethods; +use vortex::scalar::MapScalar; +use vortex::scalar::Scalar; + +use crate::PyVortex; +use crate::scalar::AsScalarRef; +use crate::scalar::PyScalar; +use crate::scalar::ScalarSubclass; + +/// Concrete class for map scalars. +#[pyclass(name = "MapScalar", module = "vortex", extends=PyScalar, frozen)] +pub(crate) struct PyMapScalar; + +impl ScalarSubclass for PyMapScalar { + type Scalar<'a> = MapScalar<'a>; +} + +#[pymethods] +impl PyMapScalar { + /// Return the Python key and value at the given entry index. + pub fn entry(self_: PyRef<'_, Self>, idx: usize) -> PyResult<(Py, Py)> { + let scalar = self_.as_scalar_ref(); + let (key, value) = scalar + .entry(idx) + .ok_or_else(|| PyIndexError::new_err(format!("Index out of bounds {idx}")))?; + Ok(( + PyVortex::<&Scalar>(&key).into_pyobject(self_.py())?.into(), + PyVortex::<&Scalar>(&value) + .into_pyobject(self_.py())? + .into(), + )) + } +} diff --git a/vortex-python/src/scalar/mod.rs b/vortex-python/src/scalar/mod.rs index eea66dccc52..e8654fc9248 100644 --- a/vortex-python/src/scalar/mod.rs +++ b/vortex-python/src/scalar/mod.rs @@ -14,6 +14,7 @@ mod extension; pub mod factory; mod into_py; mod list; +mod map; mod null; mod primitive; mod struct_; @@ -35,6 +36,7 @@ use crate::scalar::bool::PyBoolScalar; use crate::scalar::decimal::PyDecimalScalar; use crate::scalar::extension::PyExtensionScalar; use crate::scalar::list::PyListScalar; +use crate::scalar::map::PyMapScalar; use crate::scalar::null::PyNullScalar; use crate::scalar::primitive::PyPrimitiveScalar; use crate::scalar::struct_::PyStructScalar; @@ -53,6 +55,7 @@ pub(crate) fn init(py: Python, parent: &Bound) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; + m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; @@ -116,6 +119,7 @@ impl PyScalar { // of "fixed-size" only applies to full arrays, not scalars. Self::with_subclass(py, scalar, PyListScalar) } + DType::Map(..) => Self::with_subclass(py, scalar, PyMapScalar), DType::Struct(..) => Self::with_subclass(py, scalar, PyStructScalar), DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => Err(PyValueError::new_err( diff --git a/vortex-python/test/test_dtype.py b/vortex-python/test/test_dtype.py index 5c65f6cd23e..1aea531769d 100644 --- a/vortex-python/test/test_dtype.py +++ b/vortex-python/test/test_dtype.py @@ -14,3 +14,12 @@ def test_factories(): assert str(vx.uint(32)) == "u32" assert str(vx.float_(16)) == "f16" assert str(vx.struct({"a": vx.int_(nullable=True)})) == "{a=i64?}" + + +def test_map_factory(): + dtype = vx.map_(vx.int_(), vx.utf8(nullable=True), keys_sorted=True, nullable=True) + + assert isinstance(dtype, vx.MapDType) + assert dtype.is_nullable() + assert str(dtype) == "map(i64, utf8?, keys_sorted=true)?" + assert "keys_sorted=True" in repr(dtype) diff --git a/vortex-python/test/test_scalar.py b/vortex-python/test/test_scalar.py index 0f9a593814c..814dcce7a7d 100644 --- a/vortex-python/test/test_scalar.py +++ b/vortex-python/test/test_scalar.py @@ -35,3 +35,27 @@ def test_f16(): scalar = vx.scalar(1.0, dtype=vx.float_(16)) assert scalar.dtype == vx.float_(16) assert scalar.as_py() == 1.0 + + +def test_map_scalar_from_dict(): + dtype = vx.map_(vx.int_(), vx.utf8(nullable=True), keys_sorted=True, nullable=True) + scalar = vx.scalar({1: "one", 2: None}, dtype=dtype) + + assert isinstance(scalar, vx.MapScalar) + assert scalar.dtype == dtype + assert scalar.as_py() == {1: "one", 2: None} + key, value = scalar.entry(0) + assert key == 1 + assert value == "one" + + +def test_map_scalar_preserves_duplicate_and_unhashable_keys_as_pairs(): + duplicate_dtype = vx.map_(vx.int_(), vx.utf8()) + duplicate = vx.scalar([(1, "first"), (1, "second")], dtype=duplicate_dtype) + assert isinstance(duplicate, vx.MapScalar) + assert duplicate.as_py() == [(1, "first"), (1, "second")] + + list_key_dtype = vx.map_(vx.list_(vx.int_()), vx.utf8()) + unhashable = vx.scalar([([1, 2], "value")], dtype=list_key_dtype) + assert isinstance(unhashable, vx.MapScalar) + assert unhashable.as_py() == [([1, 2], "value")] diff --git a/vortex-row/src/codec.rs b/vortex-row/src/codec.rs index fd14bb254b8..8b72f07bc4b 100644 --- a/vortex-row/src/codec.rs +++ b/vortex-row/src/codec.rs @@ -220,9 +220,9 @@ pub(crate) fn row_width_for_dtype(dtype: &DType) -> VortexResult { } Ok(RowWidth::Fixed(total)) } - DType::List(..) => { + DType::List(..) | DType::Map(..) => { vortex_bail!( - "row encoding does not support variable-size List arrays (no well-defined ordering)" + "row encoding does not support variable-size List or Map arrays (no well-defined ordering)" ) } DType::Variant(_) => { From 042b69d386e5dec4a76be1c46e416b928c9978ec Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Fri, 17 Jul 2026 23:50:53 +0100 Subject: [PATCH 2/2] . Signed-off-by: Adam Gutglick --- fuzz/src/array/fill_null.rs | 1 + fuzz/src/array/mask.rs | 1 + fuzz/src/array/scalar_at.rs | 1 + .../src/aggregate_fn/fns/is_constant/mod.rs | 3 + .../src/aggregate_fn/fns/min_max/mod.rs | 1 + .../fns/uncompressed_size_in_bytes/mod.rs | 18 +- .../src/arrays/constant/vtable/canonical.rs | 12 +- vortex-array/src/arrays/dict/execute.rs | 1 + vortex-array/src/arrays/filter/execute/mod.rs | 11 +- vortex-array/src/arrays/filter/vtable.rs | 2 +- vortex-array/src/arrays/map/array.rs | 197 ++++++++++++-- vortex-array/src/arrays/map/mod.rs | 10 +- vortex-array/src/arrays/map/tests.rs | 255 ++++++++++++++++++ vortex-array/src/arrays/map/vtable/mod.rs | 153 ++++++++++- .../src/arrays/map/vtable/operations.rs | 33 ++- .../src/arrays/map/vtable/validity.rs | 12 +- vortex-array/src/arrays/masked/execute.rs | 2 + vortex-array/src/arrays/mod.rs | 4 +- vortex-array/src/builders/map.rs | 159 +++++++++++ vortex-array/src/builders/mod.rs | 27 +- vortex-array/src/canonical.rs | 97 ++++++- vortex-array/src/scalar_fn/fns/cast/mod.rs | 1 + vortex-array/src/session/mod.rs | 2 + vortex-compressor/src/compressor/cascade.rs | 2 + vortex-duckdb/src/exporter/canonical.rs | 1 + 25 files changed, 960 insertions(+), 46 deletions(-) create mode 100644 vortex-array/src/arrays/map/tests.rs create mode 100644 vortex-array/src/builders/map.rs diff --git a/fuzz/src/array/fill_null.rs b/fuzz/src/array/fill_null.rs index f3a49b25637..edf8629b6a3 100644 --- a/fuzz/src/array/fill_null.rs +++ b/fuzz/src/array/fill_null.rs @@ -47,6 +47,7 @@ pub fn fill_null_canonical_array( } Canonical::Struct(_) | Canonical::List(_) + | Canonical::Map(_) | Canonical::FixedSizeList(_) | Canonical::Extension(_) => canonical.into_array().fill_null(fill_value.clone())?, Canonical::Variant(_) => unreachable!("Variant arrays are not fuzzed"), diff --git a/fuzz/src/array/mask.rs b/fuzz/src/array/mask.rs index f3cecec2b10..db4f98c05ad 100644 --- a/fuzz/src/array/mask.rs +++ b/fuzz/src/array/mask.rs @@ -149,6 +149,7 @@ pub fn mask_canonical_array( .with_nullability(masked_storage.dtype().nullability()); ExtensionArray::new(ext_dtype, masked_storage).into_array() } + Canonical::Map(_) => unreachable!("Map arrays are not fuzzed"), Canonical::Variant(_) => unreachable!("Variant arrays are not fuzzed"), }) } diff --git a/fuzz/src/array/scalar_at.rs b/fuzz/src/array/scalar_at.rs index e13ad75343d..b164a324fdf 100644 --- a/fuzz/src/array/scalar_at.rs +++ b/fuzz/src/array/scalar_at.rs @@ -104,6 +104,7 @@ pub fn scalar_at_canonical_array( let storage_scalar = scalar_at_canonical_array(storage_canonical, index, ctx)?; Scalar::extension_ref(array.ext_dtype().clone(), storage_scalar) } + Canonical::Map(_) => unreachable!("Map arrays are not fuzzed"), Canonical::Variant(_) => unreachable!("Variant arrays are not fuzzed"), }) } diff --git a/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs b/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs index 490ede7f640..a622d087fce 100644 --- a/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs @@ -402,6 +402,9 @@ impl AggregateFnVTable for IsConstant { Canonical::Struct(s) => check_struct_constant(s, ctx)?, Canonical::Extension(e) => check_extension_constant(e, ctx)?, Canonical::List(l) => check_listview_constant(l, ctx)?, + Canonical::Map(_) => { + vortex_bail!("Map arrays don't support IsConstant") + } Canonical::FixedSizeList(f) => check_fixed_size_list_constant(f, ctx)?, Canonical::Null(_) => true, Canonical::Variant(_) => { diff --git a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs index 51601ce76fd..63ce214c74e 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs @@ -419,6 +419,7 @@ impl AggregateFnVTable for MinMax { Canonical::Null(_) => Ok(()), Canonical::Struct(_) | Canonical::List(_) + | Canonical::Map(_) | Canonical::FixedSizeList(_) | Canonical::Variant(_) => { vortex_bail!("Unsupported canonical type for min_max: {}", batch.dtype()) diff --git a/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs b/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs index 752cf952a5e..4e77719cabf 100644 --- a/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/uncompressed_size_in_bytes/mod.rs @@ -43,6 +43,7 @@ use crate::aggregate_fn::EmptyOptions; use crate::array::ArrayView; use crate::arrays::Constant; use crate::arrays::ConstantArray; +use crate::arrays::map::MapArrayExt; use crate::arrays::varbinview::BinaryView; use crate::dtype::DType; use crate::dtype::DecimalType; @@ -197,6 +198,9 @@ pub(crate) fn canonical_uncompressed_size_in_bytes( Canonical::Decimal(array) => decimal_uncompressed_size_in_bytes(array, ctx), Canonical::VarBinView(array) => varbinview_uncompressed_size_in_bytes(array, ctx), Canonical::List(array) => list_view_uncompressed_size_in_bytes(array, ctx), + Canonical::Map(array) => { + list_view_uncompressed_size_in_bytes(&array.entries().into_owned(), ctx) + } Canonical::FixedSizeList(array) => fixed_size_list_uncompressed_size_in_bytes(array, ctx), Canonical::Struct(array) => struct_uncompressed_size_in_bytes(array, ctx), Canonical::Extension(array) => extension_uncompressed_size_in_bytes(array, ctx), @@ -229,13 +233,14 @@ pub(crate) fn constant_uncompressed_size_in_bytes( array.len(), array.scalar().as_binary().value().map(|value| value.len()), )?, - DType::List(..) | DType::FixedSizeList(..) | DType::Struct(..) | DType::Extension(_) => { + DType::List(..) + | DType::Map(..) + | DType::FixedSizeList(..) + | DType::Struct(..) + | DType::Extension(_) => { let canonical = array.array().clone().execute::(ctx)?; return canonical_uncompressed_size_in_bytes(&canonical, ctx); } - DType::Map(..) => { - vortex_bail!("UncompressedSizeInBytes is not supported for map arrays yet") - } DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"), DType::Variant(_) => { vortex_bail!("UncompressedSizeInBytes is not supported for Variant arrays") @@ -289,7 +294,10 @@ fn supports_uncompressed_size_in_bytes(dtype: &DType) -> bool { DType::List(element_dtype, _) | DType::FixedSizeList(element_dtype, ..) => { supports_uncompressed_size_in_bytes(element_dtype) } - DType::Map(..) => false, + DType::Map(map_dtype, _) => { + supports_uncompressed_size_in_bytes(&map_dtype.key_dtype()) + && supports_uncompressed_size_in_bytes(&map_dtype.value_dtype()) + } DType::Struct(fields, _) => fields .fields() .all(|field| supports_uncompressed_size_in_bytes(&field)), diff --git a/vortex-array/src/arrays/constant/vtable/canonical.rs b/vortex-array/src/arrays/constant/vtable/canonical.rs index 1f15a7e9f3b..44ca6c513be 100644 --- a/vortex-array/src/arrays/constant/vtable/canonical.rs +++ b/vortex-array/src/arrays/constant/vtable/canonical.rs @@ -20,6 +20,7 @@ use crate::arrays::DecimalArray; use crate::arrays::ExtensionArray; use crate::arrays::FixedSizeListArray; use crate::arrays::ListViewArray; +use crate::arrays::MapArray; use crate::arrays::NullArray; use crate::arrays::PrimitiveArray; use crate::arrays::StructArray; @@ -126,7 +127,16 @@ pub(crate) fn constant_canonicalize( )) } DType::List(..) => Canonical::List(constant_canonical_list_array(scalar, array.len())), - DType::Map(..) => vortex_error::vortex_bail!("canonical map arrays are not yet supported"), + DType::Map(map_dtype, nullability) => { + let entries_scalar = Scalar::try_new( + DType::List(Arc::new(map_dtype.entries_dtype()), *nullability), + scalar.value().cloned(), + )?; + Canonical::Map(MapArray::try_new( + map_dtype.clone(), + constant_canonical_list_array(&entries_scalar, array.len()), + )?) + } DType::FixedSizeList(element_dtype, list_size, _) => { let value = scalar.as_list(); diff --git a/vortex-array/src/arrays/dict/execute.rs b/vortex-array/src/arrays/dict/execute.rs index 47a9a051666..0ba1d31a6ea 100644 --- a/vortex-array/src/arrays/dict/execute.rs +++ b/vortex-array/src/arrays/dict/execute.rs @@ -49,6 +49,7 @@ pub(crate) fn take_canonical( Canonical::Decimal(a) => Canonical::Decimal(take_decimal(&a, codes, ctx)), Canonical::VarBinView(a) => Canonical::VarBinView(take_varbinview(&a, codes, ctx)), Canonical::List(a) => Canonical::List(take_listview(&a, codes, ctx)), + Canonical::Map(_) => vortex_error::vortex_bail!("Map arrays don't support take"), Canonical::FixedSizeList(a) => { Canonical::FixedSizeList(take_fixed_size_list(&a, codes, ctx)) } diff --git a/vortex-array/src/arrays/filter/execute/mod.rs b/vortex-array/src/arrays/filter/execute/mod.rs index 52b0373ac49..2ceb8ce22fb 100644 --- a/vortex-array/src/arrays/filter/execute/mod.rs +++ b/vortex-array/src/arrays/filter/execute/mod.rs @@ -9,6 +9,7 @@ use std::sync::Arc; use vortex_error::VortexExpect; use vortex_error::VortexResult; +use vortex_error::vortex_bail; use vortex_mask::Mask; use vortex_mask::MaskValues; @@ -83,14 +84,18 @@ pub(super) fn execute_filter_fast_paths( } /// Filter a canonical array by a mask, returning a new canonical array. -pub(super) fn execute_filter(canonical: Canonical, mask: &Arc) -> Canonical { - match canonical { +pub(super) fn execute_filter( + canonical: Canonical, + mask: &Arc, +) -> VortexResult { + Ok(match canonical { Canonical::Null(_) => Canonical::Null(NullArray::new(mask.true_count())), Canonical::Bool(a) => Canonical::Bool(bool::filter_bool(&a, mask)), Canonical::Primitive(a) => Canonical::Primitive(primitive::filter_primitive(&a, mask)), Canonical::Decimal(a) => Canonical::Decimal(decimal::filter_decimal(&a, mask)), Canonical::VarBinView(a) => Canonical::VarBinView(varbinview::filter_varbinview(&a, mask)), Canonical::List(a) => Canonical::List(listview::filter_listview(&a, mask)), + Canonical::Map(_) => vortex_bail!("Map arrays don't support filter"), Canonical::FixedSizeList(a) => { Canonical::FixedSizeList(fixed_size_list::filter_fixed_size_list(&a, mask)) } @@ -118,5 +123,5 @@ pub(super) fn execute_filter(canonical: Canonical, mask: &Arc) -> Ca .vortex_expect("filtered VariantArray children are row-aligned"), ) } - } + }) } diff --git a/vortex-array/src/arrays/filter/vtable.rs b/vortex-array/src/arrays/filter/vtable.rs index 0f54a97c574..7cc4f9ea645 100644 --- a/vortex-array/src/arrays/filter/vtable.rs +++ b/vortex-array/src/arrays/filter/vtable.rs @@ -168,7 +168,7 @@ impl VTable for Filter { // TODO(joe): fix the ownership of AnyCanonical let child = Canonical::from(array.child().as_::()); Ok(ExecutionResult::done( - execute_filter(child, &mask_values).into_array(), + execute_filter(child, &mask_values)?.into_array(), )) } diff --git a/vortex-array/src/arrays/map/array.rs b/vortex-array/src/arrays/map/array.rs index 6ad0180b46b..73a7e4db6bf 100644 --- a/vortex-array/src/arrays/map/array.rs +++ b/vortex-array/src/arrays/map/array.rs @@ -1,27 +1,190 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -/// Placeholder for Vortex's canonical map array. -/// -/// Its physical storage layout will be defined when map array support is implemented. -#[derive(Clone, Debug, Default)] -pub struct MapArray; +use std::fmt::Display; +use std::fmt::Formatter; +use std::hash::Hasher; +use std::sync::Arc; + +use smallvec::smallvec; +use vortex_error::VortexExpect; +use vortex_error::VortexResult; +use vortex_error::vortex_ensure; -/// Placeholder for map-array metadata that is independent of child slots. +use crate::ArrayEq; +use crate::ArrayHash; +use crate::ArrayRef; +use crate::EqMode; +use crate::IntoArray; +use crate::array::Array; +use crate::array::ArrayParts; +use crate::array::ArrayView; +use crate::array::TypedArrayRef; +use crate::arrays::ListView; +use crate::arrays::ListViewArray; +use crate::arrays::listview::ListViewArrayExt; +use crate::arrays::map::Map; +use crate::dtype::DType; +use crate::dtype::MapDType; +use crate::validity::Validity; + +/// The one child slot holding a [`ListViewArray`] of map entries. +pub(super) const ENTRIES_SLOT: usize = 0; +pub(super) const NUM_SLOTS: usize = 1; +pub(super) const SLOT_NAMES: [&str; NUM_SLOTS] = ["entries"]; + +/// Encoding-specific metadata for [`MapArray`]. /// -/// Fields will be added with the selected canonical map layout. +/// All map metadata is represented by the outer [`DType::Map`] and the entries child, so this +/// value is intentionally empty. #[derive(Clone, Debug, Default)] pub struct MapData; -/// Placeholder for the inputs used to construct a [`MapArray`]. -/// -/// Its fields will be defined with the selected canonical map layout. -#[derive(Clone, Debug, Default)] -pub struct MapDataParts; +impl Display for MapData { + fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result { + Ok(()) + } +} -/// Marker trait for map-array accessors. -/// -/// Logical accessors will be added once the physical layout is selected. -pub trait MapArrayExt {} +impl ArrayEq for MapData { + fn array_eq(&self, _other: &Self, _accuracy: EqMode) -> bool { + true + } +} + +impl ArrayHash for MapData { + fn array_hash(&self, _state: &mut H, _accuracy: EqMode) {} +} + +/// The logical and physical inputs used to construct a [`MapArray`]. +pub struct MapDataParts { + /// The key/value type and sortedness assertion for the map. + pub map_dtype: MapDType, + /// The physical list-view storage of `{key, value}` entry structs. + pub entries: ListViewArray, +} + +/// Accessors for the canonical map representation. +pub trait MapArrayExt: TypedArrayRef { + /// Returns the list-view storage of map entry structs. + fn entries(&self) -> ArrayView<'_, ListView> { + self.as_ref().slots()[ENTRIES_SLOT] + .as_ref() + .vortex_expect("MapArray entries slot") + .as_::() + } + + /// Returns the entry structs for one map row. + fn entries_at(&self, index: usize) -> VortexResult { + self.entries().list_elements_at(index) + } + + /// Returns the number of entries in one map row. + fn entry_count_at(&self, index: usize) -> usize { + self.entries().size_at(index) + } + + /// Returns the outer map validity delegated from the entries list-view. + fn map_validity(&self) -> Validity { + self.entries().listview_validity() + } + + /// Returns this map's key/value type information. + fn map_dtype(&self) -> &MapDType { + self.as_ref() + .dtype() + .as_map_opt() + .vortex_expect("MapArray requires a map dtype") + } + + /// Returns whether producers assert sorted keys within each map value. + fn keys_sorted(&self) -> bool { + self.map_dtype().keys_sorted() + } +} +impl> MapArrayExt for T {} + +impl Array { + /// Creates a canonical map array from its map dtype and list-view entry storage. + /// + /// # Panics + /// + /// Panics if `entries` is not a list of the map dtype's non-nullable `{key, value}` entry + /// struct with matching outer nullability. + pub fn new(map_dtype: MapDType, entries: ListViewArray) -> Self { + Self::try_new(map_dtype, entries).vortex_expect("MapArray construction failed") + } + + /// Constructs a canonical map array from its map dtype and list-view entry storage. + /// + /// # Errors + /// + /// Returns an error when the entry child is not `ListView>`, has a + /// different outer nullability, or has a different length than the outer map array. + pub fn try_new(map_dtype: MapDType, entries: ListViewArray) -> VortexResult { + let nullability = entries.nullability(); + let dtype = DType::Map(map_dtype, nullability); + let len = entries.len(); + let parts = ArrayParts::new(Map, dtype, len, MapData) + .with_slots(smallvec![Some(entries.into_array())]); + Self::try_from_parts(parts) + } + + /// Creates a canonical map array without validating its entry storage. + /// + /// # Safety + /// + /// The caller must ensure that `entries` has dtype + /// `List(Struct { key, value }, entries.nullability())`, where the struct exactly matches + /// `map_dtype.entries_dtype()`. + pub unsafe fn new_unchecked(map_dtype: MapDType, entries: ListViewArray) -> Self { + let nullability = entries.nullability(); + let dtype = DType::Map(map_dtype, nullability); + let len = entries.len(); + let parts = ArrayParts::new(Map, dtype, len, MapData) + .with_slots(smallvec![Some(entries.into_array())]); + unsafe { Self::from_parts_unchecked(parts) } + } + + /// Decomposes this map array into its logical dtype and physical entries child. + pub fn into_data_parts(self) -> MapDataParts { + let map_dtype = self + .dtype() + .as_map_opt() + .vortex_expect("MapArray requires a map dtype") + .clone(); + let entries = self.entries().into_owned(); + MapDataParts { map_dtype, entries } + } +} + +fn expected_entries_dtype(map_dtype: &MapDType, nullability: crate::dtype::Nullability) -> DType { + DType::List(Arc::new(map_dtype.entries_dtype()), nullability) +} + +pub(super) fn validate_entries( + map_dtype: &MapDType, + nullability: crate::dtype::Nullability, + len: usize, + entries: &ArrayRef, +) -> VortexResult<()> { + vortex_ensure!( + entries.is::(), + "MapArray entries must use vortex.listview encoding, got {}", + entries.encoding_id() + ); + vortex_ensure!( + entries.len() == len, + "MapArray entries length {} does not match outer length {len}", + entries.len() + ); + + let expected_dtype = expected_entries_dtype(map_dtype, nullability); + vortex_ensure!( + entries.dtype() == &expected_dtype, + "MapArray entries dtype {} does not match expected {expected_dtype}", + entries.dtype() + ); -impl MapArrayExt for MapArray {} + Ok(()) +} diff --git a/vortex-array/src/arrays/map/mod.rs b/vortex-array/src/arrays/map/mod.rs index a38751230dc..f7215b133a4 100644 --- a/vortex-array/src/arrays/map/mod.rs +++ b/vortex-array/src/arrays/map/mod.rs @@ -1,13 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -//! Canonical map array scaffolding. -//! -//! The physical layout for maps has not been selected yet. This module only reserves the -//! standard canonical-array structure and public type names. +//! Canonical map arrays backed by [`ListView`](crate::arrays::ListView) entry storage. mod array; -pub use array::MapArray; pub use array::MapArrayExt; pub use array::MapData; pub use array::MapDataParts; @@ -16,3 +12,7 @@ pub(crate) mod compute; mod vtable; pub use vtable::Map; +pub use vtable::MapArray; + +#[cfg(test)] +mod tests; diff --git a/vortex-array/src/arrays/map/tests.rs b/vortex-array/src/arrays/map/tests.rs new file mode 100644 index 00000000000..7a856943031 --- /dev/null +++ b/vortex-array/src/arrays/map/tests.rs @@ -0,0 +1,255 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use smallvec::smallvec; +use vortex_buffer::ByteBufferMut; +use vortex_error::VortexResult; +use vortex_session::registry::ReadContext; + +use crate::Array; +use crate::ArrayContext; +use crate::ArrayParts; +use crate::ArrayVTable; +use crate::Canonical; +use crate::IntoArray; +use crate::VortexSessionExecute; +use crate::array_session; +use crate::arrays::ChunkedArray; +use crate::arrays::ConstantArray; +use crate::arrays::ListViewArray; +use crate::arrays::Map; +use crate::arrays::MapArray; +use crate::arrays::PrimitiveArray; +use crate::arrays::map::MapArrayExt; +use crate::arrays::map::MapData; +use crate::arrays::map::MapDataParts; +use crate::builders::ArrayBuilder; +use crate::builders::MapBuilder; +use crate::dtype::DType; +use crate::dtype::MapDType; +use crate::dtype::Nullability; +use crate::dtype::PType; +use crate::scalar::Scalar; +use crate::serde::SerializeOptions; +use crate::serde::SerializedArray; +use crate::session::ArraySessionExt; +use crate::validity::Validity; + +fn map_dtype() -> VortexResult { + MapDType::try_new( + DType::Primitive(PType::I32, Nullability::NonNullable), + DType::Utf8(Nullability::Nullable), + true, + ) +} + +fn key(value: i32) -> Scalar { + Scalar::primitive(value, Nullability::NonNullable) +} + +fn value(value: Option<&str>) -> Scalar { + match value { + Some(value) => Scalar::utf8(value, Nullability::Nullable), + None => Scalar::null(DType::Utf8(Nullability::Nullable)), + } +} + +fn sample_scalar(dtype: DType) -> VortexResult { + Scalar::try_map( + dtype, + [ + (key(2), value(Some("two"))), + (key(1), value(None)), + (key(2), value(Some("duplicate"))), + ], + ) +} + +fn sample_array() -> VortexResult { + let map_dtype = map_dtype()?; + let dtype = DType::Map(map_dtype.clone(), Nullability::Nullable); + let mut builder = MapBuilder::::with_capacity(map_dtype, Nullability::Nullable, 3); + builder.append_scalar(&sample_scalar(dtype.clone())?)?; + builder.append_scalar(&Scalar::try_map(dtype.clone(), [])?)?; + builder.append_scalar(&Scalar::null(dtype))?; + Ok(builder.finish_into_map()) +} + +#[test] +fn constructs_map_with_listview_entries() -> VortexResult<()> { + let MapDataParts { map_dtype, entries } = sample_array()?.into_data_parts(); + let array = MapArray::try_new(map_dtype.clone(), entries)?; + + assert_eq!( + array.dtype(), + &DType::Map(map_dtype.clone(), Nullability::Nullable) + ); + assert!(array.keys_sorted()); + assert_eq!(array.entry_count_at(0), 3); + assert_eq!(array.entry_count_at(1), 0); + assert_eq!(array.entries_at(0)?.dtype(), &map_dtype.entries_dtype()); + + let mut ctx = array_session().create_execution_ctx(); + assert_eq!( + array + .map_validity() + .execute_mask(array.len(), &mut ctx)? + .true_count(), + 2 + ); + + Ok(()) +} + +#[test] +fn accepts_duplicate_and_unsorted_keys() -> VortexResult<()> { + let array = sample_array()?; + let mut ctx = array_session().create_execution_ctx(); + + assert_eq!( + array.execute_scalar(0, &mut ctx)?, + sample_scalar(array.dtype().clone())? + ); + + Ok(()) +} + +#[test] +fn rejects_malformed_entry_storage() -> VortexResult<()> { + let map_dtype = map_dtype()?; + let offsets = PrimitiveArray::from_iter([0u64]).into_array(); + let sizes = PrimitiveArray::from_iter([1u64]).into_array(); + let non_struct_entries = ListViewArray::try_new( + PrimitiveArray::from_iter([1i32]).into_array(), + offsets, + sizes, + Validity::NonNullable, + )?; + assert!(MapArray::try_new(map_dtype.clone(), non_struct_entries).is_err()); + + let nullable_entry_struct = + ConstantArray::new(Scalar::null(map_dtype.entries_dtype().as_nullable()), 1).into_array(); + let null_entries = ListViewArray::try_new( + nullable_entry_struct, + PrimitiveArray::from_iter([0u64]).into_array(), + PrimitiveArray::from_iter([1u64]).into_array(), + Validity::NonNullable, + )?; + assert!(MapArray::try_new(map_dtype.clone(), null_entries).is_err()); + + let MapDataParts { entries, .. } = sample_array()?.into_data_parts(); + let parts = ArrayParts::new( + Map, + DType::Map(map_dtype, Nullability::NonNullable), + entries.len(), + MapData, + ) + .with_slots(smallvec![Some(entries.into_array())]); + assert!(Array::::try_from_parts(parts).is_err()); + + assert!( + MapDType::try_new( + DType::Primitive(PType::I32, Nullability::Nullable), + DType::Utf8(Nullability::Nullable), + false, + ) + .is_err() + ); + + Ok(()) +} + +#[test] +fn scalar_access_preserves_null_and_empty_maps() -> VortexResult<()> { + let array = sample_array()?; + let mut ctx = array_session().create_execution_ctx(); + + assert_eq!( + array.execute_scalar(0, &mut ctx)?, + sample_scalar(array.dtype().clone())? + ); + assert!(array.execute_scalar(1, &mut ctx)?.as_map().is_empty()); + assert!(array.execute_scalar(2, &mut ctx)?.is_null()); + + Ok(()) +} + +#[test] +fn builder_appends_existing_map_arrays() -> VortexResult<()> { + let source = sample_array()?; + let mut builder = MapBuilder::::with_capacity( + source.map_dtype().clone(), + source.dtype().nullability(), + 0, + ); + let mut ctx = array_session().create_execution_ctx(); + builder.append_map_array(source.as_view(), &mut ctx)?; + builder.append_map_array(source.as_view(), &mut ctx)?; + let array = builder.finish_into_map(); + + assert_eq!(array.len(), 6); + assert_eq!( + array.execute_scalar(0, &mut ctx)?, + source.execute_scalar(0, &mut ctx)? + ); + assert!(array.execute_scalar(2, &mut ctx)?.is_null()); + assert_eq!( + array.execute_scalar(3, &mut ctx)?, + source.execute_scalar(0, &mut ctx)? + ); + + Ok(()) +} + +#[test] +fn canonicalizes_empty_constant_and_chunked_maps() -> VortexResult<()> { + let map_dtype = map_dtype()?; + let dtype = DType::Map(map_dtype, Nullability::Nullable); + let empty = Canonical::empty(&dtype); + assert!(empty.as_map().is_empty()); + + let mut ctx = array_session().create_execution_ctx(); + let constant = ConstantArray::new(sample_scalar(dtype.clone())?, 2) + .into_array() + .execute::(&mut ctx)?; + assert_eq!(constant.as_map().len(), 2); + + let first = sample_array()?.into_array(); + let second = sample_array()?.into_array(); + let chunked = ChunkedArray::try_new(vec![first, second], dtype)?.into_array(); + let canonical = chunked.execute::(&mut ctx)?; + assert_eq!(canonical.as_map().len(), 6); + + Ok(()) +} + +#[test] +fn serde_roundtrip_uses_registered_map_vtable() -> VortexResult<()> { + let session = array_session(); + assert!(session.arrays().registry().find(&Map.id()).is_some()); + + let array = sample_array()?.into_array(); + let dtype = array.dtype().clone(); + let len = array.len(); + let array_ctx = ArrayContext::empty(); + let serialized = array.serialize(&array_ctx, &session, &SerializeOptions::default())?; + let mut concat = ByteBufferMut::empty(); + for buffer in serialized { + concat.extend_from_slice(buffer.as_ref()); + } + + let serialized = SerializedArray::try_from(concat.freeze())?; + let decoded = + serialized.decode(&dtype, len, &ReadContext::new(array_ctx.to_ids()), &session)?; + assert!(decoded.is::()); + + let mut ctx = session.create_execution_ctx(); + for index in 0..len { + assert_eq!( + decoded.execute_scalar(index, &mut ctx)?, + array.execute_scalar(index, &mut ctx)? + ); + } + + Ok(()) +} diff --git a/vortex-array/src/arrays/map/vtable/mod.rs b/vortex-array/src/arrays/map/vtable/mod.rs index 0292b50a437..7e4e2f67d3d 100644 --- a/vortex-array/src/arrays/map/vtable/mod.rs +++ b/vortex-array/src/arrays/map/vtable/mod.rs @@ -1,11 +1,160 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +use smallvec::smallvec; +use vortex_error::VortexResult; +use vortex_error::vortex_bail; +use vortex_error::vortex_ensure; +use vortex_error::vortex_panic; +use vortex_session::VortexSession; +use vortex_session::registry::CachedId; + +use crate::ArrayParts; +use crate::ArrayRef; +use crate::ExecutionCtx; +use crate::ExecutionResult; +use crate::array::Array; +use crate::array::ArrayId; +use crate::array::ArrayView; +use crate::array::VTable; +use crate::array::ValidityVTableFromChild; +use crate::array::with_empty_buffers; +use crate::arrays::ListView; +use crate::arrays::map::MapData; +use crate::arrays::map::array::ENTRIES_SLOT; +use crate::arrays::map::array::NUM_SLOTS; +use crate::arrays::map::array::SLOT_NAMES; +use crate::arrays::map::array::validate_entries; +use crate::buffer::BufferHandle; +use crate::builders::ArrayBuilder; +use crate::dtype::DType; +use crate::serde::ArrayChildren; + mod operations; mod validity; -/// Placeholder encoding marker for [`super::MapArray`]. +/// A [`Map`]-encoded Vortex array. +pub type MapArray = Array; + +/// The canonical encoding for [`DType::Map`]. /// -/// The corresponding vtable will be implemented with the canonical map array layout. +/// A map array has one `ListView>` child. Its outer dtype retains map-specific +/// metadata such as the `keys_sorted` assertion. #[derive(Clone, Debug, Default)] pub struct Map; + +impl VTable for Map { + type TypedArrayData = MapData; + + type OperationsVTable = Self; + type ValidityVTable = ValidityVTableFromChild; + + fn id(&self) -> ArrayId { + static ID: CachedId = CachedId::new("vortex.map"); + *ID + } + + fn validate( + &self, + _data: &MapData, + dtype: &DType, + len: usize, + slots: &[Option], + ) -> VortexResult<()> { + vortex_ensure!( + slots.len() == NUM_SLOTS, + "MapArray expected {NUM_SLOTS} slot, found {}", + slots.len() + ); + + let DType::Map(map_dtype, nullability) = dtype else { + vortex_bail!("Expected map dtype, got {dtype}"); + }; + let entries = slots[ENTRIES_SLOT] + .as_ref() + .ok_or_else(|| vortex_error::vortex_err!("MapArray missing entries slot"))?; + validate_entries(map_dtype, *nullability, len, entries) + } + + fn nbuffers(_array: ArrayView<'_, Self>) -> usize { + 0 + } + + fn buffer(_array: ArrayView<'_, Self>, idx: usize) -> BufferHandle { + vortex_panic!("MapArray buffer index {idx} out of bounds") + } + + fn buffer_name(_array: ArrayView<'_, Self>, _idx: usize) -> Option { + None + } + + fn with_buffers( + &self, + array: ArrayView<'_, Self>, + buffers: &[BufferHandle], + ) -> VortexResult> { + with_empty_buffers(self, array, buffers) + } + + fn serialize( + _array: ArrayView<'_, Self>, + _session: &VortexSession, + ) -> VortexResult>> { + Ok(Some(vec![])) + } + + fn deserialize( + &self, + dtype: &DType, + len: usize, + metadata: &[u8], + buffers: &[BufferHandle], + children: &dyn ArrayChildren, + _session: &VortexSession, + ) -> VortexResult> { + if !metadata.is_empty() { + vortex_bail!( + "MapArray expects empty metadata, got {} bytes", + metadata.len() + ); + } + vortex_ensure!(buffers.is_empty(), "MapArray expects no buffers"); + + let DType::Map(map_dtype, nullability) = dtype else { + vortex_bail!("Expected map dtype, got {dtype}"); + }; + vortex_ensure!( + children.len() == NUM_SLOTS, + "MapArray expected {NUM_SLOTS} child, found {}", + children.len() + ); + + let expected_entries_dtype = + DType::List(std::sync::Arc::new(map_dtype.entries_dtype()), *nullability); + let entries = children.get(ENTRIES_SLOT, &expected_entries_dtype, len)?; + vortex_ensure!( + entries.is::(), + "MapArray entries must use vortex.listview encoding, got {}", + entries.encoding_id() + ); + + Ok(ArrayParts::new(self.clone(), dtype.clone(), len, MapData) + .with_slots(smallvec![Some(entries)])) + } + + fn slot_name(_array: ArrayView<'_, Self>, idx: usize) -> String { + SLOT_NAMES[idx].to_string() + } + + fn execute(array: Array, _ctx: &mut ExecutionCtx) -> VortexResult { + Ok(ExecutionResult::done(array)) + } + + fn append_to_builder( + array: ArrayView<'_, Self>, + builder: &mut dyn ArrayBuilder, + ctx: &mut ExecutionCtx, + ) -> VortexResult<()> { + builder.append_map_array(array, ctx) + } +} diff --git a/vortex-array/src/arrays/map/vtable/operations.rs b/vortex-array/src/arrays/map/vtable/operations.rs index 21e55849123..d6e8fe87f12 100644 --- a/vortex-array/src/arrays/map/vtable/operations.rs +++ b/vortex-array/src/arrays/map/vtable/operations.rs @@ -1,4 +1,35 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -//! Map array vtable operations will live here. +use vortex_error::VortexResult; + +use crate::ExecutionCtx; +use crate::array::ArrayView; +use crate::array::OperationsVTable; +use crate::arrays::Map; +use crate::arrays::StructArray; +use crate::arrays::map::MapArrayExt; +use crate::arrays::struct_::StructArrayExt; +use crate::scalar::Scalar; + +impl OperationsVTable for Map { + fn scalar_at( + array: ArrayView<'_, Map>, + index: usize, + ctx: &mut ExecutionCtx, + ) -> VortexResult { + let entries = array.entries_at(index)?.execute::(ctx)?; + let keys = entries.unmasked_field(0); + let values = entries.unmasked_field(1); + let pairs = (0..entries.len()) + .map(|entry_index| { + Ok(( + keys.execute_scalar(entry_index, ctx)?, + values.execute_scalar(entry_index, ctx)?, + )) + }) + .collect::>>()?; + + Scalar::try_map(array.dtype().clone(), pairs) + } +} diff --git a/vortex-array/src/arrays/map/vtable/validity.rs b/vortex-array/src/arrays/map/vtable/validity.rs index 85b1a782ddb..0cdc1f886cb 100644 --- a/vortex-array/src/arrays/map/vtable/validity.rs +++ b/vortex-array/src/arrays/map/vtable/validity.rs @@ -1,4 +1,14 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -//! Map array validity handling will live here. +use crate::ArrayRef; +use crate::array::ArrayView; +use crate::array::ValidityChild; +use crate::arrays::Map; +use crate::arrays::map::MapArrayExt; + +impl ValidityChild for Map { + fn validity_child(array: ArrayView<'_, Map>) -> ArrayRef { + array.entries().array().clone() + } +} diff --git a/vortex-array/src/arrays/masked/execute.rs b/vortex-array/src/arrays/masked/execute.rs index c4173dd0cf6..b00d1eee304 100644 --- a/vortex-array/src/arrays/masked/execute.rs +++ b/vortex-array/src/arrays/masked/execute.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use vortex_error::VortexResult; +use vortex_error::vortex_bail; use crate::Canonical; use crate::IntoArray; @@ -46,6 +47,7 @@ pub fn mask_validity_canonical( Canonical::Decimal(a) => Canonical::Decimal(mask_validity_decimal(a, validity)?), Canonical::VarBinView(a) => Canonical::VarBinView(mask_validity_varbinview(a, validity)?), Canonical::List(a) => Canonical::List(mask_validity_listview(a, validity)?), + Canonical::Map(_) => vortex_bail!("Map arrays don't support masking"), Canonical::FixedSizeList(a) => { Canonical::FixedSizeList(mask_validity_fixed_size_list(a, validity)?) } diff --git a/vortex-array/src/arrays/mod.rs b/vortex-array/src/arrays/mod.rs index 43178a4a3cf..baf338cef4a 100644 --- a/vortex-array/src/arrays/mod.rs +++ b/vortex-array/src/arrays/mod.rs @@ -5,8 +5,8 @@ //! //! Canonical arrays are the default uncompressed representation for a logical dtype: //! [`NullArray`], [`BoolArray`], [`PrimitiveArray`], [`DecimalArray`], [`VarBinViewArray`], -//! [`ListViewArray`], [`FixedSizeListArray`], [`StructArray`], [`ExtensionArray`], and -//! [`VariantArray`]. +//! [`ListViewArray`], [`MapArray`], [`FixedSizeListArray`], [`StructArray`], +//! [`ExtensionArray`], and [`VariantArray`]. //! //! Utility and lazy arrays represent common transformations without immediately materializing //! their result. Examples include [`ChunkedArray`] for concatenation, [`ConstantArray`] for repeated diff --git a/vortex-array/src/builders/map.rs b/vortex-array/src/builders/map.rs new file mode 100644 index 00000000000..a95f9367f12 --- /dev/null +++ b/vortex-array/src/builders/map.rs @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use std::any::Any; +use std::sync::Arc; + +use vortex_error::VortexResult; +use vortex_error::vortex_ensure; +use vortex_mask::Mask; + +use crate::ArrayRef; +use crate::Canonical; +use crate::ExecutionCtx; +use crate::IntoArray; +use crate::array::ArrayView; +use crate::arrays::Map; +use crate::arrays::MapArray; +use crate::arrays::map::MapArrayExt; +use crate::builders::ArrayBuilder; +use crate::builders::DEFAULT_BUILDER_CAPACITY; +use crate::builders::ListViewBuilder; +use crate::dtype::DType; +use crate::dtype::IntegerPType; +use crate::dtype::MapDType; +use crate::dtype::Nullability; +use crate::scalar::MapScalar; +use crate::scalar::Scalar; + +/// A builder for canonical [`MapArray`] values. +/// +/// The builder owns a [`ListViewBuilder`] whose elements are non-nullable `{key, value}` structs. +/// It preserves the map dtype's `keys_sorted` assertion while delegating offsets, sizes, and outer +/// validity to that list-view builder. +pub struct MapBuilder { + dtype: DType, + map_dtype: MapDType, + entries_builder: ListViewBuilder, +} + +impl MapBuilder { + /// Creates a map builder with the default capacity. + pub fn new(map_dtype: MapDType, nullability: Nullability) -> Self { + Self::with_capacity(map_dtype, nullability, DEFAULT_BUILDER_CAPACITY) + } + + /// Creates a map builder with space for `capacity` map rows. + pub fn with_capacity(map_dtype: MapDType, nullability: Nullability, capacity: usize) -> Self { + let entries_builder = ListViewBuilder::with_capacity( + Arc::new(map_dtype.entries_dtype()), + nullability, + capacity.saturating_mul(2), + capacity, + ); + let dtype = DType::Map(map_dtype.clone(), nullability); + Self { + dtype, + map_dtype, + entries_builder, + } + } + + /// Appends one map scalar. + pub fn append_value(&mut self, value: MapScalar<'_>) -> VortexResult<()> { + vortex_ensure!( + value.dtype() == &self.dtype, + "MapBuilder expected map scalar with dtype {}, got {}", + self.dtype, + value.dtype() + ); + + if value.is_null() { + self.entries_builder.append_null(); + return Ok(()); + } + + let entry_dtype = self.map_dtype.entries_dtype(); + let entries = value + .entries() + .map(|(key, value)| Scalar::struct_(entry_dtype.clone(), vec![key, value])) + .collect(); + let entries = Scalar::list(Arc::new(entry_dtype), entries, self.dtype.nullability()); + self.entries_builder.append_value(entries.as_list()) + } + + /// Finishes the builder directly into a [`MapArray`]. + pub fn finish_into_map(&mut self) -> MapArray { + MapArray::new( + self.map_dtype.clone(), + self.entries_builder.finish_into_listview(), + ) + } +} + +impl ArrayBuilder for MapBuilder { + fn as_any(&self) -> &dyn Any { + self + } + + fn as_any_mut(&mut self) -> &mut dyn Any { + self + } + + fn dtype(&self) -> &DType { + &self.dtype + } + + fn len(&self) -> usize { + self.entries_builder.len() + } + + fn append_zeros(&mut self, n: usize) { + self.entries_builder.append_zeros(n); + } + + unsafe fn append_nulls_unchecked(&mut self, n: usize) { + unsafe { self.entries_builder.append_nulls_unchecked(n) }; + } + + fn append_scalar(&mut self, scalar: &Scalar) -> VortexResult<()> { + vortex_ensure!( + scalar.dtype() == self.dtype(), + "MapBuilder expected scalar with dtype {}, got {}", + self.dtype(), + scalar.dtype() + ); + self.append_value(scalar.as_map()) + } + + fn reserve_exact(&mut self, additional: usize) { + self.entries_builder.reserve_exact(additional); + } + + unsafe fn set_validity_unchecked(&mut self, validity: Mask) { + unsafe { self.entries_builder.set_validity_unchecked(validity) }; + } + + fn finish(&mut self) -> ArrayRef { + self.finish_into_map().into_array() + } + + fn finish_into_canonical(&mut self, _ctx: &mut ExecutionCtx) -> Canonical { + Canonical::Map(self.finish_into_map()) + } + + fn append_map_array( + &mut self, + array: ArrayView<'_, Map>, + ctx: &mut ExecutionCtx, + ) -> VortexResult<()> { + vortex_ensure!( + array.dtype() == self.dtype(), + "MapBuilder expected map array with dtype {}, got {}", + self.dtype(), + array.dtype() + ); + self.entries_builder + .append_listview_array(array.entries(), ctx) + } +} diff --git a/vortex-array/src/builders/mod.rs b/vortex-array/src/builders/mod.rs index aae935fc430..17d6ba6195e 100644 --- a/vortex-array/src/builders/mod.rs +++ b/vortex-array/src/builders/mod.rs @@ -42,6 +42,7 @@ use crate::ExecutionCtx; use crate::array::ArrayView; use crate::arrays::List; use crate::arrays::ListView; +use crate::arrays::Map; use crate::canonical::Canonical; use crate::dtype::DType; use crate::match_each_decimal_value_type; @@ -59,6 +60,7 @@ mod extension; mod fixed_size_list; mod list; mod listview; +mod map; mod null; mod primitive; mod struct_; @@ -70,6 +72,7 @@ pub use extension::*; pub use fixed_size_list::*; pub use list::*; pub use listview::*; +pub use map::*; pub use null::*; pub use primitive::*; pub use struct_::*; @@ -228,6 +231,22 @@ pub trait ArrayBuilder: Send { self.dtype() ) } + + /// Appends the values of a [`Map`]-encoded `array` to this builder. + /// + /// Only map-typed builders support this; canonical map arrays dispatch through this hook so + /// the generic offset and size types of their nested list-view builders stay erased. + fn append_map_array( + &mut self, + array: ArrayView<'_, Map>, + _ctx: &mut ExecutionCtx, + ) -> VortexResult<()> { + vortex_bail!( + "cannot append a Map array of dtype {} to a {} builder", + array.dtype(), + self.dtype() + ) + } } /// Construct a new canonical builder for the given [`DType`]. @@ -288,9 +307,11 @@ pub fn builder_with_capacity(dtype: &DType, capacity: usize) -> Box { - vortex_error::vortex_panic!(InvalidArgument: "map builders are not yet supported") - } + DType::Map(map_dtype, nullability) => Box::new(MapBuilder::::with_capacity( + map_dtype.clone(), + *nullability, + capacity, + )), DType::FixedSizeList(elem_dtype, list_size, null) => { Box::new(FixedSizeListBuilder::with_capacity( Arc::clone(elem_dtype), diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index d725bb65632..269b4d9bd7f 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -29,6 +29,8 @@ use crate::arrays::FixedSizeList; use crate::arrays::FixedSizeListArray; use crate::arrays::ListView; use crate::arrays::ListViewArray; +use crate::arrays::Map; +use crate::arrays::MapArray; use crate::arrays::Null; use crate::arrays::NullArray; use crate::arrays::Primitive; @@ -45,6 +47,7 @@ use crate::arrays::extension::ExtensionArrayExt; use crate::arrays::fixed_size_list::FixedSizeListArrayExt; use crate::arrays::listview::ListViewDataParts; use crate::arrays::listview::ListViewRebuildMode; +use crate::arrays::map::MapArrayExt; use crate::arrays::primitive::PrimitiveDataParts; use crate::arrays::struct_::StructDataParts; use crate::arrays::varbinview::VarBinViewDataParts; @@ -80,8 +83,9 @@ use crate::validity::Validity; /// /// # Arrow interoperability /// -/// All of the Vortex canonical encodings have an equivalent Arrow encoding that can be built -/// zero-copy, and the corresponding Arrow array types can also be built directly. +/// Most Vortex canonical encodings have an equivalent Arrow encoding that can be built zero-copy, +/// and the corresponding Arrow array types can also be built directly. Map array Arrow transport +/// is not implemented yet. /// /// The full list of canonical types and their equivalent Arrow array types are: /// @@ -91,6 +95,7 @@ use crate::validity::Validity; /// * `DecimalArray`: `arrow_array::Decimal128Array` and `arrow_array::Decimal256Array` /// * `VarBinViewArray`: `arrow_array::GenericByteViewArray` /// * `ListViewArray`: `arrow_array::ListViewArray` +/// * `MapArray`: Vortex `ListView>` storage /// * `FixedSizeListArray`: `arrow_array::FixedSizeListArray` /// * `StructArray`: `arrow_array::StructArray` /// @@ -126,6 +131,7 @@ pub enum Canonical { Decimal(DecimalArray), VarBinView(VarBinViewArray), List(ListViewArray), + Map(MapArray), FixedSizeList(FixedSizeListArray), Struct(StructArray), /// Canonical storage for extension dtypes, wrapping the canonical form of the storage dtype. @@ -144,6 +150,7 @@ macro_rules! match_each_canonical { Canonical::Decimal($ident) => $eval, Canonical::VarBinView($ident) => $eval, Canonical::List($ident) => $eval, + Canonical::Map($ident) => $eval, Canonical::FixedSizeList($ident) => $eval, Canonical::Struct($ident) => $eval, Canonical::Variant($ident) => $eval, @@ -209,9 +216,14 @@ impl Canonical { // An empty list view is trivially copyable to a list. .with_zero_copy_to_list(true) }), - DType::Map(..) => { - vortex_panic!(InvalidArgument: "canonical map arrays are not yet supported") - } + DType::Map(map_dtype, nullability) => Canonical::Map(MapArray::new( + map_dtype.clone(), + Canonical::empty(&DType::List( + Arc::new(map_dtype.entries_dtype()), + *nullability, + )) + .into_listview(), + )), DType::FixedSizeList(elem_dtype, list_size, null) => Canonical::FixedSizeList(unsafe { FixedSizeListArray::new_unchecked( Canonical::empty(elem_dtype).into_array(), @@ -269,6 +281,13 @@ impl Canonical { Canonical::List(array) => Ok(Canonical::List( array.rebuild(ListViewRebuildMode::TrimElements, ctx)?, )), + Canonical::Map(array) => Ok(Canonical::Map(MapArray::new( + array.map_dtype().clone(), + array + .entries() + .into_owned() + .rebuild(ListViewRebuildMode::TrimElements, ctx)?, + ))), _ => Ok(self.clone()), } } @@ -372,6 +391,22 @@ impl Canonical { } } + pub fn as_map(&self) -> &MapArray { + if let Canonical::Map(a) = self { + a + } else { + vortex_panic!("Cannot get MapArray from {:?}", &self) + } + } + + pub fn into_map(self) -> MapArray { + if let Canonical::Map(a) = self { + a + } else { + vortex_panic!("Cannot unwrap MapArray from {:?}", &self) + } + } + pub fn as_fixed_size_list(&self) -> &FixedSizeListArray { if let Canonical::FixedSizeList(a) = self { a @@ -460,6 +495,10 @@ pub trait ToCanonical { #[deprecated(note = "use `array.execute::(ctx)` instead")] fn to_listview(&self) -> ListViewArray; + /// Canonicalize into a [`MapArray`] if the target is [`Map`](DType::Map) typed. + #[deprecated(note = "use `array.execute::(ctx)` instead")] + fn to_map(&self) -> MapArray; + /// Canonicalize into a [`FixedSizeListArray`] if the target is [`List`](DType::FixedSizeList) /// typed. #[deprecated(note = "use `array.execute::(ctx)` instead")] @@ -515,6 +554,12 @@ impl ToCanonical for ArrayRef { result.into_listview() } + fn to_map(&self) -> MapArray { + #[expect(deprecated)] + let result = self.to_canonical().vortex_expect("to_canonical failed"); + result.into_map() + } + fn to_fixed_size_list(&self) -> FixedSizeListArray { #[expect(deprecated)] let result = self.to_canonical().vortex_expect("to_canonical failed"); @@ -634,6 +679,18 @@ impl Executable for CanonicalValidity { .with_zero_copy_to_list(zctl) }))) } + Canonical::Map(map) => { + let map_dtype = map.map_dtype().clone(); + let entries = map.entries().into_owned(); + Ok(CanonicalValidity(Canonical::Map(MapArray::new( + map_dtype, + entries + .into_array() + .execute::(ctx)? + .0 + .into_listview(), + )))) + } Canonical::FixedSizeList(fsl) => { let list_size = fsl.list_size(); let len = fsl.len(); @@ -796,6 +853,18 @@ impl Executable for RecursiveCanonical { .with_zero_copy_to_list(zctl) }))) } + Canonical::Map(map) => { + let map_dtype = map.map_dtype().clone(); + let entries = map.entries().into_owned(); + Ok(RecursiveCanonical(Canonical::Map(MapArray::new( + map_dtype, + entries + .into_array() + .execute::(ctx)? + .0 + .into_listview(), + )))) + } Canonical::FixedSizeList(fsl) => { let list_size = fsl.list_size(); let len = fsl.len(); @@ -982,6 +1051,18 @@ impl Executable for ListViewArray { } } +/// Execute the array to canonical form and unwrap as a [`MapArray`]. +/// +/// This will panic if the array's dtype is not map. +impl Executable for MapArray { + fn execute(array: ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult { + match array.try_downcast::() { + Ok(map) => Ok(map), + Err(array) => Ok(Canonical::execute(array, ctx)?.into_map()), + } + } +} + /// Execute the array to canonical form and unwrap as a [`FixedSizeListArray`]. /// /// This will panic if the array's dtype is not fixed size list. @@ -1033,6 +1114,7 @@ pub enum CanonicalView<'a> { Decimal(ArrayView<'a, Decimal>), VarBinView(ArrayView<'a, VarBinView>), List(ArrayView<'a, ListView>), + Map(ArrayView<'a, Map>), FixedSizeList(ArrayView<'a, FixedSizeList>), Struct(ArrayView<'a, Struct>), Extension(ArrayView<'a, Extension>), @@ -1048,6 +1130,7 @@ impl From> for Canonical { CanonicalView::Decimal(a) => Canonical::Decimal(a.into_owned()), CanonicalView::VarBinView(a) => Canonical::VarBinView(a.into_owned()), CanonicalView::List(a) => Canonical::List(a.into_owned()), + CanonicalView::Map(a) => Canonical::Map(a.into_owned()), CanonicalView::FixedSizeList(a) => Canonical::FixedSizeList(a.into_owned()), CanonicalView::Struct(a) => Canonical::Struct(a.into_owned()), CanonicalView::Extension(a) => Canonical::Extension(a.into_owned()), @@ -1066,6 +1149,7 @@ impl CanonicalView<'_> { CanonicalView::Decimal(a) => a.array().clone(), CanonicalView::VarBinView(a) => a.array().clone(), CanonicalView::List(a) => a.array().clone(), + CanonicalView::Map(a) => a.array().clone(), CanonicalView::FixedSizeList(a) => a.array().clone(), CanonicalView::Struct(a) => a.array().clone(), CanonicalView::Extension(a) => a.array().clone(), @@ -1087,6 +1171,7 @@ impl Matcher for AnyCanonical { || array.is::() || array.is::() || array.is::() + || array.is::() || array.is::() || array.is::() || array.is::() @@ -1107,6 +1192,8 @@ impl Matcher for AnyCanonical { Some(CanonicalView::Struct(a)) } else if let Some(a) = array.as_opt::() { Some(CanonicalView::List(a)) + } else if let Some(a) = array.as_opt::() { + Some(CanonicalView::Map(a)) } else if let Some(a) = array.as_opt::() { Some(CanonicalView::FixedSizeList(a)) } else if let Some(a) = array.as_opt::() { diff --git a/vortex-array/src/scalar_fn/fns/cast/mod.rs b/vortex-array/src/scalar_fn/fns/cast/mod.rs index 20852779d42..bb545a56846 100644 --- a/vortex-array/src/scalar_fn/fns/cast/mod.rs +++ b/vortex-array/src/scalar_fn/fns/cast/mod.rs @@ -183,6 +183,7 @@ fn cast_canonical( CanonicalView::Decimal(a) => ::cast(a, dtype, ctx), CanonicalView::VarBinView(a) => ::cast(a, dtype, ctx), CanonicalView::List(a) => ::cast(a, dtype, ctx), + CanonicalView::Map(_) => vortex_bail!("Map arrays don't support casting"), CanonicalView::FixedSizeList(a) => ::cast(a, dtype, ctx), CanonicalView::Struct(a) => struct_cast(a, dtype, ctx), CanonicalView::Extension(a) => ::cast(a, dtype), diff --git a/vortex-array/src/session/mod.rs b/vortex-array/src/session/mod.rs index 2cb8414cbfd..107497ec687 100644 --- a/vortex-array/src/session/mod.rs +++ b/vortex-array/src/session/mod.rs @@ -23,6 +23,7 @@ use crate::arrays::Extension; use crate::arrays::FixedSizeList; use crate::arrays::List; use crate::arrays::ListView; +use crate::arrays::Map; use crate::arrays::Masked; use crate::arrays::Null; use crate::arrays::Primitive; @@ -70,6 +71,7 @@ impl Default for ArraySession { this.register(Decimal); this.register(VarBinView); this.register(ListView); + this.register(Map); this.register(FixedSizeList); this.register(Struct); this.register(Variant); diff --git a/vortex-compressor/src/compressor/cascade.rs b/vortex-compressor/src/compressor/cascade.rs index 9dbbc611448..b7eef0c2de6 100644 --- a/vortex-compressor/src/compressor/cascade.rs +++ b/vortex-compressor/src/compressor/cascade.rs @@ -26,6 +26,7 @@ use vortex_array::arrays::struct_::StructArrayExt; use vortex_array::arrays::variant::VariantArrayExt; use vortex_array::scalar::Scalar; use vortex_error::VortexResult; +use vortex_error::vortex_bail; use super::CascadingCompressor; use super::constant; @@ -138,6 +139,7 @@ impl CascadingCompressor { self.compress_list_view_array(list_view_array, compress_ctx, exec_ctx) } } + Canonical::Map(_) => vortex_bail!("Map arrays are not yet supported by the compressor"), Canonical::FixedSizeList(fsl_array) => { let compressed_elems = self.compress(fsl_array.elements(), exec_ctx)?; diff --git a/vortex-duckdb/src/exporter/canonical.rs b/vortex-duckdb/src/exporter/canonical.rs index 7ee47a40642..052bc7f94ac 100644 --- a/vortex-duckdb/src/exporter/canonical.rs +++ b/vortex-duckdb/src/exporter/canonical.rs @@ -30,6 +30,7 @@ pub(crate) fn new_exporter( Canonical::Decimal(array) => decimal::new_exporter(array, ctx), Canonical::VarBinView(array) => varbinview::new_exporter(array, ctx), Canonical::List(array) => list_view::new_exporter(array, cache, ctx), + Canonical::Map(_) => vortex_bail!("Map arrays can't be exported to DuckDB"), Canonical::FixedSizeList(array) => fixed_size_list::new_exporter(array, cache, ctx), Canonical::Struct(array) => struct_::new_exporter(array, cache, ctx), Canonical::Extension(ext) => extension::new_exporter(ext, ctx),