HippoBaro commented on code in PR #9653:
URL: https://github.com/apache/arrow-rs/pull/9653#discussion_r3090022393
##########
parquet/src/column/writer/mod.rs:
##########
@@ -328,6 +314,77 @@ impl<T: Default> ColumnMetrics<T> {
}
}
+#[derive(Debug, Clone, Copy)]
+pub(crate) enum LevelDataRef<'a> {
+ Absent,
+ Materialized(&'a [i16]),
+ Uniform { value: i16, count: usize },
+}
+
+impl<'a> LevelDataRef<'a> {
+ pub(crate) fn len(self) -> usize {
+ match self {
+ Self::Absent => 0,
+ Self::Materialized(values) => values.len(),
+ Self::Uniform { count, .. } => count,
+ }
+ }
+
+ pub(crate) fn first(self) -> Option<i16> {
+ match self {
+ Self::Absent => None,
+ Self::Materialized(values) => values.first().copied(),
+ Self::Uniform { value, count } => (count > 0).then_some(value),
+ }
+ }
+
+ #[cfg(feature = "arrow")]
+ pub(crate) fn value_at(self, idx: usize) -> Option<i16> {
+ match self {
+ Self::Absent => None,
+ Self::Materialized(values) => values.get(idx).copied(),
+ Self::Uniform { value, count } => (idx < count).then_some(value),
+ }
+ }
+
+ pub(crate) fn slice(self, offset: usize, len: usize) -> Self {
+ match self {
+ Self::Absent => Self::Absent,
+ Self::Materialized(values) =>
Self::Materialized(&values[offset..offset + len]),
+ Self::Uniform { value, .. } => Self::Uniform { value, count: len },
+ }
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+pub(crate) enum ValueSelectionRef<'a> {
Review Comment:
See https://github.com/apache/arrow-rs/pull/9653#discussion_r3090016825
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]