diff --git a/parquet/src/basic.rs b/parquet/src/basic.rs index 7f50eada46de..def69f251581 100644 --- a/parquet/src/basic.rs +++ b/parquet/src/basic.rs @@ -741,7 +741,7 @@ pub struct EncodingMask(i32); impl EncodingMask { /// Highest valued discriminant in the [`Encoding`] enum - const MAX_ENCODING: i32 = Encoding::BYTE_STREAM_SPLIT as i32; + const MAX_ENCODING: i32 = Encoding::MAX_DISCRIMINANT; /// A mask consisting of unused bit positions, used for validation. This includes the never /// used GROUP_VAR_INT encoding value of `1`. const ALLOWED_MASK: u32 = diff --git a/parquet/src/column/reader/decoder.rs b/parquet/src/column/reader/decoder.rs index 1d4e2f751181..e49906207577 100644 --- a/parquet/src/column/reader/decoder.rs +++ b/parquet/src/column/reader/decoder.rs @@ -138,7 +138,7 @@ pub trait ColumnValueDecoder { /// /// This replaces `HashMap` lookups with direct indexing to avoid hashing overhead in the /// hot decoding paths. -const ENCODING_SLOTS: usize = Encoding::BYTE_STREAM_SPLIT as usize + 1; +const ENCODING_SLOTS: usize = Encoding::MAX_DISCRIMINANT as usize + 1; /// An implementation of [`ColumnValueDecoder`] for `[T::T]` pub struct ColumnValueDecoderImpl { diff --git a/parquet/src/parquet_macros.rs b/parquet/src/parquet_macros.rs index eb8bc2b7f07a..d7f865de040e 100644 --- a/parquet/src/parquet_macros.rs +++ b/parquet/src/parquet_macros.rs @@ -79,6 +79,35 @@ macro_rules! thrift_enum { Ok(field_id) } } + + impl $identifier { + #[allow(deprecated)] + #[doc = "Returns a slice containing every variant of this enum."] + #[allow(dead_code)] + pub const VARIANTS: &'static [Self] = &[ + $(Self::$field_name),* + ]; + + #[allow(deprecated)] + const fn max_discriminant_impl() -> i32 { + let values: &[i32] = &[$($field_value),*]; + let mut max = values[0]; + let mut idx = 1; + while idx < values.len() { + let candidate = values[idx]; + if candidate > max { + max = candidate; + } + idx += 1; + } + max + } + + #[allow(deprecated)] + #[doc = "Returns the largest discriminant value defined for this enum."] + #[allow(dead_code)] + pub const MAX_DISCRIMINANT: i32 = Self::max_discriminant_impl(); + } } }