Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parquet/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion parquet/src/column/reader/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: DataType> {
Expand Down
29 changes: 29 additions & 0 deletions parquet/src/parquet_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = &[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite cool

$(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();
}
}
}

Expand Down
Loading