From 35e27b7e10777004641bf1681558a0ad5f0a967b Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 06:03:45 -0700 Subject: [PATCH 1/6] interned identifiers Signed-off-by: Nicholas Gates --- vortex-array/src/aggregate_fn/mod.rs | 4 ++-- vortex-array/src/compute/mod.rs | 9 +++++---- vortex-array/src/dtype/extension/mod.rs | 2 +- vortex-array/src/scalar_fn/mod.rs | 4 ++-- vortex-array/src/scalar_fn/vtable.rs | 3 +-- vortex-array/src/vtable/dyn_.rs | 4 ++-- vortex-layout/src/encoding.rs | 4 +++- vortex-layout/src/layout.rs | 5 +++-- vortex-session/src/registry.rs | 5 +---- vortex-utils/src/lib.rs | 3 +++ 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/vortex-array/src/aggregate_fn/mod.rs b/vortex-array/src/aggregate_fn/mod.rs index 4f89d5a4178..24924e7e2eb 100644 --- a/vortex-array/src/aggregate_fn/mod.rs +++ b/vortex-array/src/aggregate_fn/mod.rs @@ -6,7 +6,7 @@ //! This module contains the [`AggregateFnVTable`] trait, the [`Accumulator`] trait, and the //! type-erasure infrastructure for aggregate functions. -use arcref::ArcRef; +use vortex_utils::Id; mod accumulator; pub use accumulator::*; @@ -34,7 +34,7 @@ pub mod kernels; pub mod session; /// A unique identifier for an aggregate function. -pub type AggregateFnId = ArcRef; +pub type AggregateFnId = Id; /// Private module to seal [`typed::DynAggregateFn`]. mod sealed { diff --git a/vortex-array/src/compute/mod.rs b/vortex-array/src/compute/mod.rs index 7c1fedfca0d..9877ef5d96a 100644 --- a/vortex-array/src/compute/mod.rs +++ b/vortex-array/src/compute/mod.rs @@ -27,6 +27,7 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; use vortex_mask::Mask; +use vortex_utils::Id; use crate::ArrayRef; use crate::DynArray; @@ -47,7 +48,7 @@ mod sum; /// An instance of a compute function holding the implementation vtable and a set of registered /// compute kernels. pub struct ComputeFn { - id: ArcRef, + id: Id, vtable: ArcRef, kernels: RwLock>>, } @@ -62,7 +63,7 @@ pub fn warm_up_vtables() { impl ComputeFn { /// Create a new compute function from the given [`ComputeFnVTable`]. - pub fn new(id: ArcRef, vtable: ArcRef) -> Self { + pub fn new(id: Id, vtable: ArcRef) -> Self { Self { id, vtable, @@ -71,8 +72,8 @@ impl ComputeFn { } /// Returns the string identifier of the compute function. - pub fn id(&self) -> &ArcRef { - &self.id + pub fn id(&self) -> Id { + self.id } /// Register a kernel for the compute function. diff --git a/vortex-array/src/dtype/extension/mod.rs b/vortex-array/src/dtype/extension/mod.rs index c6ecc86bbf7..6fdaab1b22a 100644 --- a/vortex-array/src/dtype/extension/mod.rs +++ b/vortex-array/src/dtype/extension/mod.rs @@ -29,7 +29,7 @@ mod matcher; pub use matcher::*; /// A unique identifier for an extension type -pub type ExtId = arcref::ArcRef; +pub type ExtId = vortex_utils::Id; /// Private module to seal [`typed::DynExtDType`]. mod sealed { diff --git a/vortex-array/src/scalar_fn/mod.rs b/vortex-array/src/scalar_fn/mod.rs index 945c37262de..4d2a34d1dce 100644 --- a/vortex-array/src/scalar_fn/mod.rs +++ b/vortex-array/src/scalar_fn/mod.rs @@ -7,7 +7,7 @@ //! implementations. Expressions ([`crate::expr::Expression`]) reference scalar functions //! at each node. -use arcref::ArcRef; +use vortex_utils::Id; mod vtable; pub use vtable::*; @@ -31,7 +31,7 @@ pub mod fns; pub mod session; /// A unique identifier for a scalar function. -pub type ScalarFnId = ArcRef; +pub type ScalarFnId = Id; /// Private module to seal [`typed::DynScalarFn`]. mod sealed { diff --git a/vortex-array/src/scalar_fn/vtable.rs b/vortex-array/src/scalar_fn/vtable.rs index c9588e8aa13..00f9f905afb 100644 --- a/vortex-array/src/scalar_fn/vtable.rs +++ b/vortex-array/src/scalar_fn/vtable.rs @@ -9,7 +9,6 @@ use std::fmt::Formatter; use std::hash::Hash; use std::sync::Arc; -use arcref::ArcRef; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; @@ -412,4 +411,4 @@ pub trait ScalarFnVTableExt: ScalarFnVTable { impl ScalarFnVTableExt for V {} /// A reference to the name of a child expression. -pub type ChildName = ArcRef; +pub type ChildName = vortex_utils::Id; diff --git a/vortex-array/src/vtable/dyn_.rs b/vortex-array/src/vtable/dyn_.rs index 64ca5e99c50..2b4ba70aa9f 100644 --- a/vortex-array/src/vtable/dyn_.rs +++ b/vortex-array/src/vtable/dyn_.rs @@ -7,11 +7,11 @@ use std::fmt::Debug; use std::fmt::Formatter; use std::marker::PhantomData; -use arcref::ArcRef; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_session::VortexSession; +use vortex_utils::Id; use crate::ArrayAdapter; use crate::ArrayRef; @@ -25,7 +25,7 @@ use crate::serde::ArrayChildren; use crate::vtable::VTable; /// ArrayId is a globally unique name for the array's vtable. -pub type ArrayId = ArcRef; +pub type ArrayId = Id; /// Dynamically typed vtable trait. /// diff --git a/vortex-layout/src/encoding.rs b/vortex-layout/src/encoding.rs index ce0086e2ffc..0445d55fb74 100644 --- a/vortex-layout/src/encoding.rs +++ b/vortex-layout/src/encoding.rs @@ -13,6 +13,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_panic; use vortex_session::registry::ReadContext; +use vortex_utils::Id; use crate::IntoLayout; use crate::LayoutChildren; @@ -20,7 +21,8 @@ use crate::LayoutRef; use crate::VTable; use crate::segments::SegmentId; -pub type LayoutEncodingId = ArcRef; +/// A unique identifier for a layout encoding. +pub type LayoutEncodingId = Id; pub type LayoutEncodingRef = ArcRef; pub trait LayoutEncoding: 'static + Send + Sync + Debug + private::Sealed { diff --git a/vortex-layout/src/layout.rs b/vortex-layout/src/layout.rs index a4f9e6e0830..8d5a337c902 100644 --- a/vortex-layout/src/layout.rs +++ b/vortex-layout/src/layout.rs @@ -7,7 +7,6 @@ use std::fmt::Display; use std::fmt::Formatter; use std::sync::Arc; -use arcref::ArcRef; use itertools::Itertools; use vortex_array::SerializeMetadata; use vortex_array::dtype::DType; @@ -16,6 +15,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_err; use vortex_session::VortexSession; +use vortex_utils::Id; use crate::LayoutEncodingId; use crate::LayoutEncodingRef; @@ -26,7 +26,8 @@ use crate::display::display_tree_with_segment_sizes; use crate::segments::SegmentId; use crate::segments::SegmentSource; -pub type LayoutId = ArcRef; +/// A unique identifier for a layout. +pub type LayoutId = Id; pub type LayoutRef = Arc; diff --git a/vortex-session/src/registry.rs b/vortex-session/src/registry.rs index 35a65b086a3..75a57e11c36 100644 --- a/vortex-session/src/registry.rs +++ b/vortex-session/src/registry.rs @@ -8,14 +8,11 @@ use std::fmt::Debug; use std::ops::Deref; use std::sync::Arc; -use arcref::ArcRef; use parking_lot::RwLock; use vortex_error::VortexExpect; +use vortex_utils::Id; use vortex_utils::aliases::dash_map::DashMap; -/// An identifier for an item in a registry. -pub type Id = ArcRef; - /// A registry of items that are keyed by a string identifier. #[derive(Clone, Debug)] pub struct Registry(Arc>); diff --git a/vortex-utils/src/lib.rs b/vortex-utils/src/lib.rs index ff1610ddead..3d7d49d9f53 100644 --- a/vortex-utils/src/lib.rs +++ b/vortex-utils/src/lib.rs @@ -11,4 +11,7 @@ pub mod debug_with; pub mod dyn_traits; #[cfg(feature = "_test-harness")] pub mod env; +pub mod id; pub mod iter; + +pub use id::Id; From fbd5becc54ce4653042e609f1d81c96c1c144245 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 06:09:16 -0700 Subject: [PATCH 2/6] interned identifiers Signed-off-by: Nicholas Gates --- encodings/alp/src/alp/array.rs | 2 +- encodings/alp/src/alp_rd/array.rs | 2 +- encodings/bytebool/src/array.rs | 2 +- encodings/datetime-parts/src/array.rs | 2 +- .../src/decimal_byte_parts/mod.rs | 2 +- .../fastlanes/src/bitpacking/vtable/mod.rs | 2 +- encodings/fastlanes/src/delta/vtable/mod.rs | 2 +- encodings/fastlanes/src/for/vtable/mod.rs | 2 +- encodings/fastlanes/src/rle/vtable/mod.rs | 2 +- encodings/fsst/src/array.rs | 2 +- encodings/pco/src/array.rs | 2 +- encodings/runend/src/array.rs | 2 +- encodings/sequence/src/array.rs | 2 +- encodings/sparse/src/lib.rs | 2 +- encodings/zigzag/src/array.rs | 2 +- encodings/zstd/src/array.rs | 2 +- encodings/zstd/src/zstd_buffers.rs | 2 +- .../src/aggregate_fn/fns/is_constant/mod.rs | 2 +- .../src/aggregate_fn/fns/min_max/mod.rs | 2 +- .../src/aggregate_fn/fns/nan_count/mod.rs | 2 +- vortex-array/src/aggregate_fn/fns/sum/mod.rs | 2 +- vortex-array/src/aggregate_fn/mod.rs | 2 +- vortex-array/src/arrays/bool/vtable/mod.rs | 2 +- vortex-array/src/arrays/chunked/vtable/mod.rs | 2 +- .../src/arrays/constant/vtable/mod.rs | 2 +- vortex-array/src/arrays/decimal/vtable/mod.rs | 2 +- vortex-array/src/arrays/dict/vtable/mod.rs | 2 +- .../src/arrays/extension/compute/rules.rs | 4 +- .../src/arrays/extension/vtable/mod.rs | 2 +- vortex-array/src/arrays/filter/vtable.rs | 2 +- .../src/arrays/fixed_size_list/vtable/mod.rs | 2 +- vortex-array/src/arrays/list/vtable/mod.rs | 2 +- .../src/arrays/listview/vtable/mod.rs | 2 +- vortex-array/src/arrays/masked/vtable/mod.rs | 2 +- vortex-array/src/arrays/null/mod.rs | 2 +- .../src/arrays/primitive/vtable/mod.rs | 2 +- vortex-array/src/arrays/shared/vtable.rs | 2 +- vortex-array/src/arrays/slice/vtable.rs | 2 +- vortex-array/src/arrays/struct_/vtable/mod.rs | 2 +- vortex-array/src/arrays/varbin/vtable/mod.rs | 2 +- .../src/arrays/varbinview/vtable/mod.rs | 2 +- vortex-array/src/compute/mod.rs | 2 +- vortex-array/src/dtype/extension/mod.rs | 2 +- vortex-array/src/extension/datetime/date.rs | 2 +- vortex-array/src/extension/datetime/time.rs | 2 +- .../src/extension/datetime/timestamp.rs | 2 +- .../src/extension/tests/divisible_int.rs | 2 +- vortex-array/src/extension/uuid/vtable.rs | 2 +- vortex-array/src/scalar/arrow.rs | 2 +- vortex-array/src/scalar/tests/casting.rs | 6 +- .../src/scalar/typed_view/extension/tests.rs | 6 +- vortex-array/src/scalar_fn/fns/dynamic.rs | 2 +- vortex-array/src/scalar_fn/fns/is_null.rs | 2 +- vortex-array/src/scalar_fn/fns/literal.rs | 2 +- vortex-array/src/scalar_fn/fns/merge.rs | 2 +- vortex-array/src/scalar_fn/fns/pack.rs | 2 +- vortex-array/src/scalar_fn/fns/select.rs | 4 +- vortex-array/src/scalar_fn/mod.rs | 2 +- vortex-array/src/vtable/dyn_.rs | 2 +- vortex-cuda/src/layout.rs | 2 +- vortex-duckdb/src/convert/dtype.rs | 2 +- vortex-layout/src/encoding.rs | 2 +- vortex-layout/src/layout.rs | 2 +- vortex-layout/src/layouts/chunked/mod.rs | 2 +- vortex-layout/src/layouts/dict/mod.rs | 2 +- vortex-layout/src/layouts/dict/reader.rs | 4 +- vortex-layout/src/layouts/flat/mod.rs | 2 +- vortex-layout/src/layouts/struct_/mod.rs | 2 +- vortex-layout/src/layouts/zoned/mod.rs | 2 +- vortex-session/src/registry.rs | 60 +++++++++- vortex-tensor/src/fixed_shape/vtable.rs | 2 +- .../src/scalar_fns/cosine_similarity.rs | 2 +- vortex-utils/src/id.rs | 110 ++++++++++++++++++ vortex-utils/src/lib.rs | 3 - 74 files changed, 247 insertions(+), 82 deletions(-) create mode 100644 vortex-utils/src/id.rs diff --git a/encodings/alp/src/alp/array.rs b/encodings/alp/src/alp/array.rs index 965c1622ca8..3350eb480fc 100644 --- a/encodings/alp/src/alp/array.rs +++ b/encodings/alp/src/alp/array.rs @@ -273,7 +273,7 @@ pub struct ALPArray { pub struct ALP; impl ALP { - pub const ID: ArrayId = ArrayId::new_ref("vortex.alp"); + pub const ID: ArrayId = ArrayId::new("vortex.alp"); } #[derive(Clone, prost::Message)] diff --git a/encodings/alp/src/alp_rd/array.rs b/encodings/alp/src/alp_rd/array.rs index df72cc189d3..4040f1dfb0d 100644 --- a/encodings/alp/src/alp_rd/array.rs +++ b/encodings/alp/src/alp_rd/array.rs @@ -371,7 +371,7 @@ pub struct ALPRDArray { pub struct ALPRD; impl ALPRD { - pub const ID: ArrayId = ArrayId::new_ref("vortex.alprd"); + pub const ID: ArrayId = ArrayId::new("vortex.alprd"); } impl ALPRDArray { diff --git a/encodings/bytebool/src/array.rs b/encodings/bytebool/src/array.rs index 4b6a0e7cb58..13bc7cd3e6b 100644 --- a/encodings/bytebool/src/array.rs +++ b/encodings/bytebool/src/array.rs @@ -213,7 +213,7 @@ pub struct ByteBoolArray { pub struct ByteBool; impl ByteBool { - pub const ID: ArrayId = ArrayId::new_ref("vortex.bytebool"); + pub const ID: ArrayId = ArrayId::new("vortex.bytebool"); } impl ByteBoolArray { diff --git a/encodings/datetime-parts/src/array.rs b/encodings/datetime-parts/src/array.rs index b50ff8db0a5..e029ed2f384 100644 --- a/encodings/datetime-parts/src/array.rs +++ b/encodings/datetime-parts/src/array.rs @@ -267,7 +267,7 @@ pub struct DateTimePartsArrayParts { pub struct DateTimeParts; impl DateTimeParts { - pub const ID: ArrayId = ArrayId::new_ref("vortex.datetimeparts"); + pub const ID: ArrayId = ArrayId::new("vortex.datetimeparts"); } impl DateTimePartsArray { diff --git a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs index cd56c256383..f586097a308 100644 --- a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs +++ b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs @@ -274,7 +274,7 @@ impl DecimalBytePartsArray { pub struct DecimalByteParts; impl DecimalByteParts { - pub const ID: ArrayId = ArrayId::new_ref("vortex.decimal_byte_parts"); + pub const ID: ArrayId = ArrayId::new("vortex.decimal_byte_parts"); } /// Converts a DecimalBytePartsArray to its canonical DecimalArray representation. diff --git a/encodings/fastlanes/src/bitpacking/vtable/mod.rs b/encodings/fastlanes/src/bitpacking/vtable/mod.rs index c414dfa5cc0..ef42a77e6b4 100644 --- a/encodings/fastlanes/src/bitpacking/vtable/mod.rs +++ b/encodings/fastlanes/src/bitpacking/vtable/mod.rs @@ -372,5 +372,5 @@ impl VTable for BitPacked { pub struct BitPacked; impl BitPacked { - pub const ID: ArrayId = ArrayId::new_ref("fastlanes.bitpacked"); + pub const ID: ArrayId = ArrayId::new("fastlanes.bitpacked"); } diff --git a/encodings/fastlanes/src/delta/vtable/mod.rs b/encodings/fastlanes/src/delta/vtable/mod.rs index 9ebbaebe729..ed93402a962 100644 --- a/encodings/fastlanes/src/delta/vtable/mod.rs +++ b/encodings/fastlanes/src/delta/vtable/mod.rs @@ -201,7 +201,7 @@ impl VTable for Delta { pub struct Delta; impl Delta { - pub const ID: ArrayId = ArrayId::new_ref("fastlanes.delta"); + pub const ID: ArrayId = ArrayId::new("fastlanes.delta"); } #[cfg(test)] diff --git a/encodings/fastlanes/src/for/vtable/mod.rs b/encodings/fastlanes/src/for/vtable/mod.rs index 5eb73711ae4..ebba563f236 100644 --- a/encodings/fastlanes/src/for/vtable/mod.rs +++ b/encodings/fastlanes/src/for/vtable/mod.rs @@ -184,5 +184,5 @@ impl VTable for FoR { pub struct FoR; impl FoR { - pub const ID: ArrayId = ArrayId::new_ref("fastlanes.for"); + pub const ID: ArrayId = ArrayId::new("fastlanes.for"); } diff --git a/encodings/fastlanes/src/rle/vtable/mod.rs b/encodings/fastlanes/src/rle/vtable/mod.rs index 0df4126cbf5..55fb5d18be1 100644 --- a/encodings/fastlanes/src/rle/vtable/mod.rs +++ b/encodings/fastlanes/src/rle/vtable/mod.rs @@ -242,7 +242,7 @@ impl VTable for RLE { pub struct RLE; impl RLE { - pub const ID: ArrayId = ArrayId::new_ref("fastlanes.rle"); + pub const ID: ArrayId = ArrayId::new("fastlanes.rle"); } #[cfg(test)] diff --git a/encodings/fsst/src/array.rs b/encodings/fsst/src/array.rs index 9228b34085c..8bf057efa7b 100644 --- a/encodings/fsst/src/array.rs +++ b/encodings/fsst/src/array.rs @@ -393,7 +393,7 @@ impl Debug for FSSTArray { pub struct FSST; impl FSST { - pub const ID: ArrayId = ArrayId::new_ref("vortex.fsst"); + pub const ID: ArrayId = ArrayId::new("vortex.fsst"); } impl FSSTArray { diff --git a/encodings/pco/src/array.rs b/encodings/pco/src/array.rs index 85ba2bbe6cb..12653bd8a82 100644 --- a/encodings/pco/src/array.rs +++ b/encodings/pco/src/array.rs @@ -312,7 +312,7 @@ pub(crate) fn vortex_err_from_pco(err: PcoError) -> VortexError { pub struct Pco; impl Pco { - pub const ID: ArrayId = ArrayId::new_ref("vortex.pco"); + pub const ID: ArrayId = ArrayId::new("vortex.pco"); } #[derive(Clone, Debug)] diff --git a/encodings/runend/src/array.rs b/encodings/runend/src/array.rs index 6dd3fdc521d..3181a08ecd0 100644 --- a/encodings/runend/src/array.rs +++ b/encodings/runend/src/array.rs @@ -226,7 +226,7 @@ pub struct RunEndArrayParts { pub struct RunEnd; impl RunEnd { - pub const ID: ArrayId = ArrayId::new_ref("vortex.runend"); + pub const ID: ArrayId = ArrayId::new("vortex.runend"); } impl RunEndArray { diff --git a/encodings/sequence/src/array.rs b/encodings/sequence/src/array.rs index ea716ced1ea..ac7d5fc5e58 100644 --- a/encodings/sequence/src/array.rs +++ b/encodings/sequence/src/array.rs @@ -422,7 +422,7 @@ impl ValidityVTable for Sequence { pub struct Sequence; impl Sequence { - pub const ID: ArrayId = ArrayId::new_ref("vortex.sequence"); + pub const ID: ArrayId = ArrayId::new("vortex.sequence"); } #[cfg(test)] diff --git a/encodings/sparse/src/lib.rs b/encodings/sparse/src/lib.rs index 4b59797eca1..4b60b32de42 100644 --- a/encodings/sparse/src/lib.rs +++ b/encodings/sparse/src/lib.rs @@ -272,7 +272,7 @@ pub struct SparseArray { pub struct Sparse; impl Sparse { - pub const ID: ArrayId = ArrayId::new_ref("vortex.sparse"); + pub const ID: ArrayId = ArrayId::new("vortex.sparse"); } impl SparseArray { diff --git a/encodings/zigzag/src/array.rs b/encodings/zigzag/src/array.rs index f0b7898b26c..99d1fb8f843 100644 --- a/encodings/zigzag/src/array.rs +++ b/encodings/zigzag/src/array.rs @@ -184,7 +184,7 @@ pub struct ZigZagArray { pub struct ZigZag; impl ZigZag { - pub const ID: ArrayId = ArrayId::new_ref("vortex.zigzag"); + pub const ID: ArrayId = ArrayId::new("vortex.zigzag"); } impl ZigZagArray { diff --git a/encodings/zstd/src/array.rs b/encodings/zstd/src/array.rs index 2acd9a56190..d56d2579518 100644 --- a/encodings/zstd/src/array.rs +++ b/encodings/zstd/src/array.rs @@ -295,7 +295,7 @@ impl VTable for Zstd { pub struct Zstd; impl Zstd { - pub const ID: ArrayId = ArrayId::new_ref("vortex.zstd"); + pub const ID: ArrayId = ArrayId::new("vortex.zstd"); } #[derive(Clone, Debug)] diff --git a/encodings/zstd/src/zstd_buffers.rs b/encodings/zstd/src/zstd_buffers.rs index c33403f2d64..c101fa9e4d6 100644 --- a/encodings/zstd/src/zstd_buffers.rs +++ b/encodings/zstd/src/zstd_buffers.rs @@ -41,7 +41,7 @@ vtable!(ZstdBuffers); pub struct ZstdBuffers; impl ZstdBuffers { - pub const ID: ArrayId = ArrayId::new_ref("vortex.zstd_buffers"); + pub const ID: ArrayId = ArrayId::new("vortex.zstd_buffers"); } /// An encoding that ZSTD-compresses the buffers of any wrapped array. 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 98e7ff4bde3..ce7d0795b31 100644 --- a/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs @@ -256,7 +256,7 @@ impl AggregateFnVTable for IsConstant { type Partial = IsConstantPartial; fn id(&self) -> AggregateFnId { - AggregateFnId::new_ref("vortex.is_constant") + AggregateFnId::new("vortex.is_constant") } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { 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 2241cefcc3b..8a464c5dcba 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs @@ -173,7 +173,7 @@ impl AggregateFnVTable for MinMax { type Partial = MinMaxPartial; fn id(&self) -> AggregateFnId { - AggregateFnId::new_ref("vortex.min_max") + AggregateFnId::new("vortex.min_max") } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs b/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs index f60d50f2a20..cae70dbcdc8 100644 --- a/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs @@ -81,7 +81,7 @@ impl AggregateFnVTable for NanCount { type Partial = u64; fn id(&self) -> AggregateFnId { - AggregateFnId::new_ref("vortex.nan_count") + AggregateFnId::new("vortex.nan_count") } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/sum/mod.rs b/vortex-array/src/aggregate_fn/fns/sum/mod.rs index 49706ca56c0..89857950192 100644 --- a/vortex-array/src/aggregate_fn/fns/sum/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/sum/mod.rs @@ -71,7 +71,7 @@ impl AggregateFnVTable for Sum { type Partial = SumPartial; fn id(&self) -> AggregateFnId { - AggregateFnId::new_ref("vortex.sum") + AggregateFnId::new("vortex.sum") } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/mod.rs b/vortex-array/src/aggregate_fn/mod.rs index 24924e7e2eb..56a0663b3e8 100644 --- a/vortex-array/src/aggregate_fn/mod.rs +++ b/vortex-array/src/aggregate_fn/mod.rs @@ -6,7 +6,7 @@ //! This module contains the [`AggregateFnVTable`] trait, the [`Accumulator`] trait, and the //! type-erasure infrastructure for aggregate functions. -use vortex_utils::Id; +use vortex_session::registry::Id; mod accumulator; pub use accumulator::*; diff --git a/vortex-array/src/arrays/bool/vtable/mod.rs b/vortex-array/src/arrays/bool/vtable/mod.rs index d439ecf0e78..bad5ca50268 100644 --- a/vortex-array/src/arrays/bool/vtable/mod.rs +++ b/vortex-array/src/arrays/bool/vtable/mod.rs @@ -211,5 +211,5 @@ impl VTable for Bool { pub struct Bool; impl Bool { - pub const ID: ArrayId = ArrayId::new_ref("vortex.bool"); + pub const ID: ArrayId = ArrayId::new("vortex.bool"); } diff --git a/vortex-array/src/arrays/chunked/vtable/mod.rs b/vortex-array/src/arrays/chunked/vtable/mod.rs index 49dd7f9f6d7..d72327d9197 100644 --- a/vortex-array/src/arrays/chunked/vtable/mod.rs +++ b/vortex-array/src/arrays/chunked/vtable/mod.rs @@ -46,7 +46,7 @@ vtable!(Chunked); pub struct Chunked; impl Chunked { - pub const ID: ArrayId = ArrayId::new_ref("vortex.chunked"); + pub const ID: ArrayId = ArrayId::new("vortex.chunked"); } impl VTable for Chunked { diff --git a/vortex-array/src/arrays/constant/vtable/mod.rs b/vortex-array/src/arrays/constant/vtable/mod.rs index d35b874193b..46cc236a6e3 100644 --- a/vortex-array/src/arrays/constant/vtable/mod.rs +++ b/vortex-array/src/arrays/constant/vtable/mod.rs @@ -48,7 +48,7 @@ vtable!(Constant); pub struct Constant; impl Constant { - pub const ID: ArrayId = ArrayId::new_ref("vortex.constant"); + pub const ID: ArrayId = ArrayId::new("vortex.constant"); } impl VTable for Constant { diff --git a/vortex-array/src/arrays/decimal/vtable/mod.rs b/vortex-array/src/arrays/decimal/vtable/mod.rs index 37b62240121..29bb8797910 100644 --- a/vortex-array/src/arrays/decimal/vtable/mod.rs +++ b/vortex-array/src/arrays/decimal/vtable/mod.rs @@ -233,7 +233,7 @@ impl VTable for Decimal { pub struct Decimal; impl Decimal { - pub const ID: ArrayId = ArrayId::new_ref("vortex.decimal"); + pub const ID: ArrayId = ArrayId::new("vortex.decimal"); } #[cfg(test)] diff --git a/vortex-array/src/arrays/dict/vtable/mod.rs b/vortex-array/src/arrays/dict/vtable/mod.rs index 2903967c230..05a00fb1a6c 100644 --- a/vortex-array/src/arrays/dict/vtable/mod.rs +++ b/vortex-array/src/arrays/dict/vtable/mod.rs @@ -48,7 +48,7 @@ vtable!(Dict); pub struct Dict; impl Dict { - pub const ID: ArrayId = ArrayId::new_ref("vortex.dict"); + pub const ID: ArrayId = ArrayId::new("vortex.dict"); } impl VTable for Dict { diff --git a/vortex-array/src/arrays/extension/compute/rules.rs b/vortex-array/src/arrays/extension/compute/rules.rs index e077dda5283..b3034e11bed 100644 --- a/vortex-array/src/arrays/extension/compute/rules.rs +++ b/vortex-array/src/arrays/extension/compute/rules.rs @@ -84,7 +84,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("test_ext") + ExtId::new("test_ext") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { @@ -181,7 +181,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("test_ext_2") + ExtId::new("test_ext_2") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/arrays/extension/vtable/mod.rs b/vortex-array/src/arrays/extension/vtable/mod.rs index 243a0ef35d8..9da4aa4dd69 100644 --- a/vortex-array/src/arrays/extension/vtable/mod.rs +++ b/vortex-array/src/arrays/extension/vtable/mod.rs @@ -179,5 +179,5 @@ impl VTable for Extension { pub struct Extension; impl Extension { - pub const ID: ArrayId = ArrayId::new_ref("vortex.ext"); + pub const ID: ArrayId = ArrayId::new("vortex.ext"); } diff --git a/vortex-array/src/arrays/filter/vtable.rs b/vortex-array/src/arrays/filter/vtable.rs index b7099cb7c97..79d1b5e0d03 100644 --- a/vortex-array/src/arrays/filter/vtable.rs +++ b/vortex-array/src/arrays/filter/vtable.rs @@ -44,7 +44,7 @@ vtable!(Filter); pub struct Filter; impl Filter { - pub const ID: ArrayId = ArrayId::new_ref("vortex.filter"); + pub const ID: ArrayId = ArrayId::new("vortex.filter"); } impl VTable for Filter { diff --git a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs index d5c6f673671..3ea78c17a49 100644 --- a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs +++ b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs @@ -40,7 +40,7 @@ vtable!(FixedSizeList); pub struct FixedSizeList; impl FixedSizeList { - pub const ID: ArrayId = ArrayId::new_ref("vortex.fixed_size_list"); + pub const ID: ArrayId = ArrayId::new("vortex.fixed_size_list"); } impl VTable for FixedSizeList { diff --git a/vortex-array/src/arrays/list/vtable/mod.rs b/vortex-array/src/arrays/list/vtable/mod.rs index 13428f3a46b..00d898ede0b 100644 --- a/vortex-array/src/arrays/list/vtable/mod.rs +++ b/vortex-array/src/arrays/list/vtable/mod.rs @@ -231,5 +231,5 @@ impl VTable for List { pub struct List; impl List { - pub const ID: ArrayId = ArrayId::new_ref("vortex.list"); + pub const ID: ArrayId = ArrayId::new("vortex.list"); } diff --git a/vortex-array/src/arrays/listview/vtable/mod.rs b/vortex-array/src/arrays/listview/vtable/mod.rs index a31edbb536f..6a138f53133 100644 --- a/vortex-array/src/arrays/listview/vtable/mod.rs +++ b/vortex-array/src/arrays/listview/vtable/mod.rs @@ -43,7 +43,7 @@ vtable!(ListView); pub struct ListView; impl ListView { - pub const ID: ArrayId = ArrayId::new_ref("vortex.listview"); + pub const ID: ArrayId = ArrayId::new("vortex.listview"); } #[derive(Clone, prost::Message)] diff --git a/vortex-array/src/arrays/masked/vtable/mod.rs b/vortex-array/src/arrays/masked/vtable/mod.rs index 4dbe1670a43..c2f2dd787e2 100644 --- a/vortex-array/src/arrays/masked/vtable/mod.rs +++ b/vortex-array/src/arrays/masked/vtable/mod.rs @@ -44,7 +44,7 @@ vtable!(Masked); pub struct Masked; impl Masked { - pub const ID: ArrayId = ArrayId::new_ref("vortex.masked"); + pub const ID: ArrayId = ArrayId::new("vortex.masked"); } impl VTable for Masked { diff --git a/vortex-array/src/arrays/null/mod.rs b/vortex-array/src/arrays/null/mod.rs index e2ac02f247c..c49cba53a14 100644 --- a/vortex-array/src/arrays/null/mod.rs +++ b/vortex-array/src/arrays/null/mod.rs @@ -174,7 +174,7 @@ pub struct NullArray { pub struct Null; impl Null { - pub const ID: ArrayId = ArrayId::new_ref("vortex.null"); + pub const ID: ArrayId = ArrayId::new("vortex.null"); } impl NullArray { diff --git a/vortex-array/src/arrays/primitive/vtable/mod.rs b/vortex-array/src/arrays/primitive/vtable/mod.rs index c48a72217b1..0ebf8158ab9 100644 --- a/vortex-array/src/arrays/primitive/vtable/mod.rs +++ b/vortex-array/src/arrays/primitive/vtable/mod.rs @@ -225,5 +225,5 @@ impl VTable for Primitive { pub struct Primitive; impl Primitive { - pub const ID: ArrayId = ArrayId::new_ref("vortex.primitive"); + pub const ID: ArrayId = ArrayId::new("vortex.primitive"); } diff --git a/vortex-array/src/arrays/shared/vtable.rs b/vortex-array/src/arrays/shared/vtable.rs index 5880ebae568..48e1cb70d91 100644 --- a/vortex-array/src/arrays/shared/vtable.rs +++ b/vortex-array/src/arrays/shared/vtable.rs @@ -36,7 +36,7 @@ vtable!(Shared); pub struct Shared; impl Shared { - pub const ID: ArrayId = ArrayId::new_ref("vortex.shared"); + pub const ID: ArrayId = ArrayId::new("vortex.shared"); } impl VTable for Shared { diff --git a/vortex-array/src/arrays/slice/vtable.rs b/vortex-array/src/arrays/slice/vtable.rs index 367b5c5560c..14dff3a9a2e 100644 --- a/vortex-array/src/arrays/slice/vtable.rs +++ b/vortex-array/src/arrays/slice/vtable.rs @@ -43,7 +43,7 @@ vtable!(Slice); pub struct Slice; impl Slice { - pub const ID: ArrayId = ArrayId::new_ref("vortex.slice"); + pub const ID: ArrayId = ArrayId::new("vortex.slice"); } impl VTable for Slice { diff --git a/vortex-array/src/arrays/struct_/vtable/mod.rs b/vortex-array/src/arrays/struct_/vtable/mod.rs index 39df6e8783f..7633628f12c 100644 --- a/vortex-array/src/arrays/struct_/vtable/mod.rs +++ b/vortex-array/src/arrays/struct_/vtable/mod.rs @@ -233,5 +233,5 @@ impl VTable for Struct { pub struct Struct; impl Struct { - pub const ID: ArrayId = ArrayId::new_ref("vortex.struct"); + pub const ID: ArrayId = ArrayId::new("vortex.struct"); } diff --git a/vortex-array/src/arrays/varbin/vtable/mod.rs b/vortex-array/src/arrays/varbin/vtable/mod.rs index a366cd6d0c1..23f8f693f42 100644 --- a/vortex-array/src/arrays/varbin/vtable/mod.rs +++ b/vortex-array/src/arrays/varbin/vtable/mod.rs @@ -230,5 +230,5 @@ impl VTable for VarBin { pub struct VarBin; impl VarBin { - pub const ID: ArrayId = ArrayId::new_ref("vortex.varbin"); + pub const ID: ArrayId = ArrayId::new("vortex.varbin"); } diff --git a/vortex-array/src/arrays/varbinview/vtable/mod.rs b/vortex-array/src/arrays/varbinview/vtable/mod.rs index 0c4decaa772..99a6a0e1bef 100644 --- a/vortex-array/src/arrays/varbinview/vtable/mod.rs +++ b/vortex-array/src/arrays/varbinview/vtable/mod.rs @@ -45,7 +45,7 @@ vtable!(VarBinView); pub struct VarBinView; impl VarBinView { - pub const ID: ArrayId = ArrayId::new_ref("vortex.varbinview"); + pub const ID: ArrayId = ArrayId::new("vortex.varbinview"); } impl VTable for VarBinView { diff --git a/vortex-array/src/compute/mod.rs b/vortex-array/src/compute/mod.rs index 327e4381287..43f87885819 100644 --- a/vortex-array/src/compute/mod.rs +++ b/vortex-array/src/compute/mod.rs @@ -27,7 +27,7 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; use vortex_mask::Mask; -use vortex_utils::Id; +use vortex_session::registry::Id; use crate::ArrayRef; use crate::DynArray; diff --git a/vortex-array/src/dtype/extension/mod.rs b/vortex-array/src/dtype/extension/mod.rs index 6fdaab1b22a..e1c617e9490 100644 --- a/vortex-array/src/dtype/extension/mod.rs +++ b/vortex-array/src/dtype/extension/mod.rs @@ -29,7 +29,7 @@ mod matcher; pub use matcher::*; /// A unique identifier for an extension type -pub type ExtId = vortex_utils::Id; +pub type ExtId = vortex_session::registry::Id; /// Private module to seal [`typed::DynExtDType`]. mod sealed { diff --git a/vortex-array/src/extension/datetime/date.rs b/vortex-array/src/extension/datetime/date.rs index 57fe7ad87e0..b13e8795f29 100644 --- a/vortex-array/src/extension/datetime/date.rs +++ b/vortex-array/src/extension/datetime/date.rs @@ -79,7 +79,7 @@ impl ExtVTable for Date { type NativeValue<'a> = DateValue; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.date") + ExtId::new("vortex.date") } fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/extension/datetime/time.rs b/vortex-array/src/extension/datetime/time.rs index eb53a0e0fe3..9954254ebb9 100644 --- a/vortex-array/src/extension/datetime/time.rs +++ b/vortex-array/src/extension/datetime/time.rs @@ -80,7 +80,7 @@ impl ExtVTable for Time { type NativeValue<'a> = TimeValue; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.time") + ExtId::new("vortex.time") } fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/extension/datetime/timestamp.rs b/vortex-array/src/extension/datetime/timestamp.rs index ad78c76e3a9..9b02531f205 100644 --- a/vortex-array/src/extension/datetime/timestamp.rs +++ b/vortex-array/src/extension/datetime/timestamp.rs @@ -114,7 +114,7 @@ impl ExtVTable for Timestamp { type NativeValue<'a> = TimestampValue<'a>; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.timestamp") + ExtId::new("vortex.timestamp") } // NOTE(ngates): unfortunately we're stuck with this hand-rolled serialization format for diff --git a/vortex-array/src/extension/tests/divisible_int.rs b/vortex-array/src/extension/tests/divisible_int.rs index 7b6e501b7cb..2d342bc5ec0 100644 --- a/vortex-array/src/extension/tests/divisible_int.rs +++ b/vortex-array/src/extension/tests/divisible_int.rs @@ -34,7 +34,7 @@ impl ExtVTable for DivisibleInt { type NativeValue<'a> = u64; fn id(&self) -> ExtId { - ExtId::new_ref("test.divisible_int") + ExtId::new("test.divisible_int") } fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/extension/uuid/vtable.rs b/vortex-array/src/extension/uuid/vtable.rs index 962b83f8907..a46fe2f8ac9 100644 --- a/vortex-array/src/extension/uuid/vtable.rs +++ b/vortex-array/src/extension/uuid/vtable.rs @@ -27,7 +27,7 @@ impl ExtVTable for Uuid { type NativeValue<'a> = uuid::Uuid; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.uuid") + ExtId::new("vortex.uuid") } fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/scalar/arrow.rs b/vortex-array/src/scalar/arrow.rs index ac9fda0ee5e..0fef6608b7e 100644 --- a/vortex-array/src/scalar/arrow.rs +++ b/vortex-array/src/scalar/arrow.rs @@ -454,7 +454,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("some_ext") + ExtId::new("some_ext") } fn serialize_metadata(&self, _options: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/scalar/tests/casting.rs b/vortex-array/src/scalar/tests/casting.rs index e5677f7c1f9..8e52ab9841d 100644 --- a/vortex-array/src/scalar/tests/casting.rs +++ b/vortex-array/src/scalar/tests/casting.rs @@ -32,7 +32,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("apples") + ExtId::new("apples") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { @@ -248,7 +248,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("f16_ext") + ExtId::new("f16_ext") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { @@ -306,7 +306,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("struct_ext") + ExtId::new("struct_ext") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/scalar/typed_view/extension/tests.rs b/vortex-array/src/scalar/typed_view/extension/tests.rs index 4801e8e6e0c..2763730e0de 100644 --- a/vortex-array/src/scalar/typed_view/extension/tests.rs +++ b/vortex-array/src/scalar/typed_view/extension/tests.rs @@ -21,7 +21,7 @@ impl ExtVTable for TestI32Ext { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("test_ext") + ExtId::new("test_ext") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { @@ -105,7 +105,7 @@ fn test_ext_scalar_partial_ord_different_types() { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("test_ext_2") + ExtId::new("test_ext_2") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { @@ -288,7 +288,7 @@ fn test_ext_scalar_with_metadata() { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("test_ext_metadata") + ExtId::new("test_ext_metadata") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-array/src/scalar_fn/fns/dynamic.rs b/vortex-array/src/scalar_fn/fns/dynamic.rs index c3e83f98d96..0fa0afadaf9 100644 --- a/vortex-array/src/scalar_fn/fns/dynamic.rs +++ b/vortex-array/src/scalar_fn/fns/dynamic.rs @@ -47,7 +47,7 @@ impl ScalarFnVTable for DynamicComparison { type Options = DynamicComparisonExpr; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.dynamic") + ScalarFnId::new("vortex.dynamic") } fn arity(&self, _options: &Self::Options) -> Arity { diff --git a/vortex-array/src/scalar_fn/fns/is_null.rs b/vortex-array/src/scalar_fn/fns/is_null.rs index 8eae1da2bd0..4724f210ce2 100644 --- a/vortex-array/src/scalar_fn/fns/is_null.rs +++ b/vortex-array/src/scalar_fn/fns/is_null.rs @@ -34,7 +34,7 @@ impl ScalarFnVTable for IsNull { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("is_null") + ScalarFnId::new("is_null") } fn serialize(&self, _instance: &Self::Options) -> VortexResult>> { diff --git a/vortex-array/src/scalar_fn/fns/literal.rs b/vortex-array/src/scalar_fn/fns/literal.rs index fd3e20aef18..0cb8c820565 100644 --- a/vortex-array/src/scalar_fn/fns/literal.rs +++ b/vortex-array/src/scalar_fn/fns/literal.rs @@ -38,7 +38,7 @@ impl ScalarFnVTable for Literal { type Options = Scalar; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.literal") + ScalarFnId::new("vortex.literal") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { diff --git a/vortex-array/src/scalar_fn/fns/merge.rs b/vortex-array/src/scalar_fn/fns/merge.rs index 7e4d72fe07c..b74753bbc0b 100644 --- a/vortex-array/src/scalar_fn/fns/merge.rs +++ b/vortex-array/src/scalar_fn/fns/merge.rs @@ -50,7 +50,7 @@ impl ScalarFnVTable for Merge { type Options = DuplicateHandling; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.merge") + ScalarFnId::new("vortex.merge") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { diff --git a/vortex-array/src/scalar_fn/fns/pack.rs b/vortex-array/src/scalar_fn/fns/pack.rs index 42741d2476f..a6d779d5d0b 100644 --- a/vortex-array/src/scalar_fn/fns/pack.rs +++ b/vortex-array/src/scalar_fn/fns/pack.rs @@ -54,7 +54,7 @@ impl ScalarFnVTable for Pack { type Options = PackOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.pack") + ScalarFnId::new("vortex.pack") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { diff --git a/vortex-array/src/scalar_fn/fns/select.rs b/vortex-array/src/scalar_fn/fns/select.rs index 7b323c4311c..5967012e97c 100644 --- a/vortex-array/src/scalar_fn/fns/select.rs +++ b/vortex-array/src/scalar_fn/fns/select.rs @@ -47,7 +47,7 @@ impl ScalarFnVTable for Select { type Options = FieldSelection; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.select") + ScalarFnId::new("vortex.select") } fn serialize(&self, instance: &FieldSelection) -> VortexResult>> { @@ -93,7 +93,7 @@ impl ScalarFnVTable for Select { fn child_name(&self, _instance: &FieldSelection, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("child"), + 0 => ChildName::new("child"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/mod.rs b/vortex-array/src/scalar_fn/mod.rs index 4d2a34d1dce..a7bfb3296f3 100644 --- a/vortex-array/src/scalar_fn/mod.rs +++ b/vortex-array/src/scalar_fn/mod.rs @@ -7,7 +7,7 @@ //! implementations. Expressions ([`crate::expr::Expression`]) reference scalar functions //! at each node. -use vortex_utils::Id; +use vortex_session::registry::Id; mod vtable; pub use vtable::*; diff --git a/vortex-array/src/vtable/dyn_.rs b/vortex-array/src/vtable/dyn_.rs index 2b4ba70aa9f..bcbc0fedbdc 100644 --- a/vortex-array/src/vtable/dyn_.rs +++ b/vortex-array/src/vtable/dyn_.rs @@ -11,7 +11,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_session::VortexSession; -use vortex_utils::Id; +use vortex_session::registry::Id; use crate::ArrayAdapter; use crate::ArrayRef; diff --git a/vortex-cuda/src/layout.rs b/vortex-cuda/src/layout.rs index e598db6a5b2..d5ed4d188b8 100644 --- a/vortex-cuda/src/layout.rs +++ b/vortex-cuda/src/layout.rs @@ -129,7 +129,7 @@ impl VTable for CudaFlat { type Metadata = ProstMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.cuda_flat") + LayoutId::new("vortex.cuda_flat") } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-duckdb/src/convert/dtype.rs b/vortex-duckdb/src/convert/dtype.rs index e96fa838f63..c4efe9d8724 100644 --- a/vortex-duckdb/src/convert/dtype.rs +++ b/vortex-duckdb/src/convert/dtype.rs @@ -583,7 +583,7 @@ mod tests { type NativeValue<'a> = &'a str; fn id(&self) -> ExtId { - ExtId::new_ref("unknown.extension") + ExtId::new("unknown.extension") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-layout/src/encoding.rs b/vortex-layout/src/encoding.rs index 0445d55fb74..5a14482cbe1 100644 --- a/vortex-layout/src/encoding.rs +++ b/vortex-layout/src/encoding.rs @@ -13,7 +13,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_panic; use vortex_session::registry::ReadContext; -use vortex_utils::Id; +use vortex_session::registry::Id; use crate::IntoLayout; use crate::LayoutChildren; diff --git a/vortex-layout/src/layout.rs b/vortex-layout/src/layout.rs index 8d5a337c902..bb2961c9bac 100644 --- a/vortex-layout/src/layout.rs +++ b/vortex-layout/src/layout.rs @@ -15,7 +15,7 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_err; use vortex_session::VortexSession; -use vortex_utils::Id; +use vortex_session::registry::Id; use crate::LayoutEncodingId; use crate::LayoutEncodingRef; diff --git a/vortex-layout/src/layouts/chunked/mod.rs b/vortex-layout/src/layouts/chunked/mod.rs index af3c8bef4fa..82fcb650607 100644 --- a/vortex-layout/src/layouts/chunked/mod.rs +++ b/vortex-layout/src/layouts/chunked/mod.rs @@ -34,7 +34,7 @@ impl VTable for Chunked { type Metadata = EmptyMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.chunked") + LayoutId::new("vortex.chunked") } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-layout/src/layouts/dict/mod.rs b/vortex-layout/src/layouts/dict/mod.rs index 1a7dac17efe..03b47d64634 100644 --- a/vortex-layout/src/layouts/dict/mod.rs +++ b/vortex-layout/src/layouts/dict/mod.rs @@ -40,7 +40,7 @@ impl VTable for Dict { type Metadata = ProstMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.dict") + LayoutId::new("vortex.dict") } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-layout/src/layouts/dict/reader.rs b/vortex-layout/src/layouts/dict/reader.rs index 5054fcd27f3..73cb1f8d0dd 100644 --- a/vortex-layout/src/layouts/dict/reader.rs +++ b/vortex-layout/src/layouts/dict/reader.rs @@ -325,7 +325,7 @@ mod tests { )], Nullability::NonNullable, ); - assert!(layout.encoding_id() == LayoutId::new_ref("vortex.dict")); + assert!(layout.encoding_id() == LayoutId::new("vortex.dict")); let actual = layout .new_reader("".into(), segments, &SESSION) .unwrap() @@ -467,7 +467,7 @@ mod tests { .unwrap(); let expression = not(is_null(root())); // easier to test not_is_null b/c that's the validity array - assert_eq!(layout.encoding_id(), LayoutId::new_ref("vortex.dict")); + assert_eq!(layout.encoding_id(), LayoutId::new("vortex.dict")); let actual = layout .new_reader("".into(), segments, &SESSION) .unwrap() diff --git a/vortex-layout/src/layouts/flat/mod.rs b/vortex-layout/src/layouts/flat/mod.rs index 6fa95a5e256..186ada897a7 100644 --- a/vortex-layout/src/layouts/flat/mod.rs +++ b/vortex-layout/src/layouts/flat/mod.rs @@ -43,7 +43,7 @@ impl VTable for Flat { type Metadata = ProstMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.flat") + LayoutId::new("vortex.flat") } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-layout/src/layouts/struct_/mod.rs b/vortex-layout/src/layouts/struct_/mod.rs index b51616a6761..a3146cf60d4 100644 --- a/vortex-layout/src/layouts/struct_/mod.rs +++ b/vortex-layout/src/layouts/struct_/mod.rs @@ -43,7 +43,7 @@ impl VTable for Struct { type Metadata = EmptyMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.struct") + LayoutId::new("vortex.struct") } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-layout/src/layouts/zoned/mod.rs b/vortex-layout/src/layouts/zoned/mod.rs index bcd4cf6699b..bdba1c98d71 100644 --- a/vortex-layout/src/layouts/zoned/mod.rs +++ b/vortex-layout/src/layouts/zoned/mod.rs @@ -46,7 +46,7 @@ impl VTable for Zoned { type Metadata = ZonedMetadata; fn id(_encoding: &Self::Encoding) -> LayoutId { - LayoutId::new_ref("vortex.stats") // For legacy reasons, this is called stats + LayoutId::new("vortex.stats") // For legacy reasons, this is called stats } fn encoding(_layout: &Self::Layout) -> LayoutEncodingRef { diff --git a/vortex-session/src/registry.rs b/vortex-session/src/registry.rs index 75a57e11c36..b5452f8b1de 100644 --- a/vortex-session/src/registry.rs +++ b/vortex-session/src/registry.rs @@ -4,15 +4,73 @@ //! Many session types use a registry of objects that can be looked up by name to construct //! contexts. This module provides a generic registry type for that purpose. +use std::cmp::Ordering; +use std::fmt; use std::fmt::Debug; +use std::fmt::Display; +use std::fmt::Formatter; use std::ops::Deref; use std::sync::Arc; use parking_lot::RwLock; use vortex_error::VortexExpect; -use vortex_utils::Id; use vortex_utils::aliases::dash_map::DashMap; +/// A lightweight, copyable identifier backed by a `&'static str`. +/// +/// Used for array encoding IDs, scalar function IDs, layout IDs, and similar +/// globally-unique string identifiers throughout Vortex. +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub struct Id(&'static str); + +impl Id { + /// Create a new `Id` from a static string. + pub const fn new(s: &'static str) -> Self { + Self(s) + } + + /// Returns the underlying string. + pub const fn as_str(&self) -> &'static str { + self.0 + } +} + +impl Display for Id { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str(self.0) + } +} + +impl Debug for Id { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "Id(\"{}\")", self.0) + } +} + +impl PartialOrd for Id { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Id { + fn cmp(&self, other: &Self) -> Ordering { + self.0.cmp(other.0) + } +} + +impl PartialEq for Id { + fn eq(&self, other: &str) -> bool { + self.0 == other + } +} + +impl AsRef for Id { + fn as_ref(&self) -> &str { + self.0 + } +} + /// A registry of items that are keyed by a string identifier. #[derive(Clone, Debug)] pub struct Registry(Arc>); diff --git a/vortex-tensor/src/fixed_shape/vtable.rs b/vortex-tensor/src/fixed_shape/vtable.rs index 15e47456ba9..058977e70a2 100644 --- a/vortex-tensor/src/fixed_shape/vtable.rs +++ b/vortex-tensor/src/fixed_shape/vtable.rs @@ -22,7 +22,7 @@ impl ExtVTable for FixedShapeTensor { type NativeValue<'a> = &'a ScalarValue; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.fixed_shape_tensor") + ExtId::new("vortex.fixed_shape_tensor") } fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { diff --git a/vortex-tensor/src/scalar_fns/cosine_similarity.rs b/vortex-tensor/src/scalar_fns/cosine_similarity.rs index 7d97b2b58e7..63ae16da8b5 100644 --- a/vortex-tensor/src/scalar_fns/cosine_similarity.rs +++ b/vortex-tensor/src/scalar_fns/cosine_similarity.rs @@ -50,7 +50,7 @@ impl ScalarFnVTable for CosineSimilarity { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.cosine_similarity") + ScalarFnId::new("vortex.cosine_similarity") } fn arity(&self, _options: &Self::Options) -> Arity { diff --git a/vortex-utils/src/id.rs b/vortex-utils/src/id.rs new file mode 100644 index 00000000000..710959f62c3 --- /dev/null +++ b/vortex-utils/src/id.rs @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! A lightweight interned identifier type backed by `&'static str`. + +use std::cmp::Ordering; +use std::fmt; +use std::fmt::Debug; +use std::fmt::Display; +use std::fmt::Formatter; + +/// A lightweight, copyable identifier backed by a `&'static str`. +/// +/// Used for array encoding IDs, scalar function IDs, layout IDs, and similar +/// globally-unique string identifiers throughout Vortex. +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub struct Id(&'static str); + +impl Id { + /// Create a new `Id` from a static string. + pub const fn new(s: &'static str) -> Self { + Self(s) + } + + /// Returns the underlying string. + pub const fn as_str(&self) -> &'static str { + self.0 + } +} + +impl Display for Id { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str(self.0) + } +} + +impl Debug for Id { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "Id(\"{}\")", self.0) + } +} + +impl PartialOrd for Id { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Id { + fn cmp(&self, other: &Self) -> Ordering { + self.0.cmp(other.0) + } +} + +impl PartialEq for Id { + fn eq(&self, other: &str) -> bool { + self.0 == other + } +} + +impl AsRef for Id { + fn as_ref(&self) -> &str { + self.0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_id_equality() { + let a = Id::new("vortex.primitive"); + let b = Id::new("vortex.primitive"); + let c = Id::new("vortex.bool"); + assert_eq!(a, b); + assert_ne!(a, c); + } + + #[test] + fn test_id_display() { + let id = Id::new("vortex.primitive"); + assert_eq!(format!("{id}"), "vortex.primitive"); + } + + #[test] + fn test_id_debug() { + let id = Id::new("vortex.primitive"); + assert_eq!(format!("{id:?}"), "Id(\"vortex.primitive\")"); + } + + #[test] + fn test_id_partial_eq_str() { + let id = Id::new("vortex.primitive"); + assert_eq!(id, *"vortex.primitive"); + } + + #[test] + fn test_id_ord() { + let a = Id::new("aaa"); + let b = Id::new("bbb"); + assert!(a < b); + } + + #[test] + fn test_id_const() { + const MY_ID: Id = Id::new("test"); + assert_eq!(MY_ID.as_str(), "test"); + } +} diff --git a/vortex-utils/src/lib.rs b/vortex-utils/src/lib.rs index 3d7d49d9f53..ff1610ddead 100644 --- a/vortex-utils/src/lib.rs +++ b/vortex-utils/src/lib.rs @@ -11,7 +11,4 @@ pub mod debug_with; pub mod dyn_traits; #[cfg(feature = "_test-harness")] pub mod env; -pub mod id; pub mod iter; - -pub use id::Id; From 649cd3e253dbe4530dd87e5dda47cab2e51c8aec Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 09:41:39 -0700 Subject: [PATCH 3/6] Interned Identifiers Signed-off-by: Nicholas Gates --- Cargo.lock | 11 ++ Cargo.toml | 1 + encodings/alp/public-api.lock | 8 +- encodings/alp/src/alp/array.rs | 10 +- encodings/alp/src/alp_rd/array.rs | 10 +- encodings/bytebool/public-api.lock | 4 +- encodings/bytebool/src/array.rs | 10 +- encodings/datetime-parts/public-api.lock | 4 +- encodings/datetime-parts/src/array.rs | 10 +- encodings/decimal-byte-parts/public-api.lock | 4 +- .../src/decimal_byte_parts/mod.rs | 10 +- encodings/fastlanes/public-api.lock | 16 +- .../fastlanes/src/bitpacking/vtable/mod.rs | 10 +- encodings/fastlanes/src/delta/vtable/mod.rs | 10 +- encodings/fastlanes/src/for/vtable/mod.rs | 10 +- encodings/fastlanes/src/rle/vtable/mod.rs | 10 +- encodings/fsst/public-api.lock | 4 +- encodings/fsst/src/array.rs | 10 +- encodings/pco/public-api.lock | 4 +- encodings/pco/src/array.rs | 10 +- encodings/runend/public-api.lock | 4 +- encodings/runend/src/array.rs | 10 +- encodings/sequence/public-api.lock | 4 +- encodings/sequence/src/array.rs | 10 +- encodings/sparse/public-api.lock | 4 +- encodings/sparse/src/lib.rs | 10 +- encodings/zigzag/public-api.lock | 4 +- encodings/zigzag/src/array.rs | 10 +- encodings/zstd/public-api.lock | 4 +- encodings/zstd/src/array.rs | 10 +- encodings/zstd/src/zstd_buffers.rs | 14 +- vortex-array/public-api.lock | 170 +++++++++++++----- vortex-array/src/aggregate_fn/accumulator.rs | 2 +- .../src/aggregate_fn/fns/is_sorted/mod.rs | 2 +- vortex-array/src/aggregate_fn/session.rs | 10 +- vortex-array/src/arrays/bool/vtable/mod.rs | 10 +- vortex-array/src/arrays/chunked/vtable/mod.rs | 10 +- .../src/arrays/constant/vtable/mod.rs | 10 +- vortex-array/src/arrays/decimal/vtable/mod.rs | 10 +- vortex-array/src/arrays/dict/vtable/mod.rs | 10 +- .../src/arrays/extension/vtable/mod.rs | 10 +- vortex-array/src/arrays/filter/vtable.rs | 10 +- .../src/arrays/fixed_size_list/vtable/mod.rs | 10 +- vortex-array/src/arrays/list/vtable/mod.rs | 10 +- .../src/arrays/listview/vtable/mod.rs | 10 +- vortex-array/src/arrays/masked/vtable/mod.rs | 10 +- vortex-array/src/arrays/null/mod.rs | 10 +- .../src/arrays/primitive/vtable/mod.rs | 10 +- .../src/arrays/scalar_fn/vtable/mod.rs | 2 +- vortex-array/src/arrays/shared/vtable.rs | 10 +- vortex-array/src/arrays/slice/vtable.rs | 10 +- vortex-array/src/arrays/struct_/vtable/mod.rs | 10 +- vortex-array/src/arrays/varbin/vtable/mod.rs | 10 +- .../src/arrays/varbinview/vtable/mod.rs | 10 +- vortex-array/src/dtype/serde/flatbuffers.rs | 11 +- vortex-array/src/dtype/serde/proto.rs | 2 +- vortex-array/src/dtype/serde/serde.rs | 2 +- vortex-array/src/expr/proto.rs | 4 +- vortex-array/src/scalar_fn/fns/between/mod.rs | 8 +- vortex-array/src/scalar_fn/fns/binary/mod.rs | 6 +- vortex-array/src/scalar_fn/fns/case_when.rs | 9 +- vortex-array/src/scalar_fn/fns/cast/mod.rs | 4 +- vortex-array/src/scalar_fn/fns/dynamic.rs | 2 +- .../src/scalar_fn/fns/fill_null/mod.rs | 6 +- vortex-array/src/scalar_fn/fns/get_item.rs | 4 +- vortex-array/src/scalar_fn/fns/is_null.rs | 2 +- vortex-array/src/scalar_fn/fns/like/mod.rs | 6 +- .../src/scalar_fn/fns/list_contains/mod.rs | 6 +- vortex-array/src/scalar_fn/fns/mask/mod.rs | 6 +- vortex-array/src/scalar_fn/fns/merge.rs | 3 +- vortex-array/src/scalar_fn/fns/not/mod.rs | 4 +- vortex-array/src/scalar_fn/fns/pack.rs | 2 +- vortex-array/src/scalar_fn/fns/root.rs | 2 +- vortex-array/src/scalar_fn/fns/zip/mod.rs | 8 +- vortex-array/src/scalar_fn/vtable.rs | 2 +- vortex-array/src/serde.rs | 2 +- vortex-cuda/src/session.rs | 8 +- vortex-file/src/footer/mod.rs | 4 +- vortex-ipc/src/messages/decoder.rs | 2 +- vortex-layout/public-api.lock | 4 +- vortex-layout/src/encoding.rs | 2 +- vortex-layout/src/layouts/row_idx/expr.rs | 2 +- vortex-python/src/arrays/py/array.rs | 2 +- vortex-python/src/arrays/py/mod.rs | 21 ++- vortex-python/src/arrays/py/vtable.rs | 2 +- vortex-python/src/serde/context.rs | 4 +- vortex-session/Cargo.toml | 1 + vortex-session/public-api.lock | 60 ++++++- vortex-session/src/registry.rs | 60 +++++-- .../src/scalar_fns/cosine_similarity.rs | 4 +- .../fixtures/arrays/synthetic/arrays/bool.rs | 2 +- .../arrays/synthetic/arrays/chunked.rs | 2 +- .../arrays/synthetic/arrays/datetime.rs | 2 +- .../arrays/synthetic/arrays/decimal.rs | 2 +- .../synthetic/arrays/fixed_size_list.rs | 2 +- .../fixtures/arrays/synthetic/arrays/list.rs | 2 +- .../arrays/synthetic/arrays/listview.rs | 2 +- .../fixtures/arrays/synthetic/arrays/null.rs | 2 +- .../arrays/synthetic/arrays/primitive.rs | 2 +- .../arrays/synthetic/arrays/struct_nested.rs | 2 +- .../arrays/synthetic/arrays/varbin.rs | 2 +- .../arrays/synthetic/arrays/varbinview.rs | 2 +- .../arrays/synthetic/encodings/alp.rs | 2 +- .../arrays/synthetic/encodings/alprd.rs | 2 +- .../arrays/synthetic/encodings/bitpacked.rs | 2 +- .../arrays/synthetic/encodings/bytebool.rs | 2 +- .../arrays/synthetic/encodings/constant.rs | 2 +- .../synthetic/encodings/datetimeparts.rs | 2 +- .../synthetic/encodings/decimal_byte_parts.rs | 2 +- .../arrays/synthetic/encodings/delta.rs | 2 +- .../arrays/synthetic/encodings/dict.rs | 2 +- .../arrays/synthetic/encodings/for_.rs | 2 +- .../arrays/synthetic/encodings/fsst.rs | 2 +- .../arrays/synthetic/encodings/pco.rs | 2 +- .../arrays/synthetic/encodings/rle.rs | 2 +- .../arrays/synthetic/encodings/runend.rs | 2 +- .../arrays/synthetic/encodings/sequence.rs | 2 +- .../arrays/synthetic/encodings/sparse.rs | 2 +- .../arrays/synthetic/encodings/zigzag.rs | 2 +- .../arrays/synthetic/encodings/zstd.rs | 2 +- vortex-utils/src/id.rs | 110 ------------ 121 files changed, 681 insertions(+), 382 deletions(-) delete mode 100644 vortex-utils/src/id.rs diff --git a/Cargo.lock b/Cargo.lock index 8a09716070c..6d005771434 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8518,6 +8518,16 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51f1e89f093f99e7432c491c382b88a6860a5adbe6bf02574bf0a08efff1978" +[[package]] +name = "string-interner" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23de088478b31c349c9ba67816fa55d9355232d63c3afea8bf513e31f0f1d2c0" +dependencies = [ + "hashbrown 0.15.5", + "serde", +] + [[package]] name = "strsim" version = "0.11.1" @@ -10500,6 +10510,7 @@ dependencies = [ "arcref", "dashmap", "parking_lot", + "string-interner", "vortex-error", "vortex-utils", ] diff --git a/Cargo.toml b/Cargo.toml index 1f21bdf4f21..72a99e26b15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -223,6 +223,7 @@ similar = "2.7.0" sketches-ddsketch = "0.4.0" smol = "2.0.2" static_assertions = "1.1" +string-interner = "0.19.0" strum = "0.28" syn = { version = "2.0.113", features = ["full"] } sysinfo = "0.38.0" diff --git a/encodings/alp/public-api.lock b/encodings/alp/public-api.lock index 7f769a0fc7a..fe1388a92f1 100644 --- a/encodings/alp/public-api.lock +++ b/encodings/alp/public-api.lock @@ -6,7 +6,9 @@ pub struct vortex_alp::ALP impl vortex_alp::ALP -pub const vortex_alp::ALP::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_alp::ALP::ID: &'static str + +pub fn vortex_alp::ALP::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_alp::ALP @@ -174,7 +176,9 @@ pub struct vortex_alp::ALPRD impl vortex_alp::ALPRD -pub const vortex_alp::ALPRD::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_alp::ALPRD::ID: &'static str + +pub fn vortex_alp::ALPRD::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_alp::ALPRD diff --git a/encodings/alp/src/alp/array.rs b/encodings/alp/src/alp/array.rs index 3350eb480fc..58f658c18d3 100644 --- a/encodings/alp/src/alp/array.rs +++ b/encodings/alp/src/alp/array.rs @@ -55,7 +55,7 @@ impl VTable for ALP { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ALPArray) -> usize { @@ -273,7 +273,13 @@ pub struct ALPArray { pub struct ALP; impl ALP { - pub const ID: ArrayId = ArrayId::new("vortex.alp"); + pub const ID: &'static str = "vortex.alp"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[derive(Clone, prost::Message)] diff --git a/encodings/alp/src/alp_rd/array.rs b/encodings/alp/src/alp_rd/array.rs index 4040f1dfb0d..119ca2a4f4f 100644 --- a/encodings/alp/src/alp_rd/array.rs +++ b/encodings/alp/src/alp_rd/array.rs @@ -72,7 +72,7 @@ impl VTable for ALPRD { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ALPRDArray) -> usize { @@ -371,7 +371,13 @@ pub struct ALPRDArray { pub struct ALPRD; impl ALPRD { - pub const ID: ArrayId = ArrayId::new("vortex.alprd"); + pub const ID: &'static str = "vortex.alprd"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl ALPRDArray { diff --git a/encodings/bytebool/public-api.lock b/encodings/bytebool/public-api.lock index 192d025cf34..e4e0235dced 100644 --- a/encodings/bytebool/public-api.lock +++ b/encodings/bytebool/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_bytebool::ByteBool impl vortex_bytebool::ByteBool -pub const vortex_bytebool::ByteBool::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_bytebool::ByteBool::ID: &'static str + +pub fn vortex_bytebool::ByteBool::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_bytebool::ByteBool diff --git a/encodings/bytebool/src/array.rs b/encodings/bytebool/src/array.rs index 13bc7cd3e6b..bcaf9e14572 100644 --- a/encodings/bytebool/src/array.rs +++ b/encodings/bytebool/src/array.rs @@ -49,7 +49,7 @@ impl VTable for ByteBool { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ByteBoolArray) -> usize { @@ -213,7 +213,13 @@ pub struct ByteBoolArray { pub struct ByteBool; impl ByteBool { - pub const ID: ArrayId = ArrayId::new("vortex.bytebool"); + pub const ID: &'static str = "vortex.bytebool"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl ByteBoolArray { diff --git a/encodings/datetime-parts/public-api.lock b/encodings/datetime-parts/public-api.lock index 475c7da5168..205b87a1378 100644 --- a/encodings/datetime-parts/public-api.lock +++ b/encodings/datetime-parts/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_datetime_parts::DateTimeParts impl vortex_datetime_parts::DateTimeParts -pub const vortex_datetime_parts::DateTimeParts::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_datetime_parts::DateTimeParts::ID: &'static str + +pub fn vortex_datetime_parts::DateTimeParts::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_datetime_parts::DateTimeParts diff --git a/encodings/datetime-parts/src/array.rs b/encodings/datetime-parts/src/array.rs index e029ed2f384..05af389c1b8 100644 --- a/encodings/datetime-parts/src/array.rs +++ b/encodings/datetime-parts/src/array.rs @@ -79,7 +79,7 @@ impl VTable for DateTimeParts { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &DateTimePartsArray) -> usize { @@ -267,7 +267,13 @@ pub struct DateTimePartsArrayParts { pub struct DateTimeParts; impl DateTimeParts { - pub const ID: ArrayId = ArrayId::new("vortex.datetimeparts"); + pub const ID: &'static str = "vortex.datetimeparts"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl DateTimePartsArray { diff --git a/encodings/decimal-byte-parts/public-api.lock b/encodings/decimal-byte-parts/public-api.lock index cf9c86b6d1a..38d95c9770b 100644 --- a/encodings/decimal-byte-parts/public-api.lock +++ b/encodings/decimal-byte-parts/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_decimal_byte_parts::DecimalByteParts impl vortex_decimal_byte_parts::DecimalByteParts -pub const vortex_decimal_byte_parts::DecimalByteParts::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_decimal_byte_parts::DecimalByteParts::ID: &'static str + +pub fn vortex_decimal_byte_parts::DecimalByteParts::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_decimal_byte_parts::DecimalByteParts diff --git a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs index f586097a308..1781f3502da 100644 --- a/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs +++ b/encodings/decimal-byte-parts/src/decimal_byte_parts/mod.rs @@ -66,7 +66,7 @@ impl VTable for DecimalByteParts { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &DecimalBytePartsArray) -> usize { @@ -274,7 +274,13 @@ impl DecimalBytePartsArray { pub struct DecimalByteParts; impl DecimalByteParts { - pub const ID: ArrayId = ArrayId::new("vortex.decimal_byte_parts"); + pub const ID: &'static str = "vortex.decimal_byte_parts"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } /// Converts a DecimalBytePartsArray to its canonical DecimalArray representation. diff --git a/encodings/fastlanes/public-api.lock b/encodings/fastlanes/public-api.lock index b8086473960..c56a3726049 100644 --- a/encodings/fastlanes/public-api.lock +++ b/encodings/fastlanes/public-api.lock @@ -116,7 +116,9 @@ pub struct vortex_fastlanes::BitPacked impl vortex_fastlanes::BitPacked -pub const vortex_fastlanes::BitPacked::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_fastlanes::BitPacked::ID: &'static str + +pub fn vortex_fastlanes::BitPacked::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_fastlanes::BitPacked @@ -274,7 +276,9 @@ pub struct vortex_fastlanes::Delta impl vortex_fastlanes::Delta -pub const vortex_fastlanes::Delta::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_fastlanes::Delta::ID: &'static str + +pub fn vortex_fastlanes::Delta::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_fastlanes::Delta @@ -402,7 +406,9 @@ pub struct vortex_fastlanes::FoR impl vortex_fastlanes::FoR -pub const vortex_fastlanes::FoR::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_fastlanes::FoR::ID: &'static str + +pub fn vortex_fastlanes::FoR::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_fastlanes::FoR @@ -536,7 +542,9 @@ pub struct vortex_fastlanes::RLE impl vortex_fastlanes::RLE -pub const vortex_fastlanes::RLE::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_fastlanes::RLE::ID: &'static str + +pub fn vortex_fastlanes::RLE::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_fastlanes::RLE diff --git a/encodings/fastlanes/src/bitpacking/vtable/mod.rs b/encodings/fastlanes/src/bitpacking/vtable/mod.rs index ef42a77e6b4..e12f168b5d9 100644 --- a/encodings/fastlanes/src/bitpacking/vtable/mod.rs +++ b/encodings/fastlanes/src/bitpacking/vtable/mod.rs @@ -71,7 +71,7 @@ impl VTable for BitPacked { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &BitPackedArray) -> usize { @@ -372,5 +372,11 @@ impl VTable for BitPacked { pub struct BitPacked; impl BitPacked { - pub const ID: ArrayId = ArrayId::new("fastlanes.bitpacked"); + pub const ID: &'static str = "fastlanes.bitpacked"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/encodings/fastlanes/src/delta/vtable/mod.rs b/encodings/fastlanes/src/delta/vtable/mod.rs index ed93402a962..228fbdd0778 100644 --- a/encodings/fastlanes/src/delta/vtable/mod.rs +++ b/encodings/fastlanes/src/delta/vtable/mod.rs @@ -57,7 +57,7 @@ impl VTable for Delta { type ValidityVTable = ValidityVTableFromChildSliceHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &DeltaArray) -> usize { @@ -201,7 +201,13 @@ impl VTable for Delta { pub struct Delta; impl Delta { - pub const ID: ArrayId = ArrayId::new("fastlanes.delta"); + pub const ID: &'static str = "fastlanes.delta"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[cfg(test)] diff --git a/encodings/fastlanes/src/for/vtable/mod.rs b/encodings/fastlanes/src/for/vtable/mod.rs index ebba563f236..c02a0392d7f 100644 --- a/encodings/fastlanes/src/for/vtable/mod.rs +++ b/encodings/fastlanes/src/for/vtable/mod.rs @@ -49,7 +49,7 @@ impl VTable for FoR { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &FoRArray) -> usize { @@ -184,5 +184,11 @@ impl VTable for FoR { pub struct FoR; impl FoR { - pub const ID: ArrayId = ArrayId::new("fastlanes.for"); + pub const ID: &'static str = "fastlanes.for"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/encodings/fastlanes/src/rle/vtable/mod.rs b/encodings/fastlanes/src/rle/vtable/mod.rs index 55fb5d18be1..ab8264151d2 100644 --- a/encodings/fastlanes/src/rle/vtable/mod.rs +++ b/encodings/fastlanes/src/rle/vtable/mod.rs @@ -63,7 +63,7 @@ impl VTable for RLE { type ValidityVTable = ValidityVTableFromChildSliceHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &RLEArray) -> usize { @@ -242,7 +242,13 @@ impl VTable for RLE { pub struct RLE; impl RLE { - pub const ID: ArrayId = ArrayId::new("fastlanes.rle"); + pub const ID: &'static str = "fastlanes.rle"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[cfg(test)] diff --git a/encodings/fsst/public-api.lock b/encodings/fsst/public-api.lock index c25ba6b44f2..87093728ed2 100644 --- a/encodings/fsst/public-api.lock +++ b/encodings/fsst/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_fsst::FSST impl vortex_fsst::FSST -pub const vortex_fsst::FSST::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_fsst::FSST::ID: &'static str + +pub fn vortex_fsst::FSST::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_fsst::FSST diff --git a/encodings/fsst/src/array.rs b/encodings/fsst/src/array.rs index 8bf057efa7b..e8f64c8ba04 100644 --- a/encodings/fsst/src/array.rs +++ b/encodings/fsst/src/array.rs @@ -82,7 +82,7 @@ impl VTable for FSST { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &FSSTArray) -> usize { @@ -393,7 +393,13 @@ impl Debug for FSSTArray { pub struct FSST; impl FSST { - pub const ID: ArrayId = ArrayId::new("vortex.fsst"); + pub const ID: &'static str = "vortex.fsst"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl FSSTArray { diff --git a/encodings/pco/public-api.lock b/encodings/pco/public-api.lock index b82093e811b..5627b31c73b 100644 --- a/encodings/pco/public-api.lock +++ b/encodings/pco/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_pco::Pco impl vortex_pco::Pco -pub const vortex_pco::Pco::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_pco::Pco::ID: &'static str + +pub fn vortex_pco::Pco::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_pco::Pco diff --git a/encodings/pco/src/array.rs b/encodings/pco/src/array.rs index 12653bd8a82..922d2ada681 100644 --- a/encodings/pco/src/array.rs +++ b/encodings/pco/src/array.rs @@ -93,7 +93,7 @@ impl VTable for Pco { type ValidityVTable = ValidityVTableFromValiditySliceHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &PcoArray) -> usize { @@ -312,7 +312,13 @@ pub(crate) fn vortex_err_from_pco(err: PcoError) -> VortexError { pub struct Pco; impl Pco { - pub const ID: ArrayId = ArrayId::new("vortex.pco"); + pub const ID: &'static str = "vortex.pco"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[derive(Clone, Debug)] diff --git a/encodings/runend/public-api.lock b/encodings/runend/public-api.lock index a78046051d0..3435a56e6f1 100644 --- a/encodings/runend/public-api.lock +++ b/encodings/runend/public-api.lock @@ -20,7 +20,9 @@ pub struct vortex_runend::RunEnd impl vortex_runend::RunEnd -pub const vortex_runend::RunEnd::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_runend::RunEnd::ID: &'static str + +pub fn vortex_runend::RunEnd::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_runend::RunEnd diff --git a/encodings/runend/src/array.rs b/encodings/runend/src/array.rs index 3181a08ecd0..d39a2a82e0e 100644 --- a/encodings/runend/src/array.rs +++ b/encodings/runend/src/array.rs @@ -66,7 +66,7 @@ impl VTable for RunEnd { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &RunEndArray) -> usize { @@ -226,7 +226,13 @@ pub struct RunEndArrayParts { pub struct RunEnd; impl RunEnd { - pub const ID: ArrayId = ArrayId::new("vortex.runend"); + pub const ID: &'static str = "vortex.runend"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl RunEndArray { diff --git a/encodings/sequence/public-api.lock b/encodings/sequence/public-api.lock index 2696a1d1457..cabf7575c87 100644 --- a/encodings/sequence/public-api.lock +++ b/encodings/sequence/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_sequence::Sequence impl vortex_sequence::Sequence -pub const vortex_sequence::Sequence::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_sequence::Sequence::ID: &'static str + +pub fn vortex_sequence::Sequence::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_sequence::Sequence diff --git a/encodings/sequence/src/array.rs b/encodings/sequence/src/array.rs index ac7d5fc5e58..d7a0c423bb5 100644 --- a/encodings/sequence/src/array.rs +++ b/encodings/sequence/src/array.rs @@ -243,7 +243,7 @@ impl VTable for Sequence { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &SequenceArray) -> usize { @@ -422,7 +422,13 @@ impl ValidityVTable for Sequence { pub struct Sequence; impl Sequence { - pub const ID: ArrayId = ArrayId::new("vortex.sequence"); + pub const ID: &'static str = "vortex.sequence"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[cfg(test)] diff --git a/encodings/sparse/public-api.lock b/encodings/sparse/public-api.lock index 9193dec8147..644586e1e3b 100644 --- a/encodings/sparse/public-api.lock +++ b/encodings/sparse/public-api.lock @@ -24,7 +24,9 @@ pub struct vortex_sparse::Sparse impl vortex_sparse::Sparse -pub const vortex_sparse::Sparse::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_sparse::Sparse::ID: &'static str + +pub fn vortex_sparse::Sparse::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_sparse::Sparse diff --git a/encodings/sparse/src/lib.rs b/encodings/sparse/src/lib.rs index 4b60b32de42..aa726101c12 100644 --- a/encodings/sparse/src/lib.rs +++ b/encodings/sparse/src/lib.rs @@ -81,7 +81,7 @@ impl VTable for Sparse { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &SparseArray) -> usize { @@ -272,7 +272,13 @@ pub struct SparseArray { pub struct Sparse; impl Sparse { - pub const ID: ArrayId = ArrayId::new("vortex.sparse"); + pub const ID: &'static str = "vortex.sparse"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl SparseArray { diff --git a/encodings/zigzag/public-api.lock b/encodings/zigzag/public-api.lock index 590e897cd8c..27354f9daf3 100644 --- a/encodings/zigzag/public-api.lock +++ b/encodings/zigzag/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_zigzag::ZigZag impl vortex_zigzag::ZigZag -pub const vortex_zigzag::ZigZag::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_zigzag::ZigZag::ID: &'static str + +pub fn vortex_zigzag::ZigZag::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_zigzag::ZigZag diff --git a/encodings/zigzag/src/array.rs b/encodings/zigzag/src/array.rs index 99d1fb8f843..1188727e153 100644 --- a/encodings/zigzag/src/array.rs +++ b/encodings/zigzag/src/array.rs @@ -49,7 +49,7 @@ impl VTable for ZigZag { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ZigZagArray) -> usize { @@ -184,7 +184,13 @@ pub struct ZigZagArray { pub struct ZigZag; impl ZigZag { - pub const ID: ArrayId = ArrayId::new("vortex.zigzag"); + pub const ID: &'static str = "vortex.zigzag"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl ZigZagArray { diff --git a/encodings/zstd/public-api.lock b/encodings/zstd/public-api.lock index bfe24e26991..f3a1482d92a 100644 --- a/encodings/zstd/public-api.lock +++ b/encodings/zstd/public-api.lock @@ -4,7 +4,9 @@ pub struct vortex_zstd::Zstd impl vortex_zstd::Zstd -pub const vortex_zstd::Zstd::ID: vortex_array::vtable::dyn_::ArrayId +pub const vortex_zstd::Zstd::ID: &'static str + +pub fn vortex_zstd::Zstd::array_id() -> vortex_array::vtable::dyn_::ArrayId impl core::fmt::Debug for vortex_zstd::Zstd diff --git a/encodings/zstd/src/array.rs b/encodings/zstd/src/array.rs index d56d2579518..9c47377b1eb 100644 --- a/encodings/zstd/src/array.rs +++ b/encodings/zstd/src/array.rs @@ -92,7 +92,7 @@ impl VTable for Zstd { type ValidityVTable = ValidityVTableFromValiditySliceHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ZstdArray) -> usize { @@ -295,7 +295,13 @@ impl VTable for Zstd { pub struct Zstd; impl Zstd { - pub const ID: ArrayId = ArrayId::new("vortex.zstd"); + pub const ID: &'static str = "vortex.zstd"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[derive(Clone, Debug)] diff --git a/encodings/zstd/src/zstd_buffers.rs b/encodings/zstd/src/zstd_buffers.rs index c101fa9e4d6..493b003b692 100644 --- a/encodings/zstd/src/zstd_buffers.rs +++ b/encodings/zstd/src/zstd_buffers.rs @@ -41,7 +41,13 @@ vtable!(ZstdBuffers); pub struct ZstdBuffers; impl ZstdBuffers { - pub const ID: ArrayId = ArrayId::new("vortex.zstd_buffers"); + pub const ID: &'static str = "vortex.zstd_buffers"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } /// An encoding that ZSTD-compresses the buffers of any wrapped array. @@ -250,7 +256,7 @@ impl ZstdBuffersArray { let children = self.children.as_slice(); inner_vtable.build( - self.inner_encoding_id.clone(), + self.inner_encoding_id, &self.dtype, self.len, &self.inner_metadata, @@ -320,7 +326,7 @@ fn compute_output_layout( } fn array_id_from_string(s: &str) -> ArrayId { - ArrayId::new_arc(Arc::from(s)) + ArrayId::new(s) } impl VTable for ZstdBuffers { @@ -331,7 +337,7 @@ impl VTable for ZstdBuffers { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ZstdBuffersArray) -> usize { diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index c8ed0c94938..d3b658aea01 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -396,7 +396,7 @@ impl vortex_array::aggregate_fn::session::AggregateFnSession pub fn vortex_array::aggregate_fn::session::AggregateFnSession::register(&self, vtable: V) -pub fn vortex_array::aggregate_fn::session::AggregateFnSession::register_aggregate_kernel(&self, array_id: vortex_array::vtable::ArrayId, agg_fn_id: core::option::Option, kernel: &'static dyn vortex_array::aggregate_fn::kernels::DynAggregateKernel) +pub fn vortex_array::aggregate_fn::session::AggregateFnSession::register_aggregate_kernel(&self, array_id: impl core::convert::Into, agg_fn_id: core::option::Option>, kernel: &'static dyn vortex_array::aggregate_fn::kernels::DynAggregateKernel) pub fn vortex_array::aggregate_fn::session::AggregateFnSession::registry(&self) -> &vortex_array::aggregate_fn::session::AggregateFnRegistry @@ -572,7 +572,7 @@ impl vortex_array::aggregate_f pub fn V::deserialize(&self, metadata: &[u8], session: &vortex_session::VortexSession) -> core::result::Result -pub fn V::id(&self) -> arcref::ArcRef +pub fn V::id(&self) -> vortex_session::registry::Id pub trait vortex_array::aggregate_fn::AggregateFnVTable: 'static + core::marker::Sized + core::clone::Clone + core::marker::Send + core::marker::Sync @@ -824,7 +824,7 @@ pub fn vortex_array::aggregate_fn::GroupedAccumulator::flush(&mut self) -> vo pub type vortex_array::aggregate_fn::AccumulatorRef = alloc::boxed::Box -pub type vortex_array::aggregate_fn::AggregateFnId = arcref::ArcRef +pub type vortex_array::aggregate_fn::AggregateFnId = vortex_session::registry::Id pub type vortex_array::aggregate_fn::AggregateFnPluginRef = alloc::sync::Arc @@ -838,7 +838,9 @@ pub struct vortex_array::arrays::bool::Bool impl vortex_array::arrays::Bool -pub const vortex_array::arrays::Bool::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Bool::ID: &'static str + +pub fn vortex_array::arrays::Bool::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Bool @@ -1048,7 +1050,9 @@ pub struct vortex_array::arrays::chunked::Chunked impl vortex_array::arrays::Chunked -pub const vortex_array::arrays::Chunked::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Chunked::ID: &'static str + +pub fn vortex_array::arrays::Chunked::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Chunked @@ -1210,7 +1214,9 @@ pub struct vortex_array::arrays::constant::Constant impl vortex_array::arrays::Constant -pub const vortex_array::arrays::Constant::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Constant::ID: &'static str + +pub fn vortex_array::arrays::Constant::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::Constant @@ -1418,7 +1424,9 @@ pub struct vortex_array::arrays::decimal::Decimal impl vortex_array::arrays::Decimal -pub const vortex_array::arrays::Decimal::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Decimal::ID: &'static str + +pub fn vortex_array::arrays::Decimal::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Decimal @@ -1624,7 +1632,9 @@ pub struct vortex_array::arrays::dict::vtable::Dict impl vortex_array::arrays::dict::Dict -pub const vortex_array::arrays::dict::Dict::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::dict::Dict::ID: &'static str + +pub fn vortex_array::arrays::dict::Dict::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::dict::Dict @@ -1728,7 +1738,9 @@ pub struct vortex_array::arrays::dict::Dict impl vortex_array::arrays::dict::Dict -pub const vortex_array::arrays::dict::Dict::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::dict::Dict::ID: &'static str + +pub fn vortex_array::arrays::dict::Dict::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::dict::Dict @@ -2032,7 +2044,9 @@ pub struct vortex_array::arrays::extension::Extension impl vortex_array::arrays::Extension -pub const vortex_array::arrays::Extension::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Extension::ID: &'static str + +pub fn vortex_array::arrays::Extension::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Extension @@ -2192,7 +2206,9 @@ pub struct vortex_array::arrays::filter::Filter impl vortex_array::arrays::Filter -pub const vortex_array::arrays::Filter::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Filter::ID: &'static str + +pub fn vortex_array::arrays::Filter::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Filter @@ -2392,7 +2408,9 @@ pub struct vortex_array::arrays::fixed_size_list::FixedSizeList impl vortex_array::arrays::FixedSizeList -pub const vortex_array::arrays::FixedSizeList::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::FixedSizeList::ID: &'static str + +pub fn vortex_array::arrays::FixedSizeList::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::FixedSizeList @@ -2536,7 +2554,9 @@ pub struct vortex_array::arrays::list::List impl vortex_array::arrays::List -pub const vortex_array::arrays::List::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::List::ID: &'static str + +pub fn vortex_array::arrays::List::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::List @@ -2708,7 +2728,9 @@ pub struct vortex_array::arrays::listview::ListView impl vortex_array::arrays::ListView -pub const vortex_array::arrays::ListView::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::ListView::ID: &'static str + +pub fn vortex_array::arrays::ListView::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::ListView @@ -2886,7 +2908,9 @@ pub struct vortex_array::arrays::masked::Masked impl vortex_array::arrays::Masked -pub const vortex_array::arrays::Masked::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Masked::ID: &'static str + +pub fn vortex_array::arrays::Masked::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Masked @@ -3016,7 +3040,9 @@ pub struct vortex_array::arrays::null::Null impl vortex_array::arrays::null::Null -pub const vortex_array::arrays::null::Null::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::null::Null::ID: &'static str + +pub fn vortex_array::arrays::null::Null::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::null::Null @@ -3220,7 +3246,9 @@ pub struct vortex_array::arrays::primitive::Primitive impl vortex_array::arrays::Primitive -pub const vortex_array::arrays::Primitive::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Primitive::ID: &'static str + +pub fn vortex_array::arrays::Primitive::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Primitive @@ -3640,7 +3668,9 @@ pub struct vortex_array::arrays::shared::Shared impl vortex_array::arrays::Shared -pub const vortex_array::arrays::Shared::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Shared::ID: &'static str + +pub fn vortex_array::arrays::Shared::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Shared @@ -3754,7 +3784,9 @@ pub struct vortex_array::arrays::slice::Slice impl vortex_array::arrays::slice::Slice -pub const vortex_array::arrays::slice::Slice::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::slice::Slice::ID: &'static str + +pub fn vortex_array::arrays::slice::Slice::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::slice::Slice @@ -3996,7 +4028,9 @@ pub struct vortex_array::arrays::struct_::Struct impl vortex_array::arrays::Struct -pub const vortex_array::arrays::Struct::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Struct::ID: &'static str + +pub fn vortex_array::arrays::Struct::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Struct @@ -4204,7 +4238,9 @@ pub struct vortex_array::arrays::varbin::VarBin impl vortex_array::arrays::VarBin -pub const vortex_array::arrays::VarBin::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::VarBin::ID: &'static str + +pub fn vortex_array::arrays::VarBin::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::VarBin @@ -4614,7 +4650,9 @@ pub struct vortex_array::arrays::varbinview::VarBinView impl vortex_array::arrays::VarBinView -pub const vortex_array::arrays::VarBinView::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::VarBinView::ID: &'static str + +pub fn vortex_array::arrays::VarBinView::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::VarBinView @@ -4822,7 +4860,9 @@ pub struct vortex_array::arrays::Bool impl vortex_array::arrays::Bool -pub const vortex_array::arrays::Bool::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Bool::ID: &'static str + +pub fn vortex_array::arrays::Bool::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Bool @@ -5004,7 +5044,9 @@ pub struct vortex_array::arrays::Chunked impl vortex_array::arrays::Chunked -pub const vortex_array::arrays::Chunked::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Chunked::ID: &'static str + +pub fn vortex_array::arrays::Chunked::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Chunked @@ -5164,7 +5206,9 @@ pub struct vortex_array::arrays::Constant impl vortex_array::arrays::Constant -pub const vortex_array::arrays::Constant::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Constant::ID: &'static str + +pub fn vortex_array::arrays::Constant::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::Constant @@ -5308,7 +5352,9 @@ pub struct vortex_array::arrays::Decimal impl vortex_array::arrays::Decimal -pub const vortex_array::arrays::Decimal::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Decimal::ID: &'static str + +pub fn vortex_array::arrays::Decimal::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Decimal @@ -5482,7 +5528,9 @@ pub struct vortex_array::arrays::Dict impl vortex_array::arrays::dict::Dict -pub const vortex_array::arrays::dict::Dict::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::dict::Dict::ID: &'static str + +pub fn vortex_array::arrays::dict::Dict::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::dict::Dict @@ -5644,7 +5692,9 @@ pub struct vortex_array::arrays::Extension impl vortex_array::arrays::Extension -pub const vortex_array::arrays::Extension::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Extension::ID: &'static str + +pub fn vortex_array::arrays::Extension::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Extension @@ -5802,7 +5852,9 @@ pub struct vortex_array::arrays::Filter impl vortex_array::arrays::Filter -pub const vortex_array::arrays::Filter::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Filter::ID: &'static str + +pub fn vortex_array::arrays::Filter::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Filter @@ -5918,7 +5970,9 @@ pub struct vortex_array::arrays::FixedSizeList impl vortex_array::arrays::FixedSizeList -pub const vortex_array::arrays::FixedSizeList::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::FixedSizeList::ID: &'static str + +pub fn vortex_array::arrays::FixedSizeList::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::FixedSizeList @@ -6060,7 +6114,9 @@ pub struct vortex_array::arrays::List impl vortex_array::arrays::List -pub const vortex_array::arrays::List::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::List::ID: &'static str + +pub fn vortex_array::arrays::List::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::List @@ -6210,7 +6266,9 @@ pub struct vortex_array::arrays::ListView impl vortex_array::arrays::ListView -pub const vortex_array::arrays::ListView::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::ListView::ID: &'static str + +pub fn vortex_array::arrays::ListView::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::ListView @@ -6368,7 +6426,9 @@ pub struct vortex_array::arrays::Masked impl vortex_array::arrays::Masked -pub const vortex_array::arrays::Masked::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Masked::ID: &'static str + +pub fn vortex_array::arrays::Masked::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Masked @@ -6494,7 +6554,9 @@ pub struct vortex_array::arrays::Null impl vortex_array::arrays::null::Null -pub const vortex_array::arrays::null::Null::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::null::Null::ID: &'static str + +pub fn vortex_array::arrays::null::Null::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::null::Null @@ -6630,7 +6692,9 @@ pub struct vortex_array::arrays::Primitive impl vortex_array::arrays::Primitive -pub const vortex_array::arrays::Primitive::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Primitive::ID: &'static str + +pub fn vortex_array::arrays::Primitive::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Primitive @@ -6966,7 +7030,9 @@ pub struct vortex_array::arrays::Shared impl vortex_array::arrays::Shared -pub const vortex_array::arrays::Shared::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Shared::ID: &'static str + +pub fn vortex_array::arrays::Shared::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Shared @@ -7078,7 +7144,9 @@ pub struct vortex_array::arrays::Slice impl vortex_array::arrays::slice::Slice -pub const vortex_array::arrays::slice::Slice::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::slice::Slice::ID: &'static str + +pub fn vortex_array::arrays::slice::Slice::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::slice::Slice @@ -7198,7 +7266,9 @@ pub struct vortex_array::arrays::Struct impl vortex_array::arrays::Struct -pub const vortex_array::arrays::Struct::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Struct::ID: &'static str + +pub fn vortex_array::arrays::Struct::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Struct @@ -7430,7 +7500,9 @@ pub struct vortex_array::arrays::VarBin impl vortex_array::arrays::VarBin -pub const vortex_array::arrays::VarBin::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::VarBin::ID: &'static str + +pub fn vortex_array::arrays::VarBin::array_id() -> vortex_array::vtable::ArrayId impl vortex_array::arrays::VarBin @@ -7654,7 +7726,9 @@ pub struct vortex_array::arrays::VarBinView impl vortex_array::arrays::VarBinView -pub const vortex_array::arrays::VarBinView::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::VarBinView::ID: &'static str + +pub fn vortex_array::arrays::VarBinView::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::VarBinView @@ -9542,7 +9616,7 @@ pub struct vortex_array::compute::ComputeFn impl vortex_array::compute::ComputeFn -pub fn vortex_array::compute::ComputeFn::id(&self) -> &arcref::ArcRef +pub fn vortex_array::compute::ComputeFn::id(&self) -> vortex_session::registry::Id pub fn vortex_array::compute::ComputeFn::invoke(&self, args: &vortex_array::compute::InvocationArgs<'_>) -> vortex_error::VortexResult @@ -9550,7 +9624,7 @@ pub fn vortex_array::compute::ComputeFn::is_elementwise(&self) -> bool pub fn vortex_array::compute::ComputeFn::kernels(&self) -> alloc::vec::Vec> -pub fn vortex_array::compute::ComputeFn::new(id: arcref::ArcRef, vtable: arcref::ArcRef) -> Self +pub fn vortex_array::compute::ComputeFn::new(id: vortex_session::registry::Id, vtable: arcref::ArcRef) -> Self pub fn vortex_array::compute::ComputeFn::register_kernel(&self, kernel: arcref::ArcRef) @@ -9868,7 +9942,7 @@ impl vortex_array::dtype::extensio pub fn V::deserialize(&self, data: &[u8], storage_dtype: vortex_array::dtype::DType) -> core::result::Result -pub fn V::id(&self) -> arcref::ArcRef +pub fn V::id(&self) -> vortex_session::registry::Id pub trait vortex_array::dtype::extension::ExtVTable: 'static + core::marker::Sized + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + core::cmp::Eq + core::hash::Hash @@ -10016,7 +10090,7 @@ pub fn V::try_match<'a>(item: &'a vortex_array::dtype::extension::ExtDTypeRef) - pub type vortex_array::dtype::extension::ExtDTypePluginRef = alloc::sync::Arc -pub type vortex_array::dtype::extension::ExtId = arcref::ArcRef +pub type vortex_array::dtype::extension::ExtId = vortex_session::registry::Id pub mod vortex_array::dtype::flatbuffers @@ -18642,7 +18716,7 @@ impl vortex_array::scalar_fn::Scalar pub fn V::deserialize(&self, metadata: &[u8], session: &vortex_session::VortexSession) -> core::result::Result -pub fn V::id(&self) -> arcref::ArcRef +pub fn V::id(&self) -> vortex_session::registry::Id pub trait vortex_array::scalar_fn::ScalarFnVTable: 'static + core::marker::Sized + core::clone::Clone + core::marker::Send + core::marker::Sync @@ -19386,11 +19460,11 @@ pub trait vortex_array::scalar_fn::SimplifyCtx pub fn vortex_array::scalar_fn::SimplifyCtx::return_dtype(&self, expr: &vortex_array::expr::Expression) -> vortex_error::VortexResult -pub type vortex_array::scalar_fn::ChildName = arcref::ArcRef +pub type vortex_array::scalar_fn::ChildName = vortex_session::registry::Id pub type vortex_array::scalar_fn::ReduceNodeRef = alloc::sync::Arc -pub type vortex_array::scalar_fn::ScalarFnId = arcref::ArcRef +pub type vortex_array::scalar_fn::ScalarFnId = vortex_session::registry::Id pub type vortex_array::scalar_fn::ScalarFnPluginRef = alloc::sync::Arc @@ -21462,7 +21536,7 @@ pub fn vortex_array::vtable::validity_nchildren(validity: &vortex_array::validit pub fn vortex_array::vtable::validity_to_child(validity: &vortex_array::validity::Validity, len: usize) -> core::option::Option -pub type vortex_array::vtable::ArrayId = arcref::ArcRef +pub type vortex_array::vtable::ArrayId = vortex_session::registry::Id pub macro vortex_array::field_path! diff --git a/vortex-array/src/aggregate_fn/accumulator.rs b/vortex-array/src/aggregate_fn/accumulator.rs index 95d5268b969..821eb0d02a0 100644 --- a/vortex-array/src/aggregate_fn/accumulator.rs +++ b/vortex-array/src/aggregate_fn/accumulator.rs @@ -112,7 +112,7 @@ impl DynAccumulator for Accumulator { let kernels_r = kernels.read(); let batch_id = batch.encoding_id(); if let Some(result) = kernels_r - .get(&(batch_id.clone(), Some(self.aggregate_fn.id()))) + .get(&(batch_id, Some(self.aggregate_fn.id()))) .or_else(|| kernels_r.get(&(batch_id, None))) .and_then(|kernel| { kernel 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 8a9c4e295f2..63fc040f274 100644 --- a/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs @@ -228,7 +228,7 @@ impl AggregateFnVTable for IsSorted { type Partial = IsSortedPartial; fn id(&self) -> AggregateFnId { - AggregateFnId::new_ref("vortex.is_sorted") + AggregateFnId::new("vortex.is_sorted") } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/session.rs b/vortex-array/src/aggregate_fn/session.rs index 0fc54f81052..bb9cfeac42c 100644 --- a/vortex-array/src/aggregate_fn/session.rs +++ b/vortex-array/src/aggregate_fn/session.rs @@ -48,7 +48,7 @@ impl Default for AggregateFnSession { }; // Register the built-in aggregate kernels. - this.register_aggregate_kernel(Chunked::ID, None, &ChunkedArrayAggregate); + this.register_aggregate_kernel(Chunked::ID, None::, &ChunkedArrayAggregate); this.register_aggregate_kernel(Dict::ID, Some(MinMax.id()), &DictMinMaxKernel); this.register_aggregate_kernel(Dict::ID, Some(IsConstant.id()), &DictIsConstantKernel); this.register_aggregate_kernel(Dict::ID, Some(IsSorted.id()), &DictIsSortedKernel); @@ -73,11 +73,13 @@ impl AggregateFnSession { /// Register an aggregate function kernel for a specific aggregate function and array type. pub fn register_aggregate_kernel( &self, - array_id: ArrayId, - agg_fn_id: Option, + array_id: impl Into, + agg_fn_id: Option>, kernel: &'static dyn DynAggregateKernel, ) { - self.kernels.write().insert((array_id, agg_fn_id), kernel); + self.kernels + .write() + .insert((array_id.into(), agg_fn_id.map(|id| id.into())), kernel); } } diff --git a/vortex-array/src/arrays/bool/vtable/mod.rs b/vortex-array/src/arrays/bool/vtable/mod.rs index bad5ca50268..730634fad2e 100644 --- a/vortex-array/src/arrays/bool/vtable/mod.rs +++ b/vortex-array/src/arrays/bool/vtable/mod.rs @@ -57,7 +57,7 @@ impl VTable for Bool { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &BoolArray) -> usize { @@ -211,5 +211,11 @@ impl VTable for Bool { pub struct Bool; impl Bool { - pub const ID: ArrayId = ArrayId::new("vortex.bool"); + pub const ID: &'static str = "vortex.bool"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/chunked/vtable/mod.rs b/vortex-array/src/arrays/chunked/vtable/mod.rs index d72327d9197..741a3ce7c24 100644 --- a/vortex-array/src/arrays/chunked/vtable/mod.rs +++ b/vortex-array/src/arrays/chunked/vtable/mod.rs @@ -46,7 +46,13 @@ vtable!(Chunked); pub struct Chunked; impl Chunked { - pub const ID: ArrayId = ArrayId::new("vortex.chunked"); + pub const ID: &'static str = "vortex.chunked"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Chunked { @@ -56,7 +62,7 @@ impl VTable for Chunked { type OperationsVTable = Self; type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ChunkedArray) -> usize { diff --git a/vortex-array/src/arrays/constant/vtable/mod.rs b/vortex-array/src/arrays/constant/vtable/mod.rs index 46cc236a6e3..c1c0ec6265b 100644 --- a/vortex-array/src/arrays/constant/vtable/mod.rs +++ b/vortex-array/src/arrays/constant/vtable/mod.rs @@ -48,7 +48,13 @@ vtable!(Constant); pub struct Constant; impl Constant { - pub const ID: ArrayId = ArrayId::new("vortex.constant"); + pub const ID: &'static str = "vortex.constant"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Constant { @@ -59,7 +65,7 @@ impl VTable for Constant { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ConstantArray) -> usize { diff --git a/vortex-array/src/arrays/decimal/vtable/mod.rs b/vortex-array/src/arrays/decimal/vtable/mod.rs index 29bb8797910..1588040a14a 100644 --- a/vortex-array/src/arrays/decimal/vtable/mod.rs +++ b/vortex-array/src/arrays/decimal/vtable/mod.rs @@ -59,7 +59,7 @@ impl VTable for Decimal { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &DecimalArray) -> usize { @@ -233,7 +233,13 @@ impl VTable for Decimal { pub struct Decimal; impl Decimal { - pub const ID: ArrayId = ArrayId::new("vortex.decimal"); + pub const ID: &'static str = "vortex.decimal"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[cfg(test)] diff --git a/vortex-array/src/arrays/dict/vtable/mod.rs b/vortex-array/src/arrays/dict/vtable/mod.rs index 05a00fb1a6c..ed1ce3283ad 100644 --- a/vortex-array/src/arrays/dict/vtable/mod.rs +++ b/vortex-array/src/arrays/dict/vtable/mod.rs @@ -48,7 +48,13 @@ vtable!(Dict); pub struct Dict; impl Dict { - pub const ID: ArrayId = ArrayId::new("vortex.dict"); + pub const ID: &'static str = "vortex.dict"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Dict { @@ -59,7 +65,7 @@ impl VTable for Dict { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &DictArray) -> usize { diff --git a/vortex-array/src/arrays/extension/vtable/mod.rs b/vortex-array/src/arrays/extension/vtable/mod.rs index 9da4aa4dd69..e5de1368f48 100644 --- a/vortex-array/src/arrays/extension/vtable/mod.rs +++ b/vortex-array/src/arrays/extension/vtable/mod.rs @@ -44,7 +44,7 @@ impl VTable for Extension { type ValidityVTable = ValidityVTableFromChild; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ExtensionArray) -> usize { @@ -179,5 +179,11 @@ impl VTable for Extension { pub struct Extension; impl Extension { - pub const ID: ArrayId = ArrayId::new("vortex.ext"); + pub const ID: &'static str = "vortex.ext"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/filter/vtable.rs b/vortex-array/src/arrays/filter/vtable.rs index 79d1b5e0d03..2488e70c9e7 100644 --- a/vortex-array/src/arrays/filter/vtable.rs +++ b/vortex-array/src/arrays/filter/vtable.rs @@ -44,7 +44,13 @@ vtable!(Filter); pub struct Filter; impl Filter { - pub const ID: ArrayId = ArrayId::new("vortex.filter"); + pub const ID: &'static str = "vortex.filter"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Filter { @@ -53,7 +59,7 @@ impl VTable for Filter { type OperationsVTable = Self; type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &FilterArray) -> usize { diff --git a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs index 3ea78c17a49..310f756432d 100644 --- a/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs +++ b/vortex-array/src/arrays/fixed_size_list/vtable/mod.rs @@ -40,7 +40,13 @@ vtable!(FixedSizeList); pub struct FixedSizeList; impl FixedSizeList { - pub const ID: ArrayId = ArrayId::new("vortex.fixed_size_list"); + pub const ID: &'static str = "vortex.fixed_size_list"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for FixedSizeList { @@ -50,7 +56,7 @@ impl VTable for FixedSizeList { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &FixedSizeListArray) -> usize { diff --git a/vortex-array/src/arrays/list/vtable/mod.rs b/vortex-array/src/arrays/list/vtable/mod.rs index 00d898ede0b..4f8de85b6fa 100644 --- a/vortex-array/src/arrays/list/vtable/mod.rs +++ b/vortex-array/src/arrays/list/vtable/mod.rs @@ -57,7 +57,7 @@ impl VTable for List { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ListArray) -> usize { @@ -231,5 +231,11 @@ impl VTable for List { pub struct List; impl List { - pub const ID: ArrayId = ArrayId::new("vortex.list"); + pub const ID: &'static str = "vortex.list"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/listview/vtable/mod.rs b/vortex-array/src/arrays/listview/vtable/mod.rs index 6a138f53133..4b22145b681 100644 --- a/vortex-array/src/arrays/listview/vtable/mod.rs +++ b/vortex-array/src/arrays/listview/vtable/mod.rs @@ -43,7 +43,13 @@ vtable!(ListView); pub struct ListView; impl ListView { - pub const ID: ArrayId = ArrayId::new("vortex.listview"); + pub const ID: &'static str = "vortex.listview"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } #[derive(Clone, prost::Message)] @@ -63,7 +69,7 @@ impl VTable for ListView { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &ListViewArray) -> usize { diff --git a/vortex-array/src/arrays/masked/vtable/mod.rs b/vortex-array/src/arrays/masked/vtable/mod.rs index c2f2dd787e2..1e681e5a983 100644 --- a/vortex-array/src/arrays/masked/vtable/mod.rs +++ b/vortex-array/src/arrays/masked/vtable/mod.rs @@ -44,7 +44,13 @@ vtable!(Masked); pub struct Masked; impl Masked { - pub const ID: ArrayId = ArrayId::new("vortex.masked"); + pub const ID: &'static str = "vortex.masked"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Masked { @@ -55,7 +61,7 @@ impl VTable for Masked { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &MaskedArray) -> usize { diff --git a/vortex-array/src/arrays/null/mod.rs b/vortex-array/src/arrays/null/mod.rs index c49cba53a14..9bf5ba6bb8b 100644 --- a/vortex-array/src/arrays/null/mod.rs +++ b/vortex-array/src/arrays/null/mod.rs @@ -40,7 +40,7 @@ impl VTable for Null { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &NullArray) -> usize { @@ -174,7 +174,13 @@ pub struct NullArray { pub struct Null; impl Null { - pub const ID: ArrayId = ArrayId::new("vortex.null"); + pub const ID: &'static str = "vortex.null"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl NullArray { diff --git a/vortex-array/src/arrays/primitive/vtable/mod.rs b/vortex-array/src/arrays/primitive/vtable/mod.rs index 0ebf8158ab9..78ddb4d5fc2 100644 --- a/vortex-array/src/arrays/primitive/vtable/mod.rs +++ b/vortex-array/src/arrays/primitive/vtable/mod.rs @@ -51,7 +51,7 @@ impl VTable for Primitive { type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &PrimitiveArray) -> usize { @@ -225,5 +225,11 @@ impl VTable for Primitive { pub struct Primitive; impl Primitive { - pub const ID: ArrayId = ArrayId::new("vortex.primitive"); + pub const ID: &'static str = "vortex.primitive"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs index 9d8131c7612..135078e1822 100644 --- a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs +++ b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs @@ -324,7 +324,7 @@ impl scalar_fn::ScalarFnVTable for ArrayExpr { type Options = FakeEq; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.array") + ScalarFnId::new("vortex.array") } fn arity(&self, _options: &Self::Options) -> Arity { diff --git a/vortex-array/src/arrays/shared/vtable.rs b/vortex-array/src/arrays/shared/vtable.rs index 48e1cb70d91..b35d967301a 100644 --- a/vortex-array/src/arrays/shared/vtable.rs +++ b/vortex-array/src/arrays/shared/vtable.rs @@ -36,7 +36,13 @@ vtable!(Shared); pub struct Shared; impl Shared { - pub const ID: ArrayId = ArrayId::new("vortex.shared"); + pub const ID: &'static str = "vortex.shared"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Shared { @@ -45,7 +51,7 @@ impl VTable for Shared { type OperationsVTable = Self; type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &SharedArray) -> usize { diff --git a/vortex-array/src/arrays/slice/vtable.rs b/vortex-array/src/arrays/slice/vtable.rs index 14dff3a9a2e..4b76e1805d0 100644 --- a/vortex-array/src/arrays/slice/vtable.rs +++ b/vortex-array/src/arrays/slice/vtable.rs @@ -43,7 +43,13 @@ vtable!(Slice); pub struct Slice; impl Slice { - pub const ID: ArrayId = ArrayId::new("vortex.slice"); + pub const ID: &'static str = "vortex.slice"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Slice { @@ -52,7 +58,7 @@ impl VTable for Slice { type OperationsVTable = Self; type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Slice::ID + Slice::array_id() } fn len(array: &SliceArray) -> usize { diff --git a/vortex-array/src/arrays/struct_/vtable/mod.rs b/vortex-array/src/arrays/struct_/vtable/mod.rs index 7633628f12c..f48b5af103b 100644 --- a/vortex-array/src/arrays/struct_/vtable/mod.rs +++ b/vortex-array/src/arrays/struct_/vtable/mod.rs @@ -48,7 +48,7 @@ impl VTable for Struct { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &StructArray) -> usize { @@ -233,5 +233,11 @@ impl VTable for Struct { pub struct Struct; impl Struct { - pub const ID: ArrayId = ArrayId::new("vortex.struct"); + pub const ID: &'static str = "vortex.struct"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/varbin/vtable/mod.rs b/vortex-array/src/arrays/varbin/vtable/mod.rs index 23f8f693f42..fc98b8b0b32 100644 --- a/vortex-array/src/arrays/varbin/vtable/mod.rs +++ b/vortex-array/src/arrays/varbin/vtable/mod.rs @@ -58,7 +58,7 @@ impl VTable for VarBin { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &VarBinArray) -> usize { @@ -230,5 +230,11 @@ impl VTable for VarBin { pub struct VarBin; impl VarBin { - pub const ID: ArrayId = ArrayId::new("vortex.varbin"); + pub const ID: &'static str = "vortex.varbin"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } diff --git a/vortex-array/src/arrays/varbinview/vtable/mod.rs b/vortex-array/src/arrays/varbinview/vtable/mod.rs index 99a6a0e1bef..a59fd7ae553 100644 --- a/vortex-array/src/arrays/varbinview/vtable/mod.rs +++ b/vortex-array/src/arrays/varbinview/vtable/mod.rs @@ -45,7 +45,13 @@ vtable!(VarBinView); pub struct VarBinView; impl VarBinView { - pub const ID: ArrayId = ArrayId::new("vortex.varbinview"); + pub const ID: &'static str = "vortex.varbinview"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for VarBinView { @@ -55,7 +61,7 @@ impl VTable for VarBinView { type OperationsVTable = Self; type ValidityVTable = ValidityVTableFromValidityHelper; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &VarBinViewArray) -> usize { diff --git a/vortex-array/src/dtype/serde/flatbuffers.rs b/vortex-array/src/dtype/serde/flatbuffers.rs index 75eb32e4ad3..d54b7c687bf 100644 --- a/vortex-array/src/dtype/serde/flatbuffers.rs +++ b/vortex-array/src/dtype/serde/flatbuffers.rs @@ -194,13 +194,10 @@ impl TryFrom for DType { let fb_ext = fb .type__as_extension() .ok_or_else(|| vortex_err!("failed to parse extension from flatbuffer"))?; - let id = ExtId::new_arc( - fb_ext - .id() - .ok_or_else(|| vortex_err!("failed to parse extension id from flatbuffer"))? - .to_string() - .into(), - ); + let id = + ExtId::new(fb_ext.id().ok_or_else(|| { + vortex_err!("failed to parse extension id from flatbuffer") + })?); let storage_dtype = fb_ext.storage_dtype().ok_or_else(|| { vortex_err!( Serde: "storage_dtype must be present on DType fbs message") diff --git a/vortex-array/src/dtype/serde/proto.rs b/vortex-array/src/dtype/serde/proto.rs index 508eb42d2b4..25bfd34e4e6 100644 --- a/vortex-array/src/dtype/serde/proto.rs +++ b/vortex-array/src/dtype/serde/proto.rs @@ -86,7 +86,7 @@ impl DType { )) } DtypeType::Extension(e) => { - let id = ExtId::new_arc(e.id.as_str().to_string().into()); + let id = ExtId::new(e.id.as_str()); let vtable = session.dtypes().registry().find(&id).ok_or_else( || vortex_err!(Serde: "Unregistered extension type ID: {}", e.id), )?; diff --git a/vortex-array/src/dtype/serde/serde.rs b/vortex-array/src/dtype/serde/serde.rs index 63044385548..0b0320958ec 100644 --- a/vortex-array/src/dtype/serde/serde.rs +++ b/vortex-array/src/dtype/serde/serde.rs @@ -570,7 +570,7 @@ impl<'de> DeserializeSeed<'de> for DTypeSerde<'_, ExtDTypeRef> { } let id = id.ok_or_else(|| de::Error::missing_field("id"))?; - let id = ExtId::new_arc(id); + let id = ExtId::new(&id); let vtable = self.session.dtypes().registry().find(&id).ok_or_else(|| { de::Error::custom(format!("unknown extension dtype id: {}", id)) })?; diff --git a/vortex-array/src/expr/proto.rs b/vortex-array/src/expr/proto.rs index 16b063ac831..0dcb834f90f 100644 --- a/vortex-array/src/expr/proto.rs +++ b/vortex-array/src/expr/proto.rs @@ -1,8 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -use std::sync::Arc; - use itertools::Itertools; use vortex_error::VortexResult; use vortex_error::vortex_err; @@ -40,7 +38,7 @@ impl ExprSerializeProtoExt for Expression { impl Expression { pub fn from_proto(expr: &pb::Expr, session: &VortexSession) -> VortexResult { - let expr_id = ScalarFnId::new_arc(Arc::from(expr.id.to_string())); + let expr_id = ScalarFnId::new(expr.id.as_str()); let vtable = session .scalar_fns() .registry() diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index f4b942224d8..4aff0f5622e 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -194,7 +194,7 @@ impl ScalarFnVTable for Between { type Options = BetweenOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.between") + ScalarFnId::new("vortex.between") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { @@ -233,9 +233,9 @@ impl ScalarFnVTable for Between { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("array"), - 1 => ChildName::from("lower"), - 2 => ChildName::from("upper"), + 0 => ChildName::new("array"), + 1 => ChildName::new("lower"), + 2 => ChildName::new("upper"), _ => unreachable!("Invalid child index {} for Between expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/binary/mod.rs b/vortex-array/src/scalar_fn/fns/binary/mod.rs index 83385268397..fd58d2a8ff2 100644 --- a/vortex-array/src/scalar_fn/fns/binary/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/mod.rs @@ -52,7 +52,7 @@ impl ScalarFnVTable for Binary { type Options = Operator; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.binary") + ScalarFnId::new("vortex.binary") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { @@ -79,8 +79,8 @@ impl ScalarFnVTable for Binary { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("lhs"), - 1 => ChildName::from("rhs"), + 0 => ChildName::new("lhs"), + 1 => ChildName::new("rhs"), _ => unreachable!("Binary has only two children"), } } diff --git a/vortex-array/src/scalar_fn/fns/case_when.rs b/vortex-array/src/scalar_fn/fns/case_when.rs index 26a113ee7be..a8ca1a6ef4d 100644 --- a/vortex-array/src/scalar_fn/fns/case_when.rs +++ b/vortex-array/src/scalar_fn/fns/case_when.rs @@ -13,7 +13,6 @@ use std::fmt; use std::fmt::Formatter; use std::hash::Hash; -use std::sync::Arc; use prost::Message; use vortex_error::VortexResult; @@ -78,7 +77,7 @@ impl ScalarFnVTable for CaseWhen { type Options = CaseWhenOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.case_when") + ScalarFnId::new("vortex.case_when") } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { @@ -115,12 +114,12 @@ impl ScalarFnVTable for CaseWhen { if child_idx < num_pair_children { let pair_idx = child_idx / 2; if child_idx.is_multiple_of(2) { - ChildName::from(Arc::from(format!("when_{pair_idx}"))) + ChildName::new(&format!("when_{pair_idx}")) } else { - ChildName::from(Arc::from(format!("then_{pair_idx}"))) + ChildName::new(&format!("then_{pair_idx}")) } } else if options.has_else && child_idx == num_pair_children { - ChildName::from("else") + ChildName::new("else") } else { unreachable!("Invalid child index {} for CaseWhen", child_idx) } diff --git a/vortex-array/src/scalar_fn/fns/cast/mod.rs b/vortex-array/src/scalar_fn/fns/cast/mod.rs index bfa970c549e..e5571380884 100644 --- a/vortex-array/src/scalar_fn/fns/cast/mod.rs +++ b/vortex-array/src/scalar_fn/fns/cast/mod.rs @@ -53,7 +53,7 @@ impl ScalarFnVTable for Cast { type Options = DType; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.cast") + ScalarFnId::new("vortex.cast") } fn serialize(&self, dtype: &DType) -> VortexResult>> { @@ -85,7 +85,7 @@ impl ScalarFnVTable for Cast { fn child_name(&self, _instance: &DType, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), + 0 => ChildName::new("input"), _ => unreachable!("Invalid child index {} for Cast expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/dynamic.rs b/vortex-array/src/scalar_fn/fns/dynamic.rs index 0fa0afadaf9..ee13add8bd7 100644 --- a/vortex-array/src/scalar_fn/fns/dynamic.rs +++ b/vortex-array/src/scalar_fn/fns/dynamic.rs @@ -56,7 +56,7 @@ impl ScalarFnVTable for DynamicComparison { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("lhs"), + 0 => ChildName::new("lhs"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs index dd41c6e547b..bf10ee30701 100644 --- a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs +++ b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs @@ -39,7 +39,7 @@ impl ScalarFnVTable for FillNull { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.fill_null") + ScalarFnId::new("vortex.fill_null") } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { @@ -60,8 +60,8 @@ impl ScalarFnVTable for FillNull { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), - 1 => ChildName::from("fill_value"), + 0 => ChildName::new("input"), + 1 => ChildName::new("fill_value"), _ => unreachable!("Invalid child index {} for FillNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/get_item.rs b/vortex-array/src/scalar_fn/fns/get_item.rs index 1e0469bae27..f060c14e13d 100644 --- a/vortex-array/src/scalar_fn/fns/get_item.rs +++ b/vortex-array/src/scalar_fn/fns/get_item.rs @@ -43,7 +43,7 @@ impl ScalarFnVTable for GetItem { type Options = FieldName; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.get_item") + ScalarFnId::new("vortex.get_item") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { @@ -70,7 +70,7 @@ impl ScalarFnVTable for GetItem { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), + 0 => ChildName::new("input"), _ => unreachable!("Invalid child index {} for GetItem expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/is_null.rs b/vortex-array/src/scalar_fn/fns/is_null.rs index 4724f210ce2..00f4b123eed 100644 --- a/vortex-array/src/scalar_fn/fns/is_null.rs +++ b/vortex-array/src/scalar_fn/fns/is_null.rs @@ -55,7 +55,7 @@ impl ScalarFnVTable for IsNull { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), + 0 => ChildName::new("input"), _ => unreachable!("Invalid child index {} for IsNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/like/mod.rs b/vortex-array/src/scalar_fn/fns/like/mod.rs index b095d357e02..4ced1b417a2 100644 --- a/vortex-array/src/scalar_fn/fns/like/mod.rs +++ b/vortex-array/src/scalar_fn/fns/like/mod.rs @@ -63,7 +63,7 @@ impl ScalarFnVTable for Like { type Options = LikeOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.like") + ScalarFnId::new("vortex.like") } fn serialize(&self, instance: &Self::Options) -> VortexResult>> { @@ -94,8 +94,8 @@ impl ScalarFnVTable for Like { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("child"), - 1 => ChildName::from("pattern"), + 0 => ChildName::new("child"), + 1 => ChildName::new("pattern"), _ => unreachable!("Invalid child index {} for Like expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs index dd0b2d46918..91286450674 100644 --- a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs +++ b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs @@ -60,7 +60,7 @@ impl ScalarFnVTable for ListContains { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.list.contains") + ScalarFnId::new("vortex.list.contains") } fn serialize(&self, _instance: &Self::Options) -> VortexResult>> { @@ -81,8 +81,8 @@ impl ScalarFnVTable for ListContains { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("list"), - 1 => ChildName::from("needle"), + 0 => ChildName::new("list"), + 1 => ChildName::new("needle"), _ => unreachable!( "Invalid child index {} for ListContains expression", child_idx diff --git a/vortex-array/src/scalar_fn/fns/mask/mod.rs b/vortex-array/src/scalar_fn/fns/mask/mod.rs index abe80cc6fac..b96c778b66d 100644 --- a/vortex-array/src/scalar_fn/fns/mask/mod.rs +++ b/vortex-array/src/scalar_fn/fns/mask/mod.rs @@ -45,7 +45,7 @@ impl ScalarFnVTable for Mask { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.mask") + ScalarFnId::new("vortex.mask") } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { @@ -66,8 +66,8 @@ impl ScalarFnVTable for Mask { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), - 1 => ChildName::from("mask"), + 0 => ChildName::new("input"), + 1 => ChildName::new("mask"), _ => unreachable!("Invalid child index {} for Mask expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/merge.rs b/vortex-array/src/scalar_fn/fns/merge.rs index b74753bbc0b..b00d92a959d 100644 --- a/vortex-array/src/scalar_fn/fns/merge.rs +++ b/vortex-array/src/scalar_fn/fns/merge.rs @@ -4,7 +4,6 @@ use std::fmt::Display; use std::fmt::Formatter; use std::hash::Hash; -use std::sync::Arc; use itertools::Itertools as _; use vortex_error::VortexExpect; @@ -80,7 +79,7 @@ impl ScalarFnVTable for Merge { } fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { - ChildName::from(Arc::from(format!("{}", child_idx))) + ChildName::new(&format!("{child_idx}")) } fn fmt_sql( diff --git a/vortex-array/src/scalar_fn/fns/not/mod.rs b/vortex-array/src/scalar_fn/fns/not/mod.rs index bdeae78cc66..eee6093d1df 100644 --- a/vortex-array/src/scalar_fn/fns/not/mod.rs +++ b/vortex-array/src/scalar_fn/fns/not/mod.rs @@ -36,7 +36,7 @@ impl ScalarFnVTable for Not { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.not") + ScalarFnId::new("vortex.not") } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { @@ -57,7 +57,7 @@ impl ScalarFnVTable for Not { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("input"), + 0 => ChildName::new("input"), _ => unreachable!("Invalid child index {} for Not expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/pack.rs b/vortex-array/src/scalar_fn/fns/pack.rs index a6d779d5d0b..403724d478e 100644 --- a/vortex-array/src/scalar_fn/fns/pack.rs +++ b/vortex-array/src/scalar_fn/fns/pack.rs @@ -90,7 +90,7 @@ impl ScalarFnVTable for Pack { fn child_name(&self, instance: &Self::Options, child_idx: usize) -> ChildName { match instance.names.get(child_idx) { - Some(name) => ChildName::from(name.inner().clone()), + Some(name) => ChildName::new(name.inner()), None => unreachable!( "Invalid child index {} for Pack expression with {} fields", child_idx, diff --git a/vortex-array/src/scalar_fn/fns/root.rs b/vortex-array/src/scalar_fn/fns/root.rs index 7e04746db19..99bb6fecf6e 100644 --- a/vortex-array/src/scalar_fn/fns/root.rs +++ b/vortex-array/src/scalar_fn/fns/root.rs @@ -30,7 +30,7 @@ impl ScalarFnVTable for Root { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.root") + ScalarFnId::new("vortex.root") } fn serialize(&self, _instance: &Self::Options) -> VortexResult>> { diff --git a/vortex-array/src/scalar_fn/fns/zip/mod.rs b/vortex-array/src/scalar_fn/fns/zip/mod.rs index e5f5f18d964..44e4e4fcc68 100644 --- a/vortex-array/src/scalar_fn/fns/zip/mod.rs +++ b/vortex-array/src/scalar_fn/fns/zip/mod.rs @@ -46,7 +46,7 @@ impl ScalarFnVTable for Zip { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.zip") + ScalarFnId::new("vortex.zip") } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { @@ -67,9 +67,9 @@ impl ScalarFnVTable for Zip { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("if_true"), - 1 => ChildName::from("if_false"), - 2 => ChildName::from("mask"), + 0 => ChildName::new("if_true"), + 1 => ChildName::new("if_false"), + 2 => ChildName::new("mask"), _ => unreachable!("Invalid child index {} for Zip expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/vtable.rs b/vortex-array/src/scalar_fn/vtable.rs index 00f9f905afb..858e5d8c071 100644 --- a/vortex-array/src/scalar_fn/vtable.rs +++ b/vortex-array/src/scalar_fn/vtable.rs @@ -411,4 +411,4 @@ pub trait ScalarFnVTableExt: ScalarFnVTable { impl ScalarFnVTableExt for V {} /// A reference to the name of a child expression. -pub type ChildName = vortex_utils::Id; +pub type ChildName = vortex_session::registry::Id; diff --git a/vortex-array/src/serde.rs b/vortex-array/src/serde.rs index c4f885f6c2a..d8188e9c924 100644 --- a/vortex-array/src/serde.rs +++ b/vortex-array/src/serde.rs @@ -341,7 +341,7 @@ impl ArrayParts { let buffers = self.collect_buffers()?; let decoded = vtable.build( - encoding_id.clone(), + encoding_id, dtype, len, self.metadata(), diff --git a/vortex-cuda/src/session.rs b/vortex-cuda/src/session.rs index 733c5fd636b..afeb8cd1389 100644 --- a/vortex-cuda/src/session.rs +++ b/vortex-cuda/src/session.rs @@ -85,8 +85,12 @@ impl CudaSession { /// /// * `array_id` - The encoding ID to register support for /// * `executor` - A static reference to the CUDA support implementation - pub fn register_kernel(&self, array_id: ArrayId, executor: &'static dyn CudaExecute) { - self.kernels.insert(array_id, executor); + pub fn register_kernel( + &self, + array_id: impl Into, + executor: &'static dyn CudaExecute, + ) { + self.kernels.insert(array_id.into(), executor); } /// Retrieves the CUDA support implementation for an encoding, if registered. diff --git a/vortex-file/src/footer/mod.rs b/vortex-file/src/footer/mod.rs index f4e4c477259..f608ce077f3 100644 --- a/vortex-file/src/footer/mod.rs +++ b/vortex-file/src/footer/mod.rs @@ -88,7 +88,7 @@ impl Footer { let layout_ids: Arc<[_]> = layout_specs .iter() .flat_map(|e| e.iter()) - .map(|encoding| LayoutEncodingId::new_arc(Arc::from(encoding.id()))) + .map(|encoding| LayoutEncodingId::new(encoding.id())) .collect(); let layout_read_ctx = ReadContext::new(layout_ids); @@ -97,7 +97,7 @@ impl Footer { let array_ids: Arc<[_]> = array_specs .iter() .flat_map(|e| e.iter()) - .map(|encoding| ArrayId::new_arc(Arc::from(encoding.id()))) + .map(|encoding| ArrayId::new(encoding.id())) .collect(); let array_read_ctx = ReadContext::new(array_ids); diff --git a/vortex-ipc/src/messages/decoder.rs b/vortex-ipc/src/messages/decoder.rs index ca863410855..35e7ef684ab 100644 --- a/vortex-ipc/src/messages/decoder.rs +++ b/vortex-ipc/src/messages/decoder.rs @@ -125,7 +125,7 @@ impl MessageDecoder { .encodings() .iter() .flat_map(|e| e.iter()) - .map(|id| ArrayId::new_arc(Arc::from(id.to_string()))) + .map(ArrayId::new) .collect(); let ctx = ReadContext::new(encoding_ids); diff --git a/vortex-layout/public-api.lock b/vortex-layout/public-api.lock index 2cb3dec9d9a..c6754e19126 100644 --- a/vortex-layout/public-api.lock +++ b/vortex-layout/public-api.lock @@ -1960,11 +1960,11 @@ pub type vortex_layout::ArrayFuture = futures_core::future::BoxFuture<'static, v pub type vortex_layout::LayoutContext = vortex_session::registry::Context -pub type vortex_layout::LayoutEncodingId = arcref::ArcRef +pub type vortex_layout::LayoutEncodingId = vortex_session::registry::Id pub type vortex_layout::LayoutEncodingRef = arcref::ArcRef -pub type vortex_layout::LayoutId = arcref::ArcRef +pub type vortex_layout::LayoutId = vortex_session::registry::Id pub type vortex_layout::LayoutReaderRef = alloc::sync::Arc diff --git a/vortex-layout/src/encoding.rs b/vortex-layout/src/encoding.rs index 5a14482cbe1..edfe0c0724c 100644 --- a/vortex-layout/src/encoding.rs +++ b/vortex-layout/src/encoding.rs @@ -12,8 +12,8 @@ use vortex_array::dtype::DType; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_panic; -use vortex_session::registry::ReadContext; use vortex_session::registry::Id; +use vortex_session::registry::ReadContext; use crate::IntoLayout; use crate::LayoutChildren; diff --git a/vortex-layout/src/layouts/row_idx/expr.rs b/vortex-layout/src/layouts/row_idx/expr.rs index c235193ac6c..2d85d6e43f5 100644 --- a/vortex-layout/src/layouts/row_idx/expr.rs +++ b/vortex-layout/src/layouts/row_idx/expr.rs @@ -25,7 +25,7 @@ impl ScalarFnVTable for RowIdx { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::from("vortex.row_idx") + ScalarFnId::new("vortex.row_idx") } fn arity(&self, _options: &Self::Options) -> Arity { diff --git a/vortex-python/src/arrays/py/array.rs b/vortex-python/src/arrays/py/array.rs index 48d623efa4d..acc926f4590 100644 --- a/vortex-python/src/arrays/py/array.rs +++ b/vortex-python/src/arrays/py/array.rs @@ -35,7 +35,7 @@ impl<'py> FromPyObject<'_, 'py> for PythonArray { let ob_cast = ob.cast::()?; let python_array = ob_cast.get(); Ok(Self { - id: python_array.id.clone(), + id: python_array.id, object: Arc::new(ob.to_owned().unbind()), len: python_array.len, dtype: python_array.dtype.clone(), diff --git a/vortex-python/src/arrays/py/mod.rs b/vortex-python/src/arrays/py/mod.rs index f15ffbaed9b..0395b1bc543 100644 --- a/vortex-python/src/arrays/py/mod.rs +++ b/vortex-python/src/arrays/py/mod.rs @@ -18,15 +18,14 @@ use crate::error::PyVortexResult; /// Extract the array id from a Python class `id` attribute. pub fn id_from_obj(cls: &Bound) -> PyVortexResult { - Ok(ArrayId::new_arc( - cls.getattr("id") - .map_err(|_| { - PyValueError::new_err(format!( - "PyEncoding subclass {cls:?} must have an 'id' attribute" - )) - })? - .extract::() - .map_err(|_| PyValueError::new_err("'id' attribute must be a string"))? - .into(), - )) + let id_str: String = cls + .getattr("id") + .map_err(|_| { + PyValueError::new_err(format!( + "PyEncoding subclass {cls:?} must have an 'id' attribute" + )) + })? + .extract() + .map_err(|_| PyValueError::new_err("'id' attribute must be a string"))?; + Ok(ArrayId::new(&id_str)) } diff --git a/vortex-python/src/arrays/py/vtable.rs b/vortex-python/src/arrays/py/vtable.rs index c69961bfa18..12f2e49c488 100644 --- a/vortex-python/src/arrays/py/vtable.rs +++ b/vortex-python/src/arrays/py/vtable.rs @@ -46,7 +46,7 @@ impl VTable for Python { type ValidityVTable = Self; fn id(array: &Self::Array) -> ArrayId { - array.id.clone() + array.id } fn len(array: &PythonArray) -> usize { diff --git a/vortex-python/src/serde/context.rs b/vortex-python/src/serde/context.rs index 6a4f6d5d3a2..9e88a523749 100644 --- a/vortex-python/src/serde/context.rs +++ b/vortex-python/src/serde/context.rs @@ -74,9 +74,7 @@ impl PyReadContext { #[new] fn new(ids: Vec) -> Self { Self(ReadContext::new( - ids.into_iter() - .map(|i| Id::new_arc(Arc::from(i))) - .collect::>(), + ids.into_iter().map(|i| Id::new(&i)).collect::>(), )) } diff --git a/vortex-session/Cargo.toml b/vortex-session/Cargo.toml index f6af94e1260..1c349e8beb9 100644 --- a/vortex-session/Cargo.toml +++ b/vortex-session/Cargo.toml @@ -23,5 +23,6 @@ workspace = true arcref = { workspace = true } dashmap = { workspace = true } parking_lot = { workspace = true } +string-interner = { workspace = true } vortex-error = { workspace = true } vortex-utils = { workspace = true, features = ["dashmap"] } diff --git a/vortex-session/public-api.lock b/vortex-session/public-api.lock index 65dc969ad79..558b502b58d 100644 --- a/vortex-session/public-api.lock +++ b/vortex-session/public-api.lock @@ -28,6 +28,64 @@ impl core::default::Default for vortex_session::registry::Context pub fn vortex_session::registry::Context::default() -> Self +pub struct vortex_session::registry::Id(_) + +impl vortex_session::registry::Id + +pub fn vortex_session::registry::Id::as_str(&self) -> &str + +pub fn vortex_session::registry::Id::new(s: &str) -> Self + +impl core::clone::Clone for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::clone(&self) -> vortex_session::registry::Id + +impl core::cmp::Eq for vortex_session::registry::Id + +impl core::cmp::Ord for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::cmp(&self, other: &Self) -> core::cmp::Ordering + +impl core::cmp::PartialEq for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::eq(&self, other: &vortex_session::registry::Id) -> bool + +impl core::cmp::PartialEq<&str> for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::eq(&self, other: &&str) -> bool + +impl core::cmp::PartialEq for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::eq(&self, other: &str) -> bool + +impl core::cmp::PartialOrd for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::partial_cmp(&self, other: &Self) -> core::option::Option + +impl core::convert::AsRef for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::as_ref(&self) -> &str + +impl core::convert::From<&str> for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::from(s: &str) -> Self + +impl core::fmt::Debug for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result + +impl core::fmt::Display for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result + +impl core::hash::Hash for vortex_session::registry::Id + +pub fn vortex_session::registry::Id::hash<__H: core::hash::Hasher>(&self, state: &mut __H) + +impl core::marker::Copy for vortex_session::registry::Id + +impl core::marker::StructuralPartialEq for vortex_session::registry::Id + pub struct vortex_session::registry::ReadContext impl vortex_session::registry::ReadContext @@ -76,8 +134,6 @@ impl core::default::Default for vortex_session::registry::Registry pub fn vortex_session::registry::Registry::default() -> Self -pub type vortex_session::registry::Id = arcref::ArcRef - pub struct vortex_session::Ref<'a, T>(_) impl<'a, T> vortex_session::Ref<'a, T> diff --git a/vortex-session/src/registry.rs b/vortex-session/src/registry.rs index b5452f8b1de..1553a0cf117 100644 --- a/vortex-session/src/registry.rs +++ b/vortex-session/src/registry.rs @@ -11,39 +11,61 @@ use std::fmt::Display; use std::fmt::Formatter; use std::ops::Deref; use std::sync::Arc; +use std::sync::LazyLock; use parking_lot::RwLock; +use string_interner::DefaultBackend; +use string_interner::DefaultSymbol; +use string_interner::StringInterner; use vortex_error::VortexExpect; use vortex_utils::aliases::dash_map::DashMap; -/// A lightweight, copyable identifier backed by a `&'static str`. +/// Global string interner for [`Id`] values. +static INTERNER: LazyLock>> = LazyLock::new(Default::default); + +/// A lightweight, copyable identifier backed by a global string interner. /// /// Used for array encoding IDs, scalar function IDs, layout IDs, and similar -/// globally-unique string identifiers throughout Vortex. +/// globally-unique string identifiers throughout Vortex. Equality and hashing +/// are O(1) symbol comparisons. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -pub struct Id(&'static str); +pub struct Id(DefaultSymbol); impl Id { - /// Create a new `Id` from a static string. - pub const fn new(s: &'static str) -> Self { - Self(s) + /// Intern a string and return its `Id`. + pub fn new(s: &str) -> Self { + Self(INTERNER.write().get_or_intern(s)) + } + + /// Returns the interned string. + pub fn as_str(&self) -> &str { + // SAFETY: The interner is append-only (symbols are never removed), so the resolved + // string reference is valid for the lifetime of this borrow. + let interner = INTERNER.read(); + let s = interner + .resolve(self.0) + .vortex_expect("Id symbol not found in interner"); + // SAFETY: The interner is append-only and lives for 'static, so the &str is valid + // for the program's lifetime. We just can't express that through the RwLock borrow. + unsafe { &*(s as *const str) } } +} - /// Returns the underlying string. - pub const fn as_str(&self) -> &'static str { - self.0 +impl From<&str> for Id { + fn from(s: &str) -> Self { + Self::new(s) } } impl Display for Id { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str(self.0) + f.write_str(self.as_str()) } } impl Debug for Id { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "Id(\"{}\")", self.0) + write!(f, "Id(\"{}\")", self.as_str()) } } @@ -55,19 +77,25 @@ impl PartialOrd for Id { impl Ord for Id { fn cmp(&self, other: &Self) -> Ordering { - self.0.cmp(other.0) + self.as_str().cmp(other.as_str()) } } impl PartialEq for Id { fn eq(&self, other: &str) -> bool { - self.0 == other + self.as_str() == other + } +} + +impl PartialEq<&str> for Id { + fn eq(&self, other: &&str) -> bool { + self.as_str() == *other } } impl AsRef for Id { fn as_ref(&self) -> &str { - self.0 + self.as_str() } } @@ -88,7 +116,7 @@ impl Registry { /// List the IDs in the registry. pub fn ids(&self) -> impl Iterator + '_ { - self.0.iter().map(|i| i.key().clone()) + self.0.iter().map(|i| *i.key()) } /// List the items in the registry. @@ -211,7 +239,7 @@ impl Context { idx < u16::MAX as usize, "Cannot have more than u16::MAX items" ); - ids.push(id.clone()); + ids.push(*id); Some(u16::try_from(idx).vortex_expect("checked already")) } diff --git a/vortex-tensor/src/scalar_fns/cosine_similarity.rs b/vortex-tensor/src/scalar_fns/cosine_similarity.rs index 63ae16da8b5..ef56d101abc 100644 --- a/vortex-tensor/src/scalar_fns/cosine_similarity.rs +++ b/vortex-tensor/src/scalar_fns/cosine_similarity.rs @@ -59,8 +59,8 @@ impl ScalarFnVTable for CosineSimilarity { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::from("lhs"), - 1 => ChildName::from("rhs"), + 0 => ChildName::new("lhs"), + 1 => ChildName::new("rhs"), _ => unreachable!("CosineSimilarity must have exactly two children"), } } diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/bool.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/bool.rs index 6db099173fb..0b289cd4bfd 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/bool.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/bool.rs @@ -25,7 +25,7 @@ impl FlatLayoutFixture for BooleansFixture { } fn expected_encodings(&self) -> Vec { - vec![Bool::ID] + vec![Bool::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/chunked.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/chunked.rs index 47a16771932..6ef8fee3249 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/chunked.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/chunked.rs @@ -26,7 +26,7 @@ impl FlatLayoutFixture for ChunkedFixture { } fn expected_encodings(&self) -> Vec { - vec![Primitive::ID] + vec![Primitive::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/datetime.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/datetime.rs index 30b120a0777..252cbec0e5a 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/datetime.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/datetime.rs @@ -30,7 +30,7 @@ impl FlatLayoutFixture for DateTimeFixture { } fn expected_encodings(&self) -> Vec { - vec![Extension::ID] + vec![Extension::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/decimal.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/decimal.rs index 46081371323..809aa5247ab 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/decimal.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/decimal.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for DecimalFixture { } fn expected_encodings(&self) -> Vec { - vec![Decimal::ID] + vec![Decimal::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/fixed_size_list.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/fixed_size_list.rs index f350beec435..8f90a8f44c7 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/fixed_size_list.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/fixed_size_list.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for FixedSizeListFixture { } fn expected_encodings(&self) -> Vec { - vec![FixedSizeList::ID] + vec![FixedSizeList::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/list.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/list.rs index 81845bb2a86..f79a9533f38 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/list.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/list.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for ListFixture { } fn expected_encodings(&self) -> Vec { - vec![List::ID] + vec![List::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/listview.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/listview.rs index f65abdd6cc4..694db3a438b 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/listview.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/listview.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for ListViewFixture { } fn expected_encodings(&self) -> Vec { - vec![ListView::ID] + vec![ListView::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/null.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/null.rs index 0d991d3e4c9..d1849bb39ed 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/null.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/null.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for NullFixture { } fn expected_encodings(&self) -> Vec { - vec![Null::ID] + vec![Null::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/primitive.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/primitive.rs index d5e3b388586..826bd4407a2 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/primitive.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/primitive.rs @@ -26,7 +26,7 @@ impl FlatLayoutFixture for PrimitivesFixture { } fn expected_encodings(&self) -> Vec { - vec![Primitive::ID] + vec![Primitive::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/struct_nested.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/struct_nested.rs index 546414a49fa..e9e0303dd08 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/struct_nested.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/struct_nested.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for StructNestedFixture { } fn expected_encodings(&self) -> Vec { - vec![Struct::ID] + vec![Struct::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbin.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbin.rs index ad4588ccc62..b14dc5e91ce 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbin.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbin.rs @@ -25,7 +25,7 @@ impl FlatLayoutFixture for VarBinFixture { } fn expected_encodings(&self) -> Vec { - vec![VarBin::ID] + vec![VarBin::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbinview.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbinview.rs index 8555d5eaf74..56560935fca 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbinview.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/arrays/varbinview.rs @@ -25,7 +25,7 @@ impl FlatLayoutFixture for VarBinViewFixture { } fn expected_encodings(&self) -> Vec { - vec![VarBinView::ID] + vec![VarBinView::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alp.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alp.rs index c3eb11c7aae..f9f9ac079a0 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alp.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alp.rs @@ -55,7 +55,7 @@ impl FlatLayoutFixture for AlpFixture { } fn expected_encodings(&self) -> Vec { - vec![ALP::ID] + vec![ALP::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alprd.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alprd.rs index ca310e92ee5..9d1bd7cd33b 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alprd.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/alprd.rs @@ -41,7 +41,7 @@ impl FlatLayoutFixture for AlprdFixture { } fn expected_encodings(&self) -> Vec { - vec![ALPRD::ID] + vec![ALPRD::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bitpacked.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bitpacked.rs index facbab894f7..d24f2ef5cc8 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bitpacked.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bitpacked.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for BitPackedFixture { } fn expected_encodings(&self) -> Vec { - vec![BitPacked::ID] + vec![BitPacked::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bytebool.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bytebool.rs index 14838e13939..0f2f3e4eb27 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bytebool.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/bytebool.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for ByteBoolFixture { } fn expected_encodings(&self) -> Vec { - vec![ByteBool::ID] + vec![ByteBool::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/constant.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/constant.rs index 1b26ac0bb89..794278fe26d 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/constant.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/constant.rs @@ -35,7 +35,7 @@ impl FlatLayoutFixture for ConstantFixture { } fn expected_encodings(&self) -> Vec { - vec![Constant::ID] + vec![Constant::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/datetimeparts.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/datetimeparts.rs index 4ef369badca..276094a2ba9 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/datetimeparts.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/datetimeparts.rs @@ -39,7 +39,7 @@ impl FlatLayoutFixture for DateTimePartsFixture { } fn expected_encodings(&self) -> Vec { - vec![DateTimeParts::ID] + vec![DateTimeParts::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/decimal_byte_parts.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/decimal_byte_parts.rs index 1b0c9ded30c..5e2e5f6fe65 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/decimal_byte_parts.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/decimal_byte_parts.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for DecimalBytePartsFixture { } fn expected_encodings(&self) -> Vec { - vec![DecimalByteParts::ID] + vec![DecimalByteParts::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/delta.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/delta.rs index 8b268a08456..d10a98fe87c 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/delta.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/delta.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for DeltaFixture { } fn expected_encodings(&self) -> Vec { - vec![Delta::ID] + vec![Delta::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/dict.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/dict.rs index 80cb794a418..adbad42f785 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/dict.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/dict.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for DictFixture { } fn expected_encodings(&self) -> Vec { - vec![Dict::ID] + vec![Dict::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/for_.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/for_.rs index 60054dc4948..3522411bca3 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/for_.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/for_.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for FoRFixture { } fn expected_encodings(&self) -> Vec { - vec![FoR::ID] + vec![FoR::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/fsst.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/fsst.rs index ad1706e629d..7b740742c80 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/fsst.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/fsst.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for FsstFixture { } fn expected_encodings(&self) -> Vec { - vec![FSST::ID] + vec![FSST::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/pco.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/pco.rs index 8a29c7dd161..89f151fd849 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/pco.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/pco.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for PcoFixture { } fn expected_encodings(&self) -> Vec { - vec![Pco::ID] + vec![Pco::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/rle.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/rle.rs index d635aea5d2b..3a16832e77c 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/rle.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/rle.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for RleFixture { } fn expected_encodings(&self) -> Vec { - vec![RLE::ID] + vec![RLE::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/runend.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/runend.rs index be74b072edf..d5e5b06fb69 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/runend.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/runend.rs @@ -30,7 +30,7 @@ impl FlatLayoutFixture for RunEndFixture { } fn expected_encodings(&self) -> Vec { - vec![RunEnd::ID] + vec![RunEnd::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sequence.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sequence.rs index 493cb9d4365..08dde13a550 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sequence.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sequence.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for SequenceFixture { } fn expected_encodings(&self) -> Vec { - vec![Sequence::ID] + vec![Sequence::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sparse.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sparse.rs index 360f15345ce..70e55d71ba6 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sparse.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/sparse.rs @@ -32,7 +32,7 @@ impl FlatLayoutFixture for SparseFixture { } fn expected_encodings(&self) -> Vec { - vec![Sparse::ID] + vec![Sparse::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zigzag.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zigzag.rs index 4c14b3a2d30..1e423c679e7 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zigzag.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zigzag.rs @@ -27,7 +27,7 @@ impl FlatLayoutFixture for ZigZagFixture { } fn expected_encodings(&self) -> Vec { - vec![ZigZag::ID] + vec![ZigZag::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zstd.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zstd.rs index 4546c9f6dbd..ae0bf5c4269 100644 --- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zstd.rs +++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/zstd.rs @@ -28,7 +28,7 @@ impl FlatLayoutFixture for ZstdFixture { } fn expected_encodings(&self) -> Vec { - vec![Zstd::ID] + vec![Zstd::array_id()] } fn build(&self) -> VortexResult { diff --git a/vortex-utils/src/id.rs b/vortex-utils/src/id.rs deleted file mode 100644 index 710959f62c3..00000000000 --- a/vortex-utils/src/id.rs +++ /dev/null @@ -1,110 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -//! A lightweight interned identifier type backed by `&'static str`. - -use std::cmp::Ordering; -use std::fmt; -use std::fmt::Debug; -use std::fmt::Display; -use std::fmt::Formatter; - -/// A lightweight, copyable identifier backed by a `&'static str`. -/// -/// Used for array encoding IDs, scalar function IDs, layout IDs, and similar -/// globally-unique string identifiers throughout Vortex. -#[derive(Clone, Copy, PartialEq, Eq, Hash)] -pub struct Id(&'static str); - -impl Id { - /// Create a new `Id` from a static string. - pub const fn new(s: &'static str) -> Self { - Self(s) - } - - /// Returns the underlying string. - pub const fn as_str(&self) -> &'static str { - self.0 - } -} - -impl Display for Id { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str(self.0) - } -} - -impl Debug for Id { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "Id(\"{}\")", self.0) - } -} - -impl PartialOrd for Id { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for Id { - fn cmp(&self, other: &Self) -> Ordering { - self.0.cmp(other.0) - } -} - -impl PartialEq for Id { - fn eq(&self, other: &str) -> bool { - self.0 == other - } -} - -impl AsRef for Id { - fn as_ref(&self) -> &str { - self.0 - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_id_equality() { - let a = Id::new("vortex.primitive"); - let b = Id::new("vortex.primitive"); - let c = Id::new("vortex.bool"); - assert_eq!(a, b); - assert_ne!(a, c); - } - - #[test] - fn test_id_display() { - let id = Id::new("vortex.primitive"); - assert_eq!(format!("{id}"), "vortex.primitive"); - } - - #[test] - fn test_id_debug() { - let id = Id::new("vortex.primitive"); - assert_eq!(format!("{id:?}"), "Id(\"vortex.primitive\")"); - } - - #[test] - fn test_id_partial_eq_str() { - let id = Id::new("vortex.primitive"); - assert_eq!(id, *"vortex.primitive"); - } - - #[test] - fn test_id_ord() { - let a = Id::new("aaa"); - let b = Id::new("bbb"); - assert!(a < b); - } - - #[test] - fn test_id_const() { - const MY_ID: Id = Id::new("test"); - assert_eq!(MY_ID.as_str(), "test"); - } -} From 6275b76e71e2d5ac8ec636ea9936d6acec13c44e Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 09:55:28 -0700 Subject: [PATCH 4/6] Interned Identifiers Signed-off-by: Nicholas Gates --- vortex-array/public-api.lock | 2 +- vortex-array/src/dtype/extension/mod.rs | 3 ++- vortex-array/src/scalar_fn/fns/between/mod.rs | 6 +++--- vortex-array/src/scalar_fn/fns/binary/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/case_when.rs | 7 ++++--- vortex-array/src/scalar_fn/fns/cast/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/dynamic.rs | 2 +- vortex-array/src/scalar_fn/fns/fill_null/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/get_item.rs | 2 +- vortex-array/src/scalar_fn/fns/is_null.rs | 2 +- vortex-array/src/scalar_fn/fns/like/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/list_contains/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/mask/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/merge.rs | 3 ++- vortex-array/src/scalar_fn/fns/not/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/pack.rs | 2 +- vortex-array/src/scalar_fn/fns/select.rs | 2 +- vortex-array/src/scalar_fn/fns/zip/mod.rs | 6 +++--- vortex-array/src/scalar_fn/vtable.rs | 3 ++- vortex-tensor/src/scalar_fns/cosine_similarity.rs | 4 ++-- 20 files changed, 36 insertions(+), 32 deletions(-) diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index d3b658aea01..9091a56b687 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -19460,7 +19460,7 @@ pub trait vortex_array::scalar_fn::SimplifyCtx pub fn vortex_array::scalar_fn::SimplifyCtx::return_dtype(&self, expr: &vortex_array::expr::Expression) -> vortex_error::VortexResult -pub type vortex_array::scalar_fn::ChildName = vortex_session::registry::Id +pub type vortex_array::scalar_fn::ChildName = arcref::ArcRef pub type vortex_array::scalar_fn::ReduceNodeRef = alloc::sync::Arc diff --git a/vortex-array/src/dtype/extension/mod.rs b/vortex-array/src/dtype/extension/mod.rs index e1c617e9490..54dc224606c 100644 --- a/vortex-array/src/dtype/extension/mod.rs +++ b/vortex-array/src/dtype/extension/mod.rs @@ -27,9 +27,10 @@ pub use erased::*; mod matcher; pub use matcher::*; +use vortex_session::registry::Id; /// A unique identifier for an extension type -pub type ExtId = vortex_session::registry::Id; +pub type ExtId = Id; /// Private module to seal [`typed::DynExtDType`]. mod sealed { diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index 4aff0f5622e..0f95fc19ab0 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -233,9 +233,9 @@ impl ScalarFnVTable for Between { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("array"), - 1 => ChildName::new("lower"), - 2 => ChildName::new("upper"), + 0 => ChildName::new_ref("array"), + 1 => ChildName::new_ref("lower"), + 2 => ChildName::new_ref("upper"), _ => unreachable!("Invalid child index {} for Between expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/binary/mod.rs b/vortex-array/src/scalar_fn/fns/binary/mod.rs index fd58d2a8ff2..37107d7683a 100644 --- a/vortex-array/src/scalar_fn/fns/binary/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/mod.rs @@ -79,8 +79,8 @@ impl ScalarFnVTable for Binary { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("lhs"), - 1 => ChildName::new("rhs"), + 0 => ChildName::new_ref("lhs"), + 1 => ChildName::new_ref("rhs"), _ => unreachable!("Binary has only two children"), } } diff --git a/vortex-array/src/scalar_fn/fns/case_when.rs b/vortex-array/src/scalar_fn/fns/case_when.rs index a8ca1a6ef4d..57c97b4ca3e 100644 --- a/vortex-array/src/scalar_fn/fns/case_when.rs +++ b/vortex-array/src/scalar_fn/fns/case_when.rs @@ -13,6 +13,7 @@ use std::fmt; use std::fmt::Formatter; use std::hash::Hash; +use std::sync::Arc; use prost::Message; use vortex_error::VortexResult; @@ -114,12 +115,12 @@ impl ScalarFnVTable for CaseWhen { if child_idx < num_pair_children { let pair_idx = child_idx / 2; if child_idx.is_multiple_of(2) { - ChildName::new(&format!("when_{pair_idx}")) + ChildName::from(Arc::from(format!("when_{pair_idx}").as_str())) } else { - ChildName::new(&format!("then_{pair_idx}")) + ChildName::from(Arc::from(format!("then_{pair_idx}").as_str())) } } else if options.has_else && child_idx == num_pair_children { - ChildName::new("else") + ChildName::new_ref("else") } else { unreachable!("Invalid child index {} for CaseWhen", child_idx) } diff --git a/vortex-array/src/scalar_fn/fns/cast/mod.rs b/vortex-array/src/scalar_fn/fns/cast/mod.rs index e5571380884..2490a1b9b24 100644 --- a/vortex-array/src/scalar_fn/fns/cast/mod.rs +++ b/vortex-array/src/scalar_fn/fns/cast/mod.rs @@ -85,7 +85,7 @@ impl ScalarFnVTable for Cast { fn child_name(&self, _instance: &DType, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), + 0 => ChildName::new_ref("input"), _ => unreachable!("Invalid child index {} for Cast expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/dynamic.rs b/vortex-array/src/scalar_fn/fns/dynamic.rs index ee13add8bd7..98fe010efad 100644 --- a/vortex-array/src/scalar_fn/fns/dynamic.rs +++ b/vortex-array/src/scalar_fn/fns/dynamic.rs @@ -56,7 +56,7 @@ impl ScalarFnVTable for DynamicComparison { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("lhs"), + 0 => ChildName::new_ref("lhs"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs index bf10ee30701..29c151f974b 100644 --- a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs +++ b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs @@ -60,8 +60,8 @@ impl ScalarFnVTable for FillNull { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), - 1 => ChildName::new("fill_value"), + 0 => ChildName::new_ref("input"), + 1 => ChildName::new_ref("fill_value"), _ => unreachable!("Invalid child index {} for FillNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/get_item.rs b/vortex-array/src/scalar_fn/fns/get_item.rs index f060c14e13d..42b79028f4b 100644 --- a/vortex-array/src/scalar_fn/fns/get_item.rs +++ b/vortex-array/src/scalar_fn/fns/get_item.rs @@ -70,7 +70,7 @@ impl ScalarFnVTable for GetItem { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), + 0 => ChildName::new_ref("input"), _ => unreachable!("Invalid child index {} for GetItem expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/is_null.rs b/vortex-array/src/scalar_fn/fns/is_null.rs index 00f4b123eed..8f8b9e62549 100644 --- a/vortex-array/src/scalar_fn/fns/is_null.rs +++ b/vortex-array/src/scalar_fn/fns/is_null.rs @@ -55,7 +55,7 @@ impl ScalarFnVTable for IsNull { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), + 0 => ChildName::new_ref("input"), _ => unreachable!("Invalid child index {} for IsNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/like/mod.rs b/vortex-array/src/scalar_fn/fns/like/mod.rs index 4ced1b417a2..f8496f1d445 100644 --- a/vortex-array/src/scalar_fn/fns/like/mod.rs +++ b/vortex-array/src/scalar_fn/fns/like/mod.rs @@ -94,8 +94,8 @@ impl ScalarFnVTable for Like { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("child"), - 1 => ChildName::new("pattern"), + 0 => ChildName::new_ref("child"), + 1 => ChildName::new_ref("pattern"), _ => unreachable!("Invalid child index {} for Like expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs index 91286450674..3490e1ae01a 100644 --- a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs +++ b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs @@ -81,8 +81,8 @@ impl ScalarFnVTable for ListContains { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("list"), - 1 => ChildName::new("needle"), + 0 => ChildName::new_ref("list"), + 1 => ChildName::new_ref("needle"), _ => unreachable!( "Invalid child index {} for ListContains expression", child_idx diff --git a/vortex-array/src/scalar_fn/fns/mask/mod.rs b/vortex-array/src/scalar_fn/fns/mask/mod.rs index b96c778b66d..de84d2e5abf 100644 --- a/vortex-array/src/scalar_fn/fns/mask/mod.rs +++ b/vortex-array/src/scalar_fn/fns/mask/mod.rs @@ -66,8 +66,8 @@ impl ScalarFnVTable for Mask { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), - 1 => ChildName::new("mask"), + 0 => ChildName::new_ref("input"), + 1 => ChildName::new_ref("mask"), _ => unreachable!("Invalid child index {} for Mask expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/merge.rs b/vortex-array/src/scalar_fn/fns/merge.rs index b00d92a959d..6e128771135 100644 --- a/vortex-array/src/scalar_fn/fns/merge.rs +++ b/vortex-array/src/scalar_fn/fns/merge.rs @@ -4,6 +4,7 @@ use std::fmt::Display; use std::fmt::Formatter; use std::hash::Hash; +use std::sync::Arc; use itertools::Itertools as _; use vortex_error::VortexExpect; @@ -79,7 +80,7 @@ impl ScalarFnVTable for Merge { } fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { - ChildName::new(&format!("{child_idx}")) + ChildName::from(Arc::from(format!("{child_idx}").as_str())) } fn fmt_sql( diff --git a/vortex-array/src/scalar_fn/fns/not/mod.rs b/vortex-array/src/scalar_fn/fns/not/mod.rs index eee6093d1df..f4cfaeaf120 100644 --- a/vortex-array/src/scalar_fn/fns/not/mod.rs +++ b/vortex-array/src/scalar_fn/fns/not/mod.rs @@ -57,7 +57,7 @@ impl ScalarFnVTable for Not { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("input"), + 0 => ChildName::new_ref("input"), _ => unreachable!("Invalid child index {} for Not expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/pack.rs b/vortex-array/src/scalar_fn/fns/pack.rs index 403724d478e..1c5308dcc02 100644 --- a/vortex-array/src/scalar_fn/fns/pack.rs +++ b/vortex-array/src/scalar_fn/fns/pack.rs @@ -90,7 +90,7 @@ impl ScalarFnVTable for Pack { fn child_name(&self, instance: &Self::Options, child_idx: usize) -> ChildName { match instance.names.get(child_idx) { - Some(name) => ChildName::new(name.inner()), + Some(name) => ChildName::new_arc(name.inner().clone()), None => unreachable!( "Invalid child index {} for Pack expression with {} fields", child_idx, diff --git a/vortex-array/src/scalar_fn/fns/select.rs b/vortex-array/src/scalar_fn/fns/select.rs index 5967012e97c..677307ac842 100644 --- a/vortex-array/src/scalar_fn/fns/select.rs +++ b/vortex-array/src/scalar_fn/fns/select.rs @@ -93,7 +93,7 @@ impl ScalarFnVTable for Select { fn child_name(&self, _instance: &FieldSelection, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("child"), + 0 => ChildName::new_ref("child"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/fns/zip/mod.rs b/vortex-array/src/scalar_fn/fns/zip/mod.rs index 44e4e4fcc68..183cc8b6a52 100644 --- a/vortex-array/src/scalar_fn/fns/zip/mod.rs +++ b/vortex-array/src/scalar_fn/fns/zip/mod.rs @@ -67,9 +67,9 @@ impl ScalarFnVTable for Zip { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("if_true"), - 1 => ChildName::new("if_false"), - 2 => ChildName::new("mask"), + 0 => ChildName::new_ref("if_true"), + 1 => ChildName::new_ref("if_false"), + 2 => ChildName::new_ref("mask"), _ => unreachable!("Invalid child index {} for Zip expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/vtable.rs b/vortex-array/src/scalar_fn/vtable.rs index 858e5d8c071..c9588e8aa13 100644 --- a/vortex-array/src/scalar_fn/vtable.rs +++ b/vortex-array/src/scalar_fn/vtable.rs @@ -9,6 +9,7 @@ use std::fmt::Formatter; use std::hash::Hash; use std::sync::Arc; +use arcref::ArcRef; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; @@ -411,4 +412,4 @@ pub trait ScalarFnVTableExt: ScalarFnVTable { impl ScalarFnVTableExt for V {} /// A reference to the name of a child expression. -pub type ChildName = vortex_session::registry::Id; +pub type ChildName = ArcRef; diff --git a/vortex-tensor/src/scalar_fns/cosine_similarity.rs b/vortex-tensor/src/scalar_fns/cosine_similarity.rs index ef56d101abc..c19cc8a1072 100644 --- a/vortex-tensor/src/scalar_fns/cosine_similarity.rs +++ b/vortex-tensor/src/scalar_fns/cosine_similarity.rs @@ -59,8 +59,8 @@ impl ScalarFnVTable for CosineSimilarity { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new("lhs"), - 1 => ChildName::new("rhs"), + 0 => ChildName::new_ref("lhs"), + 1 => ChildName::new_ref("rhs"), _ => unreachable!("CosineSimilarity must have exactly two children"), } } From d952863dcb94e5f0de3c0cc58c09cf889769d1d8 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 10:00:21 -0700 Subject: [PATCH 5/6] Interned Identifiers Signed-off-by: Nicholas Gates --- vortex-array/src/scalar_fn/fns/between/mod.rs | 6 +++--- vortex-array/src/scalar_fn/fns/binary/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/case_when.rs | 6 +++--- vortex-array/src/scalar_fn/fns/cast/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/dynamic.rs | 2 +- vortex-array/src/scalar_fn/fns/fill_null/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/get_item.rs | 2 +- vortex-array/src/scalar_fn/fns/is_null.rs | 2 +- vortex-array/src/scalar_fn/fns/like/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/list_contains/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/mask/mod.rs | 4 ++-- vortex-array/src/scalar_fn/fns/merge.rs | 2 +- vortex-array/src/scalar_fn/fns/not/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/pack.rs | 2 +- vortex-array/src/scalar_fn/fns/select.rs | 2 +- vortex-array/src/scalar_fn/fns/zip/mod.rs | 6 +++--- vortex-tensor/src/scalar_fns/cosine_similarity.rs | 4 ++-- 17 files changed, 29 insertions(+), 29 deletions(-) diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index 0f95fc19ab0..84d5881a536 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -233,9 +233,9 @@ impl ScalarFnVTable for Between { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("array"), - 1 => ChildName::new_ref("lower"), - 2 => ChildName::new_ref("upper"), + 0 => ChildName::from("array"), + 1 => ChildName::from("lower"), + 2 => ChildName::from("upper"), _ => unreachable!("Invalid child index {} for Between expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/binary/mod.rs b/vortex-array/src/scalar_fn/fns/binary/mod.rs index 37107d7683a..1dce67e6679 100644 --- a/vortex-array/src/scalar_fn/fns/binary/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/mod.rs @@ -79,8 +79,8 @@ impl ScalarFnVTable for Binary { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("lhs"), - 1 => ChildName::new_ref("rhs"), + 0 => ChildName::from("lhs"), + 1 => ChildName::from("rhs"), _ => unreachable!("Binary has only two children"), } } diff --git a/vortex-array/src/scalar_fn/fns/case_when.rs b/vortex-array/src/scalar_fn/fns/case_when.rs index 57c97b4ca3e..12630085f18 100644 --- a/vortex-array/src/scalar_fn/fns/case_when.rs +++ b/vortex-array/src/scalar_fn/fns/case_when.rs @@ -115,12 +115,12 @@ impl ScalarFnVTable for CaseWhen { if child_idx < num_pair_children { let pair_idx = child_idx / 2; if child_idx.is_multiple_of(2) { - ChildName::from(Arc::from(format!("when_{pair_idx}").as_str())) + ChildName::from(Arc::from(format!("when_{pair_idx}"))) } else { - ChildName::from(Arc::from(format!("then_{pair_idx}").as_str())) + ChildName::from(Arc::from(format!("then_{pair_idx}"))) } } else if options.has_else && child_idx == num_pair_children { - ChildName::new_ref("else") + ChildName::from("else") } else { unreachable!("Invalid child index {} for CaseWhen", child_idx) } diff --git a/vortex-array/src/scalar_fn/fns/cast/mod.rs b/vortex-array/src/scalar_fn/fns/cast/mod.rs index 2490a1b9b24..926832a32e0 100644 --- a/vortex-array/src/scalar_fn/fns/cast/mod.rs +++ b/vortex-array/src/scalar_fn/fns/cast/mod.rs @@ -85,7 +85,7 @@ impl ScalarFnVTable for Cast { fn child_name(&self, _instance: &DType, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), + 0 => ChildName::from("input"), _ => unreachable!("Invalid child index {} for Cast expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/dynamic.rs b/vortex-array/src/scalar_fn/fns/dynamic.rs index 98fe010efad..0fa0afadaf9 100644 --- a/vortex-array/src/scalar_fn/fns/dynamic.rs +++ b/vortex-array/src/scalar_fn/fns/dynamic.rs @@ -56,7 +56,7 @@ impl ScalarFnVTable for DynamicComparison { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("lhs"), + 0 => ChildName::from("lhs"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs index 29c151f974b..cc6e0be09fd 100644 --- a/vortex-array/src/scalar_fn/fns/fill_null/mod.rs +++ b/vortex-array/src/scalar_fn/fns/fill_null/mod.rs @@ -60,8 +60,8 @@ impl ScalarFnVTable for FillNull { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), - 1 => ChildName::new_ref("fill_value"), + 0 => ChildName::from("input"), + 1 => ChildName::from("fill_value"), _ => unreachable!("Invalid child index {} for FillNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/get_item.rs b/vortex-array/src/scalar_fn/fns/get_item.rs index 42b79028f4b..8cd155fae48 100644 --- a/vortex-array/src/scalar_fn/fns/get_item.rs +++ b/vortex-array/src/scalar_fn/fns/get_item.rs @@ -70,7 +70,7 @@ impl ScalarFnVTable for GetItem { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), + 0 => ChildName::from("input"), _ => unreachable!("Invalid child index {} for GetItem expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/is_null.rs b/vortex-array/src/scalar_fn/fns/is_null.rs index 8f8b9e62549..4724f210ce2 100644 --- a/vortex-array/src/scalar_fn/fns/is_null.rs +++ b/vortex-array/src/scalar_fn/fns/is_null.rs @@ -55,7 +55,7 @@ impl ScalarFnVTable for IsNull { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), + 0 => ChildName::from("input"), _ => unreachable!("Invalid child index {} for IsNull expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/like/mod.rs b/vortex-array/src/scalar_fn/fns/like/mod.rs index f8496f1d445..2bdfca87cc4 100644 --- a/vortex-array/src/scalar_fn/fns/like/mod.rs +++ b/vortex-array/src/scalar_fn/fns/like/mod.rs @@ -94,8 +94,8 @@ impl ScalarFnVTable for Like { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("child"), - 1 => ChildName::new_ref("pattern"), + 0 => ChildName::from("child"), + 1 => ChildName::from("pattern"), _ => unreachable!("Invalid child index {} for Like expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs index 3490e1ae01a..a9c2d743ba0 100644 --- a/vortex-array/src/scalar_fn/fns/list_contains/mod.rs +++ b/vortex-array/src/scalar_fn/fns/list_contains/mod.rs @@ -81,8 +81,8 @@ impl ScalarFnVTable for ListContains { fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("list"), - 1 => ChildName::new_ref("needle"), + 0 => ChildName::from("list"), + 1 => ChildName::from("needle"), _ => unreachable!( "Invalid child index {} for ListContains expression", child_idx diff --git a/vortex-array/src/scalar_fn/fns/mask/mod.rs b/vortex-array/src/scalar_fn/fns/mask/mod.rs index de84d2e5abf..92cf758b7dc 100644 --- a/vortex-array/src/scalar_fn/fns/mask/mod.rs +++ b/vortex-array/src/scalar_fn/fns/mask/mod.rs @@ -66,8 +66,8 @@ impl ScalarFnVTable for Mask { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), - 1 => ChildName::new_ref("mask"), + 0 => ChildName::from("input"), + 1 => ChildName::from("mask"), _ => unreachable!("Invalid child index {} for Mask expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/merge.rs b/vortex-array/src/scalar_fn/fns/merge.rs index 6e128771135..b74753bbc0b 100644 --- a/vortex-array/src/scalar_fn/fns/merge.rs +++ b/vortex-array/src/scalar_fn/fns/merge.rs @@ -80,7 +80,7 @@ impl ScalarFnVTable for Merge { } fn child_name(&self, _instance: &Self::Options, child_idx: usize) -> ChildName { - ChildName::from(Arc::from(format!("{child_idx}").as_str())) + ChildName::from(Arc::from(format!("{}", child_idx))) } fn fmt_sql( diff --git a/vortex-array/src/scalar_fn/fns/not/mod.rs b/vortex-array/src/scalar_fn/fns/not/mod.rs index f4cfaeaf120..9bd842cfae4 100644 --- a/vortex-array/src/scalar_fn/fns/not/mod.rs +++ b/vortex-array/src/scalar_fn/fns/not/mod.rs @@ -57,7 +57,7 @@ impl ScalarFnVTable for Not { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("input"), + 0 => ChildName::from("input"), _ => unreachable!("Invalid child index {} for Not expression", child_idx), } } diff --git a/vortex-array/src/scalar_fn/fns/pack.rs b/vortex-array/src/scalar_fn/fns/pack.rs index 1c5308dcc02..a6d779d5d0b 100644 --- a/vortex-array/src/scalar_fn/fns/pack.rs +++ b/vortex-array/src/scalar_fn/fns/pack.rs @@ -90,7 +90,7 @@ impl ScalarFnVTable for Pack { fn child_name(&self, instance: &Self::Options, child_idx: usize) -> ChildName { match instance.names.get(child_idx) { - Some(name) => ChildName::new_arc(name.inner().clone()), + Some(name) => ChildName::from(name.inner().clone()), None => unreachable!( "Invalid child index {} for Pack expression with {} fields", child_idx, diff --git a/vortex-array/src/scalar_fn/fns/select.rs b/vortex-array/src/scalar_fn/fns/select.rs index 677307ac842..74f3c787c3f 100644 --- a/vortex-array/src/scalar_fn/fns/select.rs +++ b/vortex-array/src/scalar_fn/fns/select.rs @@ -93,7 +93,7 @@ impl ScalarFnVTable for Select { fn child_name(&self, _instance: &FieldSelection, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("child"), + 0 => ChildName::from("child"), _ => unreachable!(), } } diff --git a/vortex-array/src/scalar_fn/fns/zip/mod.rs b/vortex-array/src/scalar_fn/fns/zip/mod.rs index 183cc8b6a52..89f894e933c 100644 --- a/vortex-array/src/scalar_fn/fns/zip/mod.rs +++ b/vortex-array/src/scalar_fn/fns/zip/mod.rs @@ -67,9 +67,9 @@ impl ScalarFnVTable for Zip { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("if_true"), - 1 => ChildName::new_ref("if_false"), - 2 => ChildName::new_ref("mask"), + 0 => ChildName::from("if_true"), + 1 => ChildName::from("if_false"), + 2 => ChildName::from("mask"), _ => unreachable!("Invalid child index {} for Zip expression", child_idx), } } diff --git a/vortex-tensor/src/scalar_fns/cosine_similarity.rs b/vortex-tensor/src/scalar_fns/cosine_similarity.rs index c19cc8a1072..63ae16da8b5 100644 --- a/vortex-tensor/src/scalar_fns/cosine_similarity.rs +++ b/vortex-tensor/src/scalar_fns/cosine_similarity.rs @@ -59,8 +59,8 @@ impl ScalarFnVTable for CosineSimilarity { fn child_name(&self, _options: &Self::Options, child_idx: usize) -> ChildName { match child_idx { - 0 => ChildName::new_ref("lhs"), - 1 => ChildName::new_ref("rhs"), + 0 => ChildName::from("lhs"), + 1 => ChildName::from("rhs"), _ => unreachable!("CosineSimilarity must have exactly two children"), } } From 2232ae592d22d07833fe1f4ef793d2b2a7d326fc Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Thu, 19 Mar 2026 10:28:03 -0700 Subject: [PATCH 6/6] Interned Identifiers Signed-off-by: Nicholas Gates --- vortex-array/public-api.lock | 8 ++++++-- vortex-array/src/arrays/variant/vtable/mod.rs | 10 ++++++++-- vortex-tensor/src/scalar_fns/l2_norm.rs | 2 +- vortex-tensor/src/vector/vtable.rs | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index 4c767e28daf..d78ce555f49 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -4862,7 +4862,9 @@ pub struct vortex_array::arrays::variant::Variant impl vortex_array::arrays::Variant -pub const vortex_array::arrays::Variant::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Variant::ID: &'static str + +pub fn vortex_array::arrays::Variant::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Variant @@ -8038,7 +8040,9 @@ pub struct vortex_array::arrays::Variant impl vortex_array::arrays::Variant -pub const vortex_array::arrays::Variant::ID: vortex_array::vtable::ArrayId +pub const vortex_array::arrays::Variant::ID: &'static str + +pub fn vortex_array::arrays::Variant::array_id() -> vortex_array::vtable::ArrayId impl core::fmt::Debug for vortex_array::arrays::Variant diff --git a/vortex-array/src/arrays/variant/vtable/mod.rs b/vortex-array/src/arrays/variant/vtable/mod.rs index 71ae0665212..5e223a5e751 100644 --- a/vortex-array/src/arrays/variant/vtable/mod.rs +++ b/vortex-array/src/arrays/variant/vtable/mod.rs @@ -34,7 +34,13 @@ vtable!(Variant); pub struct Variant; impl Variant { - pub const ID: ArrayId = ArrayId::new_ref("vortex.variant"); + pub const ID: &'static str = "vortex.variant"; + + /// Returns the cached [`ArrayId`] for this encoding. + pub fn array_id() -> ArrayId { + static CACHED: std::sync::OnceLock = std::sync::OnceLock::new(); + *CACHED.get_or_init(|| ArrayId::new(Self::ID)) + } } impl VTable for Variant { @@ -47,7 +53,7 @@ impl VTable for Variant { type ValidityVTable = Self; fn id(_array: &Self::Array) -> ArrayId { - Self::ID + Self::array_id() } fn len(array: &Self::Array) -> usize { diff --git a/vortex-tensor/src/scalar_fns/l2_norm.rs b/vortex-tensor/src/scalar_fns/l2_norm.rs index e0a3bac4143..53c0d3a8a6f 100644 --- a/vortex-tensor/src/scalar_fns/l2_norm.rs +++ b/vortex-tensor/src/scalar_fns/l2_norm.rs @@ -46,7 +46,7 @@ impl ScalarFnVTable for L2Norm { type Options = EmptyOptions; fn id(&self) -> ScalarFnId { - ScalarFnId::new_ref("vortex.tensor.l2_norm") + ScalarFnId::new("vortex.tensor.l2_norm") } fn arity(&self, _options: &Self::Options) -> Arity { diff --git a/vortex-tensor/src/vector/vtable.rs b/vortex-tensor/src/vector/vtable.rs index 6ab849ab4e9..e10282fa9a5 100644 --- a/vortex-tensor/src/vector/vtable.rs +++ b/vortex-tensor/src/vector/vtable.rs @@ -20,7 +20,7 @@ impl ExtVTable for Vector { type NativeValue<'a> = &'a ScalarValue; fn id(&self) -> ExtId { - ExtId::new_ref("vortex.tensor.vector") + ExtId::new("vortex.tensor.vector") } fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> {