diff --git a/pyvortex/src/array.rs b/pyvortex/src/array.rs index bd35b64e36..c99c88ea17 100644 --- a/pyvortex/src/array.rs +++ b/pyvortex/src/array.rs @@ -26,15 +26,13 @@ use vortex::array::typed::TypedArray; use vortex::array::varbin::VarBinArray; use vortex::array::varbinview::VarBinViewArray; use vortex::array::{Array, ArrayKind, ArrayRef}; -use vortex_alp::{ALPArray, ALP_ENCODING}; -use vortex_dict::{DictArray, DICT_ENCODING}; -use vortex_fastlanes::{BitPackedArray, FoRArray, FL_BITPACKED_ENCODING, FL_FOR_ENCODING}; -use vortex_ffor::{FFORArray, FFOR_ENCODING}; -use vortex_ree::{REEArray, REE_ENCODING}; -use vortex_roaring::{ - RoaringBoolArray, RoaringIntArray, ROARING_BOOL_ENCODING, ROARING_INT_ENCODING, -}; -use vortex_zigzag::{ZigZagArray, ZIGZAG_ENCODING}; +use vortex_alp::{ALPArray, ALPEncoding}; +use vortex_dict::{DictArray, DictEncoding}; +use vortex_fastlanes::{BitPackedArray, BitPackedEncoding, FoRArray, FoREncoding}; +use vortex_ffor::{FFORArray, FFoREncoding}; +use vortex_ree::{REEArray, REEEncoding}; +use vortex_roaring::{RoaringBoolArray, RoaringBoolEncoding, RoaringIntArray, RoaringIntEncoding}; +use vortex_zigzag::{ZigZagArray, ZigZagEncoding}; use crate::dtype::PyDType; use crate::error::PyVortexError; @@ -132,42 +130,42 @@ impl PyArray { ArrayKind::Other(other) => match *other.encoding().id() { // PyEnc chooses to expose certain encodings as first-class objects. // For the remainder, we should have a generic EncArray implementation that supports basic functions. - ALP_ENCODING => { + ALPEncoding::ID => { PyALPArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } - DICT_ENCODING => { + DictEncoding::ID => { PyDictArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } - FL_FOR_ENCODING => { + FoREncoding::ID => { PyFoRArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } - FL_BITPACKED_ENCODING => PyBitPackedArray::wrap( + BitPackedEncoding::ID => PyBitPackedArray::wrap( py, inner.into_any().downcast::().unwrap(), )? .extract(py), - FFOR_ENCODING => { + FFoREncoding::ID => { PyFFORArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } - REE_ENCODING => { + REEEncoding::ID => { PyREEArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } - ROARING_BOOL_ENCODING => PyRoaringBoolArray::wrap( + RoaringBoolEncoding::ID => PyRoaringBoolArray::wrap( py, inner.into_any().downcast::().unwrap(), )? .extract(py), - ROARING_INT_ENCODING => PyRoaringIntArray::wrap( + RoaringIntEncoding::ID => PyRoaringIntArray::wrap( py, inner.into_any().downcast::().unwrap(), )? .extract(py), - ZIGZAG_ENCODING => { + ZigZagEncoding::ID => { PyZigZagArray::wrap(py, inner.into_any().downcast::().unwrap())? .extract(py) } diff --git a/vortex-alp/src/alp.rs b/vortex-alp/src/alp.rs index 3a787bbc99..0ad42dc838 100644 --- a/vortex-alp/src/alp.rs +++ b/vortex-alp/src/alp.rs @@ -199,11 +199,13 @@ impl ArrayDisplay for ALPArray { #[derive(Debug)] pub struct ALPEncoding; -pub const ALP_ENCODING: EncodingId = EncodingId::new("vortex.alp"); +impl ALPEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.alp"); +} impl Encoding for ALPEncoding { fn id(&self) -> &EncodingId { - &ALP_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-dict/src/dict.rs b/vortex-dict/src/dict.rs index 95488fffe9..0b78b6d7c6 100644 --- a/vortex-dict/src/dict.rs +++ b/vortex-dict/src/dict.rs @@ -136,11 +136,13 @@ impl ArrayDisplay for DictArray { #[derive(Debug)] pub struct DictEncoding; -pub const DICT_ENCODING: EncodingId = EncodingId::new("vortex.dict"); +impl DictEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.dict"); +} impl Encoding for DictEncoding { fn id(&self) -> &EncodingId { - &DICT_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-fastlanes/src/bitpacking/mod.rs b/vortex-fastlanes/src/bitpacking/mod.rs index f94dabc26c..19ffaf4e3d 100644 --- a/vortex-fastlanes/src/bitpacking/mod.rs +++ b/vortex-fastlanes/src/bitpacking/mod.rs @@ -197,11 +197,13 @@ impl StatsCompute for BitPackedArray { #[derive(Debug)] pub struct BitPackedEncoding; -pub const FL_BITPACKED_ENCODING: EncodingId = EncodingId::new("fastlanes.bitpacked"); +impl BitPackedEncoding { + pub const ID: EncodingId = EncodingId::new("fastlanes.bitpacked"); +} impl Encoding for BitPackedEncoding { fn id(&self) -> &EncodingId { - &FL_BITPACKED_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-fastlanes/src/for/mod.rs b/vortex-fastlanes/src/for/mod.rs index 05aa2dee80..efe834f35c 100644 --- a/vortex-fastlanes/src/for/mod.rs +++ b/vortex-fastlanes/src/for/mod.rs @@ -147,11 +147,13 @@ impl StatsCompute for FoRArray { #[derive(Debug)] pub struct FoREncoding; -pub const FL_FOR_ENCODING: EncodingId = EncodingId::new("fastlanes.for"); +impl FoREncoding { + pub const ID: EncodingId = EncodingId::new("fastlanes.for"); +} impl Encoding for FoREncoding { fn id(&self) -> &EncodingId { - &FL_FOR_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-ffor/src/ffor.rs b/vortex-ffor/src/ffor.rs index aefd96c47c..6afc7b5c05 100644 --- a/vortex-ffor/src/ffor.rs +++ b/vortex-ffor/src/ffor.rs @@ -242,11 +242,13 @@ impl ArrayDisplay for FFORArray { #[derive(Debug)] pub struct FFoREncoding; -pub const FFOR_ENCODING: EncodingId = EncodingId::new("vortex.ffor"); +impl FFoREncoding { + pub const ID: EncodingId = EncodingId::new("vortex.ffor"); +} impl Encoding for FFoREncoding { fn id(&self) -> &EncodingId { - &FFOR_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-ree/src/compress.rs b/vortex-ree/src/compress.rs index aa352e9d7f..c54d720342 100644 --- a/vortex-ree/src/compress.rs +++ b/vortex-ree/src/compress.rs @@ -14,7 +14,7 @@ use codecz::AlignedAllocator; use vortex::array::downcast::DowncastArrayBuiltin; -use vortex::array::primitive::{PrimitiveArray, PRIMITIVE_ENCODING}; +use vortex::array::primitive::{PrimitiveArray, PrimitiveEncoding}; use vortex::array::{Array, ArrayRef}; use vortex::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; use vortex::dtype::{DType, IntWidth, Nullability}; @@ -35,7 +35,7 @@ impl EncodingCompression for REEEncoding { .stats() .get_or_compute_or::(array.len(), &Stat::RunCount) as f32; - if array.encoding().id() == &PRIMITIVE_ENCODING + if array.encoding().id() == &PrimitiveEncoding::ID && avg_run_length >= config.ree_average_run_threshold { return Some(&(ree_compressor as Compressor)); diff --git a/vortex-ree/src/ree.rs b/vortex-ree/src/ree.rs index 99e81a4edc..f328b09cb0 100644 --- a/vortex-ree/src/ree.rs +++ b/vortex-ree/src/ree.rs @@ -243,11 +243,13 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for REEArray { #[derive(Debug)] pub struct REEEncoding; -pub const REE_ENCODING: EncodingId = EncodingId::new("vortex.ree"); +impl REEEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.ree"); +} impl Encoding for REEEncoding { fn id(&self) -> &EncodingId { - &REE_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-roaring/src/boolean/compress.rs b/vortex-roaring/src/boolean/compress.rs index 4bb550e928..97a8211c14 100644 --- a/vortex-roaring/src/boolean/compress.rs +++ b/vortex-roaring/src/boolean/compress.rs @@ -14,7 +14,7 @@ use croaring::Bitmap; -use vortex::array::bool::{BoolArray, BOOL_ENCODING}; +use vortex::array::bool::{BoolArray, BoolEncoding}; use vortex::array::downcast::DowncastArrayBuiltin; use vortex::array::{Array, ArrayRef}; use vortex::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; @@ -30,7 +30,7 @@ impl EncodingCompression for RoaringBoolEncoding { _config: &CompressConfig, ) -> Option<&'static Compressor> { // Only support bool enc arrays - if array.encoding().id() != &BOOL_ENCODING { + if array.encoding().id() != &BoolEncoding::ID { return None; } diff --git a/vortex-roaring/src/boolean/mod.rs b/vortex-roaring/src/boolean/mod.rs index f4d838ab79..b18b75153b 100644 --- a/vortex-roaring/src/boolean/mod.rs +++ b/vortex-roaring/src/boolean/mod.rs @@ -157,11 +157,13 @@ impl ArrayDisplay for RoaringBoolArray { #[derive(Debug)] pub struct RoaringBoolEncoding; -pub const ROARING_BOOL_ENCODING: EncodingId = EncodingId::new("roaring.bool"); +impl RoaringBoolEncoding { + pub const ID: EncodingId = EncodingId::new("roaring.bool"); +} impl Encoding for RoaringBoolEncoding { fn id(&self) -> &EncodingId { - &ROARING_BOOL_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-roaring/src/integer/compress.rs b/vortex-roaring/src/integer/compress.rs index e9ed04848f..f0b9122063 100644 --- a/vortex-roaring/src/integer/compress.rs +++ b/vortex-roaring/src/integer/compress.rs @@ -17,7 +17,7 @@ use log::debug; use num_traits::NumCast; use vortex::array::downcast::DowncastArrayBuiltin; -use vortex::array::primitive::{PrimitiveArray, PRIMITIVE_ENCODING}; +use vortex::array::primitive::{PrimitiveArray, PrimitiveEncoding}; use vortex::array::{Array, ArrayRef}; use vortex::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; use vortex::dtype::DType; @@ -35,7 +35,7 @@ impl EncodingCompression for RoaringIntEncoding { _config: &CompressConfig, ) -> Option<&'static Compressor> { // Only support primitive enc arrays - if array.encoding().id() != &PRIMITIVE_ENCODING { + if array.encoding().id() != &PrimitiveEncoding::ID { debug!("Skipping roaring int, not primitive"); return None; } diff --git a/vortex-roaring/src/integer/mod.rs b/vortex-roaring/src/integer/mod.rs index 6a974c0a9a..9d35a14692 100644 --- a/vortex-roaring/src/integer/mod.rs +++ b/vortex-roaring/src/integer/mod.rs @@ -163,11 +163,13 @@ impl ArrayDisplay for RoaringIntArray { #[derive(Debug)] pub struct RoaringIntEncoding; -pub const ROARING_INT_ENCODING: EncodingId = EncodingId::new("roaring.int"); +impl RoaringIntEncoding { + pub const ID: EncodingId = EncodingId::new("roaring.int"); +} impl Encoding for RoaringIntEncoding { fn id(&self) -> &EncodingId { - &ROARING_INT_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex-zigzag/src/zigzag.rs b/vortex-zigzag/src/zigzag.rs index 37c2d996f2..26a1d3b4cd 100644 --- a/vortex-zigzag/src/zigzag.rs +++ b/vortex-zigzag/src/zigzag.rs @@ -168,11 +168,13 @@ impl ArrayDisplay for ZigZagArray { #[derive(Debug)] pub struct ZigZagEncoding; -pub const ZIGZAG_ENCODING: EncodingId = EncodingId::new("vortex.zigzag"); +impl ZigZagEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.zigzag"); +} impl Encoding for ZigZagEncoding { fn id(&self) -> &EncodingId { - &ZIGZAG_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/bool/compress.rs b/vortex/src/array/bool/compress.rs index 089a69e371..bb1f74d9b3 100644 --- a/vortex/src/array/bool/compress.rs +++ b/vortex/src/array/bool/compress.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::array::bool::{BoolEncoding, BOOL_ENCODING}; +use crate::array::bool::BoolEncoding; use crate::array::{Array, ArrayRef}; use crate::compress::{ sampled_compression, CompressConfig, CompressCtx, Compressor, EncodingCompression, @@ -24,7 +24,7 @@ impl EncodingCompression for BoolEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &BOOL_ENCODING { + if array.encoding().id() == &BoolEncoding::ID { Some(&(bool_compressor as Compressor)) } else { None diff --git a/vortex/src/array/bool/mod.rs b/vortex/src/array/bool/mod.rs index 8e61902779..c59c072a9a 100644 --- a/vortex/src/array/bool/mod.rs +++ b/vortex/src/array/bool/mod.rs @@ -175,16 +175,18 @@ impl Array for BoolArray { } #[derive(Debug)] -struct BoolEncoding; +pub struct BoolEncoding; -pub const BOOL_ENCODING: EncodingId = EncodingId::new("vortex.bool"); +impl BoolEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.bool"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_BOOL: EncodingRef = &BoolEncoding; impl Encoding for BoolEncoding { fn id(&self) -> &EncodingId { - &BOOL_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/chunked/compress.rs b/vortex/src/array/chunked/compress.rs index 324a149205..87fbd4e3c2 100644 --- a/vortex/src/array/chunked/compress.rs +++ b/vortex/src/array/chunked/compress.rs @@ -14,7 +14,7 @@ use rayon::prelude::*; -use crate::array::chunked::{ChunkedArray, ChunkedEncoding, CHUNKED_ENCODING}; +use crate::array::chunked::{ChunkedArray, ChunkedEncoding}; use crate::array::downcast::DowncastArrayBuiltin; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; @@ -25,7 +25,7 @@ impl EncodingCompression for ChunkedEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &CHUNKED_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(chunked_compressor as Compressor)) } else { None diff --git a/vortex/src/array/chunked/mod.rs b/vortex/src/array/chunked/mod.rs index 223a5afdc3..abd39f9b46 100644 --- a/vortex/src/array/chunked/mod.rs +++ b/vortex/src/array/chunked/mod.rs @@ -225,16 +225,18 @@ impl ArrayDisplay for ChunkedArray { } #[derive(Debug)] -struct ChunkedEncoding; +pub struct ChunkedEncoding; -pub const CHUNKED_ENCODING: EncodingId = EncodingId::new("vortex.chunked"); +impl ChunkedEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.chunked"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_CHUNKED: EncodingRef = &ChunkedEncoding; impl Encoding for ChunkedEncoding { fn id(&self) -> &EncodingId { - &CHUNKED_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/constant/mod.rs b/vortex/src/array/constant/mod.rs index d91838d259..de3bde541a 100644 --- a/vortex/src/array/constant/mod.rs +++ b/vortex/src/array/constant/mod.rs @@ -140,14 +140,16 @@ impl ArrayDisplay for ConstantArray { #[derive(Debug)] pub struct ConstantEncoding; -pub const CONSTANT_ENCODING: EncodingId = EncodingId::new("vortex.constant"); +impl ConstantEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.constant"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_CONSTANT: EncodingRef = &ConstantEncoding; impl Encoding for ConstantEncoding { fn id(&self) -> &EncodingId { - &CONSTANT_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/mod.rs b/vortex/src/array/mod.rs index c9386f10fb..529677c458 100644 --- a/vortex/src/array/mod.rs +++ b/vortex/src/array/mod.rs @@ -18,16 +18,16 @@ use std::fmt::{Debug, Display, Formatter}; use arrow::array::ArrayRef as ArrowArrayRef; use linkme::distributed_slice; -use crate::array::bool::{BoolArray, BOOL_ENCODING}; -use crate::array::chunked::{ChunkedArray, CHUNKED_ENCODING}; -use crate::array::constant::{ConstantArray, CONSTANT_ENCODING}; +use crate::array::bool::{BoolArray, BoolEncoding}; +use crate::array::chunked::{ChunkedArray, ChunkedEncoding}; +use crate::array::constant::{ConstantArray, ConstantEncoding}; use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::primitive::{PrimitiveArray, PRIMITIVE_ENCODING}; -use crate::array::sparse::{SparseArray, SPARSE_ENCODING}; -use crate::array::struct_::{StructArray, STRUCT_ENCODING}; -use crate::array::typed::{TypedArray, TYPED_ENCODING}; -use crate::array::varbin::{VarBinArray, VARBIN_ENCODING}; -use crate::array::varbinview::{VarBinViewArray, VARBINVIEW_ENCODING}; +use crate::array::primitive::{PrimitiveArray, PrimitiveEncoding}; +use crate::array::sparse::{SparseArray, SparseEncoding}; +use crate::array::struct_::{StructArray, StructEncoding}; +use crate::array::typed::{TypedArray, TypedEncoding}; +use crate::array::varbin::{VarBinArray, VarBinEncoding}; +use crate::array::varbinview::{VarBinViewArray, VarBinViewEncoding}; use crate::compress::EncodingCompression; use crate::compute::ArrayCompute; use crate::dtype::{DType, Nullability}; @@ -183,15 +183,15 @@ pub enum ArrayKind<'a> { impl<'a> From<&'a dyn Array> for ArrayKind<'a> { fn from(value: &'a dyn Array) -> Self { match *value.encoding().id() { - BOOL_ENCODING => ArrayKind::Bool(value.as_bool()), - CHUNKED_ENCODING => ArrayKind::Chunked(value.as_chunked()), - CONSTANT_ENCODING => ArrayKind::Constant(value.as_constant()), - PRIMITIVE_ENCODING => ArrayKind::Primitive(value.as_primitive()), - SPARSE_ENCODING => ArrayKind::Sparse(value.as_sparse()), - STRUCT_ENCODING => ArrayKind::Struct(value.as_struct()), - TYPED_ENCODING => ArrayKind::Typed(value.as_typed()), - VARBIN_ENCODING => ArrayKind::VarBin(value.as_varbin()), - VARBINVIEW_ENCODING => ArrayKind::VarBinView(value.as_varbinview()), + BoolEncoding::ID => ArrayKind::Bool(value.as_bool()), + ChunkedEncoding::ID => ArrayKind::Chunked(value.as_chunked()), + ConstantEncoding::ID => ArrayKind::Constant(value.as_constant()), + PrimitiveEncoding::ID => ArrayKind::Primitive(value.as_primitive()), + SparseEncoding::ID => ArrayKind::Sparse(value.as_sparse()), + StructEncoding::ID => ArrayKind::Struct(value.as_struct()), + TypedEncoding::ID => ArrayKind::Typed(value.as_typed()), + VarBinEncoding::ID => ArrayKind::VarBin(value.as_varbin()), + VarBinViewEncoding::ID => ArrayKind::VarBinView(value.as_varbinview()), _ => ArrayKind::Other(value), } } diff --git a/vortex/src/array/primitive/compress.rs b/vortex/src/array/primitive/compress.rs index 1e50beb4d4..69c8409747 100644 --- a/vortex/src/array/primitive/compress.rs +++ b/vortex/src/array/primitive/compress.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::array::primitive::{PrimitiveEncoding, PRIMITIVE_ENCODING}; +use crate::array::primitive::PrimitiveEncoding; use crate::array::{Array, ArrayRef}; use crate::compress::{ sampled_compression, CompressConfig, CompressCtx, Compressor, EncodingCompression, @@ -24,7 +24,7 @@ impl EncodingCompression for PrimitiveEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &PRIMITIVE_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(primitive_compressor as Compressor)) } else { None diff --git a/vortex/src/array/primitive/mod.rs b/vortex/src/array/primitive/mod.rs index c0d6ba7d7c..b5208ffe3d 100644 --- a/vortex/src/array/primitive/mod.rs +++ b/vortex/src/array/primitive/mod.rs @@ -260,14 +260,16 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for PrimitiveArray { #[derive(Debug)] pub struct PrimitiveEncoding; -pub const PRIMITIVE_ENCODING: EncodingId = EncodingId::new("vortex.primitive"); +impl PrimitiveEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.primitive"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_PRIMITIVE: EncodingRef = &PrimitiveEncoding; impl Encoding for PrimitiveEncoding { fn id(&self) -> &EncodingId { - &PRIMITIVE_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/sparse/compress.rs b/vortex/src/array/sparse/compress.rs index e4721e0440..215f8832a2 100644 --- a/vortex/src/array/sparse/compress.rs +++ b/vortex/src/array/sparse/compress.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::sparse::{SparseArray, SparseEncoding, SPARSE_ENCODING}; +use crate::array::sparse::{SparseArray, SparseEncoding}; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; @@ -23,7 +23,7 @@ impl EncodingCompression for SparseEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &SPARSE_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(sparse_compressor as Compressor)) } else { None diff --git a/vortex/src/array/sparse/mod.rs b/vortex/src/array/sparse/mod.rs index 2b9de72d85..1046e98f39 100644 --- a/vortex/src/array/sparse/mod.rs +++ b/vortex/src/array/sparse/mod.rs @@ -243,14 +243,16 @@ impl ArrayDisplay for SparseArray { #[derive(Debug)] pub struct SparseEncoding; -pub const SPARSE_ENCODING: EncodingId = EncodingId::new("vortex.sparse"); +impl SparseEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.sparse"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_SPARSE: EncodingRef = &SparseEncoding; impl Encoding for SparseEncoding { fn id(&self) -> &EncodingId { - &SPARSE_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/struct_/compress.rs b/vortex/src/array/struct_/compress.rs index e318f49521..731a421dfd 100644 --- a/vortex/src/array/struct_/compress.rs +++ b/vortex/src/array/struct_/compress.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::struct_::{StructArray, StructEncoding, STRUCT_ENCODING}; +use crate::array::struct_::{StructArray, StructEncoding}; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; use rayon::iter::IndexedParallelIterator; @@ -26,7 +26,7 @@ impl EncodingCompression for StructEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &STRUCT_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(struct_compressor as Compressor)) } else { None diff --git a/vortex/src/array/struct_/mod.rs b/vortex/src/array/struct_/mod.rs index 904714994b..4aaaeeefa5 100644 --- a/vortex/src/array/struct_/mod.rs +++ b/vortex/src/array/struct_/mod.rs @@ -195,14 +195,16 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for StructArray { #[derive(Debug)] pub struct StructEncoding; -pub const STRUCT_ENCODING: EncodingId = EncodingId::new("vortex.struct"); +impl StructEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.struct"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_STRUCT: EncodingRef = &StructEncoding; impl Encoding for StructEncoding { fn id(&self) -> &EncodingId { - &STRUCT_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/typed/compress.rs b/vortex/src/array/typed/compress.rs index e309851342..956422fdc6 100644 --- a/vortex/src/array/typed/compress.rs +++ b/vortex/src/array/typed/compress.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::typed::{TypedArray, TypedEncoding, TYPED_ENCODING}; +use crate::array::typed::{TypedArray, TypedEncoding}; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; @@ -23,7 +23,7 @@ impl EncodingCompression for TypedEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &TYPED_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(typed_compressor as Compressor)) } else { None diff --git a/vortex/src/array/typed/mod.rs b/vortex/src/array/typed/mod.rs index f845a4609c..e438a23c34 100644 --- a/vortex/src/array/typed/mod.rs +++ b/vortex/src/array/typed/mod.rs @@ -140,16 +140,18 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for TypedArray { } #[derive(Debug)] -struct TypedEncoding; +pub struct TypedEncoding; -pub const TYPED_ENCODING: EncodingId = EncodingId::new("vortex.typed"); +impl TypedEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.typed"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_TYPED: EncodingRef = &TypedEncoding; impl Encoding for TypedEncoding { fn id(&self) -> &EncodingId { - &TYPED_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/varbin/compress.rs b/vortex/src/array/varbin/compress.rs index 103e0a71fb..7710f2470b 100644 --- a/vortex/src/array/varbin/compress.rs +++ b/vortex/src/array/varbin/compress.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::varbin::{VarBinArray, VarBinEncoding, VARBIN_ENCODING}; +use crate::array::varbin::{VarBinArray, VarBinEncoding}; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; @@ -23,7 +23,7 @@ impl EncodingCompression for VarBinEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &VARBIN_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(varbin_compressor as Compressor)) } else { None diff --git a/vortex/src/array/varbin/mod.rs b/vortex/src/array/varbin/mod.rs index f1dc46d3e5..77c428f4b6 100644 --- a/vortex/src/array/varbin/mod.rs +++ b/vortex/src/array/varbin/mod.rs @@ -322,16 +322,18 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for VarBinArray { } #[derive(Debug)] -struct VarBinEncoding; +pub struct VarBinEncoding; -pub const VARBIN_ENCODING: EncodingId = EncodingId::new("vortex.varbin"); +impl VarBinEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.varbin"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_VARBIN: EncodingRef = &VarBinEncoding; impl Encoding for VarBinEncoding { fn id(&self) -> &EncodingId { - &VARBIN_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/array/varbinview/compress.rs b/vortex/src/array/varbinview/compress.rs index 7957defc50..c63e9df9b3 100644 --- a/vortex/src/array/varbinview/compress.rs +++ b/vortex/src/array/varbinview/compress.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::varbinview::{VarBinViewArray, VarBinViewEncoding, VARBINVIEW_ENCODING}; +use crate::array::varbinview::{VarBinViewArray, VarBinViewEncoding}; use crate::array::{Array, ArrayRef}; use crate::compress::{CompressConfig, CompressCtx, Compressor, EncodingCompression}; use rayon::prelude::*; @@ -24,7 +24,7 @@ impl EncodingCompression for VarBinViewEncoding { array: &dyn Array, _config: &CompressConfig, ) -> Option<&'static Compressor> { - if array.encoding().id() == &VARBINVIEW_ENCODING { + if array.encoding().id() == &Self::ID { Some(&(varbinview_compressor as Compressor)) } else { None diff --git a/vortex/src/array/varbinview/mod.rs b/vortex/src/array/varbinview/mod.rs index 8b04782b2a..eaec743137 100644 --- a/vortex/src/array/varbinview/mod.rs +++ b/vortex/src/array/varbinview/mod.rs @@ -341,16 +341,18 @@ impl<'arr> AsRef<(dyn Array + 'arr)> for VarBinViewArray { } #[derive(Debug)] -struct VarBinViewEncoding; +pub struct VarBinViewEncoding; -pub const VARBINVIEW_ENCODING: EncodingId = EncodingId::new("vortex.varbinview"); +impl VarBinViewEncoding { + pub const ID: EncodingId = EncodingId::new("vortex.varbinview"); +} #[distributed_slice(ENCODINGS)] static ENCODINGS_VARBINVIEW: EncodingRef = &VarBinViewEncoding; impl Encoding for VarBinViewEncoding { fn id(&self) -> &EncodingId { - &VARBINVIEW_ENCODING + &Self::ID } fn compression(&self) -> Option<&dyn EncodingCompression> { diff --git a/vortex/src/compress.rs b/vortex/src/compress.rs index 9210c5484f..cbac99bf90 100644 --- a/vortex/src/compress.rs +++ b/vortex/src/compress.rs @@ -18,7 +18,7 @@ use std::fmt::Debug; use log::debug; use once_cell::sync::Lazy; -use crate::array::constant::{ConstantEncoding, CONSTANT_ENCODING}; +use crate::array::constant::ConstantEncoding; use crate::array::{Array, ArrayRef, Encoding, EncodingId, ENCODINGS}; use crate::compute; use crate::sampling::stratified_slices; @@ -63,7 +63,7 @@ impl CompressConfig { mut disabled_encodings: HashSet<&'static EncodingId>, ) -> Self { // Always disable constant encoding, it's handled separately - disabled_encodings.insert(&CONSTANT_ENCODING); + disabled_encodings.insert(&ConstantEncoding::ID); Self { encodings, disabled_encodings, diff --git a/vortex/src/compute/as_contiguous.rs b/vortex/src/compute/as_contiguous.rs index a8fc939232..db3573280a 100644 --- a/vortex/src/compute/as_contiguous.rs +++ b/vortex/src/compute/as_contiguous.rs @@ -15,9 +15,9 @@ use arrow::buffer::BooleanBuffer; use itertools::Itertools; -use crate::array::bool::{BoolArray, BOOL_ENCODING}; +use crate::array::bool::{BoolArray, BoolEncoding}; use crate::array::downcast::DowncastArrayBuiltin; -use crate::array::primitive::{PrimitiveArray, PRIMITIVE_ENCODING}; +use crate::array::primitive::{PrimitiveArray, PrimitiveEncoding}; use crate::array::{Array, ArrayRef}; use crate::error::{VortexError, VortexResult}; use crate::ptype::{match_each_native_ptype, NativePType}; @@ -34,10 +34,10 @@ pub fn as_contiguous(arrays: Vec) -> VortexResult { } match *arrays[0].encoding().id() { - BOOL_ENCODING => { + BoolEncoding::ID => { Ok(bool_as_contiguous(arrays.iter().map(|a| a.as_bool()).collect())?.boxed()) } - PRIMITIVE_ENCODING => { + PrimitiveEncoding::ID => { Ok(primitive_as_contiguous(arrays.iter().map(|a| a.as_primitive()).collect())?.boxed()) } _ => Err(VortexError::ComputeError(