You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "etseidl (via GitHub)" <gi...@apache.org> on 2025/11/06 01:36:32 UTC

[PR] [WIP] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

etseidl opened a new pull request, #8797:
URL: https://github.com/apache/arrow-rs/pull/8797

   # Which issue does this PR close?
   
   - Closes #8518.
   
   # Rationale for this change
   
   This builds on #8763 to add options to either skip decoding of the page encoding statistics array, or transform it to a bitmask. This gets rid of the last of the heavy allocations in the metadata decoder.
   
   # What changes are included in this PR?
   Adds new options to `ParquetMetaDataOptions`. Also adds more metadata benchmarks.
   
   # Are these changes tested?
   
   Not yet, but tests on the way.
   
   # Are there any user-facing changes?
   No, just adds new field to `ColumnChunkMetaData`.
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [WIP] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3494420928

   excerpts from new benchmarks
   ```
   decode parquet metadata time:   [15.050 µs 15.105 µs 15.164 µs]
   decode metadata with schema
                           time:   [7.7038 µs 7.7286 µs 7.7561 µs]
   decode metadata with stats mask
                           time:   [14.035 µs 14.100 µs 14.182 µs
   decode metadata with skip PES
                           time:   [13.976 µs 14.016 µs 14.060 µs]
   decode parquet metadata (wide)
                           time:   [54.013 ms 54.236 ms 54.468 ms]
   decode metadata (wide) with schema
                           time:   [48.399 ms 48.562 ms 48.738 ms]
   decode metadata (wide) with stats mask
                           time:   [44.912 ms 45.077 ms 45.253 ms]
   decode metadata (wide) with skip PES
                           time:   [44.500 ms 44.616 ms 44.739 ms]
   ```
   Skipping the stats is not any faster than turning them into a mask 😮.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2534510617


##########
parquet/src/file/metadata/options.rs:
##########
@@ -29,6 +33,24 @@ use crate::schema::types::SchemaDescPtr;
 #[derive(Default, Debug, Clone)]
 pub struct ParquetMetaDataOptions {
     schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,

Review Comment:
   They're not *quite* mutually exclusive...if you enable stats for a few columns, those stats can be the mask form rather than the vec. I'll make the docs a little clearer.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2516084430


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,70 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the `encoding_stats` field of the `ColumnMetaData` as a
+    /// bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert `encoding_stats` from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);

Review Comment:
   Now that I've done the macro, it saves all of 3 lines per instance. I'm fine with doing away with it.
   
   One reason to keep this concise is that once an API is finalized for this setting, I'll add options for chunk statistics, size statistics, and geo statistics, and potentially an option to skip decoding the page index length/offsets as well (oh, and bloom filters too). That's a lot of repetition with high chances of cut-and-paste errors that I'd like to avoid, especially with the addition of per-column setters (i.e. the poorly named `set_keep_X`). I'd really like the whole suite of accessors/setters to be generated with a macro, but then documentation becomes problematic. Suggestions welcome 😄 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2519463347


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,83 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert [`encoding_stats`] from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);
+
+    /// Returns whether to skip decoding the [`encoding_stats`] in the Parquet `ColumnMetaData`
+    /// for the column indexed by `col_index`.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn skip_encoding_stats(&self, col_index: usize) -> bool {
+        self.skip_encoding_stats
+            .as_ref()
+            .is_some_and(|oset| oset.as_ref().is_none_or(|keep| !keep.contains(&col_index)))
+    }
+
+    /// Sets whether to skip decoding of all [`encoding_stats`] in the Parquet `ColumnMetaData`.
+    /// Takes precedence over [`Self::encoding_stats_as_mask`].
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_skip_encoding_stats(&mut self, val: bool) {
+        self.skip_encoding_stats = if val { Some(None) } else { None };
+    }
+
+    // with_skip_encoding_stats
+    add_mutator!(skip_encoding_stats, bool);
+
+    /// Skip decoding of [`encoding_stats`] in the Parquet `ColumnMetaData`, but decode the stats
+    /// for those columns in the provided list of column indices.
+    ///
+    /// This allows for optimizations such as only decoding the page encoding statistics
+    /// for columns present in a predicate.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_keep_encoding_stats(&mut self, keep: &[usize]) {

Review Comment:
   I'm open to a better name for this. `set_decode_encoding_stats_for_columns` is a bit long winded.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2538004656


##########
parquet/src/file/metadata/options.rs:
##########
@@ -29,6 +74,11 @@ use crate::schema::types::SchemaDescPtr;
 #[derive(Default, Debug, Clone)]
 pub struct ParquetMetaDataOptions {
     schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indices to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   
   Would it make sense to update this API to also use `ParquetStatisticsPolicy`?
   
   ```suggestion
       skip_encoding_stats: ParquetStatisticsPolicy,
   ```



##########
parquet/src/arrow/arrow_reader/mod.rs:
##########
@@ -557,6 +557,29 @@ impl ArrowReaderOptions {
         self
     }
 
+    /// Set whether to convert the [`encoding_stats`] in the Parquet `ColumnMetaData` to a bitmask.

Review Comment:
   ```suggestion
       /// Set whether to convert the [`encoding_stats`] in the Parquet `ColumnMetaData` to a bitmask (defaults to false)
   ```



##########
parquet/src/file/metadata/options.rs:
##########
@@ -17,12 +17,53 @@
 
 //! Options used to control metadata parsing
 
-use paste::paste;
 use std::collections::HashSet;
 use std::sync::Arc;
 
 use crate::schema::types::SchemaDescPtr;
 
+/// Enum to control decoding of some Parquet statistics fields.

Review Comment:
   yes, i agree this is much better



##########
parquet/src/file/metadata/options.rs:
##########
@@ -17,8 +17,53 @@
 
 //! Options used to control metadata parsing
 
+use std::collections::HashSet;
+use std::sync::Arc;
+
 use crate::schema::types::SchemaDescPtr;
 
+/// Enum to control decoding of some Parquet statistics fields.
+///
+/// # Example
+/// ```rust
+/// use parquet::file::metadata::ParquetStatisticsPolicy;
+/// use parquet::file::serialized_reader::ReadOptionsBuilder;
+/// use parquet::arrow::arrow_reader::ArrowReaderOptions;
+///
+/// // Set arrow options to skip encoding statistics for all columns.
+/// let options =
+///     ArrowReaderOptions::new().with_encoding_stats_policy(ParquetStatisticsPolicy::SkipAll);
+///
+/// // Set serialized reader options to decode encoding statistics for all columns.
+/// let options =
+///     ReadOptionsBuilder::new().with_encoding_stats_policy(ParquetStatisticsPolicy::KeepAll)
+///     .build();
+///
+/// // Set arrow options to skip encoding statistics for all columns, but to decode statistics
+/// // for columns 0 and 1.
+/// let options = ArrowReaderOptions::new()
+///     .with_encoding_stats_policy(ParquetStatisticsPolicy::skip_except(&[0, 1]));
+/// ```
+#[derive(Debug, Clone)]
+pub enum ParquetStatisticsPolicy {
+    /// Decode the relevant statistics for all columns.
+    KeepAll,
+    /// Skip decoding the relevant statistics for all columns.
+    SkipAll,
+    /// Skip decoding the relevant statistics for all columns not in the provided set
+    /// of column indices.
+    SkipExcept(HashSet<usize>),
+}
+
+impl ParquetStatisticsPolicy {
+    /// Create a `ParquetStatisticsPolicy` to skip all columns except those in `keep`.
+    pub fn skip_except(keep: &[usize]) -> Self {

Review Comment:
   This is a nice API



##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,9 +98,79 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
+    /// Call [`Self::set_schema`] and return `Self` for chaining.
     pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
+        self.set_schema(val);
+        self
+    }
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.

Review Comment:
   ```suggestion
       /// as a bitmask (defaults to false).
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2515941613


##########
parquet/src/file/metadata/mod.rs:
##########
@@ -1913,9 +1952,9 @@ mod tests {
             .build();
 
         #[cfg(not(feature = "encryption"))]
-        let bigger_expected_size = 3192;
+        let bigger_expected_size = 3224;
         #[cfg(feature = "encryption")]
-        let bigger_expected_size = 3360;
+        let bigger_expected_size = 3392;

Review Comment:
   This is for adding the mask to `ColumnChunkMetaData`. An alternative might be to create an enum with `Vec` and mask variants if we don't want more bloat.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3608540348

   We also lack a benchmark with the other column level statistics. I'll address that before adding any more skipping logic.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2516084430


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,70 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the `encoding_stats` field of the `ColumnMetaData` as a
+    /// bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert `encoding_stats` from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);

Review Comment:
   Now that I've done the macro, it saves all of 3 lines per instance. I'm fine with doing away with it.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3543845192

   Thanks for the review @alamb. I've now refactored a bit and introduced a policy enum for the encoding stats. I like this much more than the earlier API and feel it addresses my concerns about bloat. Please check it out when you have a moment. 🙏 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2535143052


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,83 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert [`encoding_stats`] from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);
+
+    /// Returns whether to skip decoding the [`encoding_stats`] in the Parquet `ColumnMetaData`
+    /// for the column indexed by `col_index`.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn skip_encoding_stats(&self, col_index: usize) -> bool {
+        self.skip_encoding_stats
+            .as_ref()
+            .is_some_and(|oset| oset.as_ref().is_none_or(|keep| !keep.contains(&col_index)))
+    }
+
+    /// Sets whether to skip decoding of all [`encoding_stats`] in the Parquet `ColumnMetaData`.
+    /// Takes precedence over [`Self::encoding_stats_as_mask`].
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_skip_encoding_stats(&mut self, val: bool) {
+        self.skip_encoding_stats = if val { Some(None) } else { None };
+    }
+
+    // with_skip_encoding_stats
+    add_mutator!(skip_encoding_stats, bool);
+
+    /// Skip decoding of [`encoding_stats`] in the Parquet `ColumnMetaData`, but decode the stats
+    /// for those columns in the provided list of column indices.
+    ///
+    /// This allows for optimizations such as only decoding the page encoding statistics
+    /// for columns present in a predicate.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_keep_encoding_stats(&mut self, keep: &[usize]) {

Review Comment:
   Or
   ```rust
   /// Enum to control decoding of some Parquet statistics fields.
   #[derive(Debug, Clone)]
   pub enum ParquetStatisticsPolicy {
       /// Decode the relevant statistics for all columns.
       KeepAll,
       /// Skip decoding the relevant statistics for all columns.
       SkipAll,
       /// Skip decoding the relevant statistics for all columns not in the provided set
       /// of column indices.
       SkipExcept(HashSet<usize>),
   }
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2535082555


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,83 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert [`encoding_stats`] from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);
+
+    /// Returns whether to skip decoding the [`encoding_stats`] in the Parquet `ColumnMetaData`
+    /// for the column indexed by `col_index`.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn skip_encoding_stats(&self, col_index: usize) -> bool {
+        self.skip_encoding_stats
+            .as_ref()
+            .is_some_and(|oset| oset.as_ref().is_none_or(|keep| !keep.contains(&col_index)))
+    }
+
+    /// Sets whether to skip decoding of all [`encoding_stats`] in the Parquet `ColumnMetaData`.
+    /// Takes precedence over [`Self::encoding_stats_as_mask`].
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_skip_encoding_stats(&mut self, val: bool) {
+        self.skip_encoding_stats = if val { Some(None) } else { None };
+    }
+
+    // with_skip_encoding_stats
+    add_mutator!(skip_encoding_stats, bool);
+
+    /// Skip decoding of [`encoding_stats`] in the Parquet `ColumnMetaData`, but decode the stats
+    /// for those columns in the provided list of column indices.
+    ///
+    /// This allows for optimizations such as only decoding the page encoding statistics
+    /// for columns present in a predicate.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_keep_encoding_stats(&mut self, keep: &[usize]) {

Review Comment:
   Another option to reduce bloat is to add `keep` as an optional argument to `set_skip_encoding_stats`. That might be less confusing.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2515260496


##########
parquet/src/file/metadata/mod.rs:
##########
@@ -1050,12 +1051,43 @@ impl ColumnChunkMetaData {
         self.geo_statistics.as_deref()
     }
 
-    /// Returns the offset for the page encoding stats,
-    /// or `None` if no page encoding stats are available.
+    /// Returns the page encoding statistics, or `None` if no page encoding statistics
+    /// are available.
     pub fn page_encoding_stats(&self) -> Option<&Vec<PageEncodingStats>> {
         self.encoding_stats.as_ref()
     }
 
+    /// Returns the page encoding statistics reduced to a bitmask, or `None` if statistics are
+    /// not available.
+    ///
+    /// The [`PageEncodingStats`] struct was added to the Parquet specification specifically to
+    /// enable fast determination of whether all pages in a column chunk are dictionary encoded
+    /// (see <https://github.com/apache/parquet-format/pull/16>).
+    /// Decoding the full page encoding statistics, however, can be very costly, and is not
+    /// necessary to support the aforementioned use case. As an alternative, this crate can
+    /// instead distill the list of `PageEncodingStats` down to a bitmask of just the encodings
+    /// used for data pages
+    /// (see [`ParquetMetaDataOptions::set_encoding_stats_as_mask`]).
+    /// To test for an all-dictionary-encoded chunk one could use this bitmask in the following way:
+    ///
+    /// ```rust
+    /// use parquet::basic::Encoding;
+    /// use parquet::file::metadata::ColumnChunkMetaData;
+    /// // test if all data pages in the column chunk are dictionary encoded
+    /// fn is_all_dictionary_encoded(col_meta: &ColumnChunkMetaData) -> bool {
+    ///     // check that dictionary encoding was used
+    ///     col_meta.dictionary_page_offset().is_some()
+    ///         && col_meta.page_encoding_stats_mask().is_some_and(|mask| {
+    ///             // mask should only have one bit set, either for PLAIN_DICTIONARY or
+    ///             // RLE_DICTIONARY
+    ///             mask.is_only(Encoding::PLAIN_DICTIONARY) || mask.is_only(Encoding::RLE_DICTIONARY)
+    ///         })
+    /// }
+    /// ```
+    pub fn page_encoding_stats_mask(&self) -> Option<&EncodingMask> {

Review Comment:
   I wonder if this should be `data_page_encoding_stats_mask` (or just `data_page_encoding_stats`) to make it clear it only has the stats for data pages.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3549738741

   Circling back to the question about skipping the stats (https://github.com/apache/arrow-rs/pull/8797#pullrequestreview-3472757501), I've created several branches based off of this PR and #8714. I've implemented row group, column, and all chunk statistics skipping, all with and without the metadata index. Here's some preliminary benchmark numbers:
   ```
   group                                               index                                  skip                                   skip_opt
   -----                                               -----                                  ----                                   --------
   decode metadata (wide) 10 columns                   1.00     19.2±0.61ms        ? ?/sec    2.11     40.6±0.74ms        ? ?/sec    1.77     34.0±0.51ms        ? ?/sec
   decode metadata (wide) 10 columns last row group    1.00      7.9±0.15ms        ? ?/sec    3.75     29.7±0.33ms        ? ?/sec    2.96     23.4±0.30ms        ? ?/sec
   decode metadata (wide) last row group               1.00     10.7±0.27ms        ? ?/sec    2.81     29.9±0.50ms        ? ?/sec    2.27     24.2±0.32ms        ? ?/sec
   decode metadata (wide) with schema                  1.05     47.5±2.15ms        ? ?/sec    1.01     45.7±0.77ms        ? ?/sec    1.00     45.3±0.62ms        ? ?/sec
   decode metadata (wide) with skip PES                1.00     33.2±1.04ms        ? ?/sec    1.26     41.9±0.50ms        ? ?/sec    1.15     38.0±0.45ms        ? ?/sec
   decode metadata (wide) with stats mask              1.03     43.9±0.71ms        ? ?/sec    1.01     42.8±0.85ms        ? ?/sec    1.00     42.5±0.57ms        ? ?/sec
   decode parquet metadata (wide)                      1.03     52.4±0.70ms        ? ?/sec    1.04     52.5±1.05ms        ? ?/sec    1.00     50.7±0.93ms        ? ?/sec
   ```
   
   "skip" is using the current `ThriftCompactInputProtocol::skip` code, which still has to parse the thrift data, but doesn't materialize it. "skip_opt" uses an optimized version of `skip()` that uses a stack rather than recursion to handle nested thrift structures. Finally "index" uses the index introduced in #8714 to enable selective decoding. For the "skip PES" bench I hacked the reader to skip all column metadata stats, not just the page encoding stats.
   
   If a cached schema is used, then the "10 columns last row group" case goes down to 2.3ms, which is over 20X faster than "decode parquet metadata (wide)" (52ms. For comparison that benchmark was 221ms in 56.2.0, and was down to 90ms after the first phase of the remodel).
   
   None of this is usable yet, but it does give some hope for speeding up point lookup queries with projection down the road.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2535336649


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,83 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert [`encoding_stats`] from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);
+
+    /// Returns whether to skip decoding the [`encoding_stats`] in the Parquet `ColumnMetaData`
+    /// for the column indexed by `col_index`.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn skip_encoding_stats(&self, col_index: usize) -> bool {
+        self.skip_encoding_stats
+            .as_ref()
+            .is_some_and(|oset| oset.as_ref().is_none_or(|keep| !keep.contains(&col_index)))
+    }
+
+    /// Sets whether to skip decoding of all [`encoding_stats`] in the Parquet `ColumnMetaData`.
+    /// Takes precedence over [`Self::encoding_stats_as_mask`].
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_skip_encoding_stats(&mut self, val: bool) {
+        self.skip_encoding_stats = if val { Some(None) } else { None };
+    }
+
+    // with_skip_encoding_stats
+    add_mutator!(skip_encoding_stats, bool);
+
+    /// Skip decoding of [`encoding_stats`] in the Parquet `ColumnMetaData`, but decode the stats
+    /// for those columns in the provided list of column indices.
+    ///
+    /// This allows for optimizations such as only decoding the page encoding statistics
+    /// for columns present in a predicate.
+    ///
+    /// [`encoding_stats`]:
+    /// https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L917
+    pub fn set_keep_encoding_stats(&mut self, keep: &[usize]) {

Review Comment:
   I went the policy route, so this is now moot



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2538937608


##########
parquet/src/file/metadata/options.rs:
##########
@@ -29,6 +74,11 @@ use crate::schema::types::SchemaDescPtr;
 #[derive(Default, Debug, Clone)]
 pub struct ParquetMetaDataOptions {
     schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indices to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   You know, I thought about this when I was wiring it up, and rejected it for some reason. I can't remember why, and suspect it's because there's no reason not to. Done in https://github.com/apache/arrow-rs/pull/8797/commits/4aed15b0d677a1679ef1810492a13c9252df96b2



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [WIP] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2505309676


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,

Review Comment:
   This defaults to `false` so no behavior change. If we want to enable using the mask by default, we can either implement `Default`, or change this to `encoding_stats_as_vec` or something to allow enabling the old behavior.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2524008847


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,70 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the `encoding_stats` field of the `ColumnMetaData` as a
+    /// bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert `encoding_stats` from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);

Review Comment:
   FWIW I've tried implementing a macro to generate all of the setters/getters. 
   
   <details>
   
   ```rust
   // For the field "name", generate setters and getters for the field. This generates:
   //    skip_name
   //    set_skip_name
   //    with_skip_name
   //    set_keep_name
   //    with_keep_name
   // This assumes a field "skip_name" exists in the ParquetMetaDataOptions struct.
   macro_rules! add_bool_accessors {
       ($name:expr) => {
           paste! {
               #[doc = concat!("Returns whether to skip decoding the `", stringify!($name), "`")]
               #[doc = "in the Parquet [`ColumnMetaData`] for the column indexed by `col_index`."]
               #[doc = ""]
               #[doc = "[`ColumnMetaData`]: https://github.com/apache/parquet-format/blob/786142e26740487930ddc3ec5e39d780bd930907/src/main/thrift/parquet.thrift#L875"]
               pub fn [<skip_ $name>](&self, col_index: usize) -> bool {
                   self.[<skip_ $name>]
                       .as_ref()
                       .is_some_and(|oset| oset.as_ref().is_none_or(|keep| !keep.contains(&col_index)))
               }
               ...
           }
       }
   }
   
   pub struct ParquetMetaDataOptions {
       ...
       skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,
       skip_statistics: Option<Option<Arc<HashSet<usize>>>>,
       skip_size_statistics: Option<Option<Arc<HashSet<usize>>>>,
       skip_geospatial_statistics: Option<Option<Arc<HashSet<usize>>>>,
   }
   
   impl ParquetMetaDataOptions {
       ...
       add_bool_accessors!(encoding_stats);
       add_bool_accessors!(statistics);
       add_bool_accessors!(size_statistics);
       add_bool_accessors!(geospatial_statistics);
   }
   ```
   </details>



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2535339586


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,70 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the `encoding_stats` field of the `ColumnMetaData` as a
+    /// bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert `encoding_stats` from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);

Review Comment:
   I removed the macro and replaced the multiple setters for stats skipping with a policy enum



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3608011010

   Any objections to merging this now? @alamb?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3608520951

   It occurs to me we don't really have any benchmarks for writing parquet files as a whole (we have some low level benchmarks for the arrow writers). Maybe we should write some...


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2524437367


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indicies to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   Querying this causes a noticeable regression even when the outer option is `None`. I'm going to investigate other options here. Marking as draft until I can get this worked out.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3552869370

   @etseidl  would you like to merge this PR for inclusion in arrow 57.1.0? Or shall we want to merge until after I make the branch / RC?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [WIP] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2505254676


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indicies to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   This is my solution to per-column options. For huge schemas I didn't want a `Vec<bool>` that's mostly filled with `false`. Using `Arc` so cloning should be faster.
   
   | skip_encoding_stats | behavior |       
   |--------------|------------------|
   | `None`       | decode all       |
   | `Some<None>` | decode none      |
   | `Some<Some<Set>>` | decode if in set |
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2524437367


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indicies to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   Querying this causes a noticeable regression even when the outer option is `None`. I'm going to investigate other options here. Marking as draft until I can get this worked out.
   
   Edit: I spent half a day running this down, and in the end found that merging main into this branch made most of the timing differences go away.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl merged PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2534131627


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,

Review Comment:
   I personally suggest we: file a ticket / PR to change the default in the next major release



##########
parquet/src/file/metadata/options.rs:
##########
@@ -29,6 +33,24 @@ use crate::schema::types::SchemaDescPtr;
 #[derive(Default, Debug, Clone)]
 pub struct ParquetMetaDataOptions {
     schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,

Review Comment:
   It took me a little while to grok how encoding_stats_as_mask and skip_encoding_stats were related. But now I see they are mutually exclusive
   
   I think maybe creating a enum rather than Option / Option /etc would be clearer to me but since it is an implementation detail this is also find



##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,
+    // The outer option acts as a global boolean, so if `skip_encoding_stats.is_some()`
+    // is `true` then we're at least skipping some stats. The inner `Option` is a keep
+    // list of column indicies to decode.
+    skip_encoding_stats: Option<Option<Arc<HashSet<usize>>>>,

Review Comment:
   Maybe a bitmask would be the better (but that can be a subsequent PR perhaps)



##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,11 +70,70 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
-    pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
-        self
+    // with_schema
+    add_mutator!(schema, SchemaDescPtr);
+
+    /// Returns whether to present the `encoding_stats` field of the `ColumnMetaData` as a
+    /// bitmask.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for an explanation of why this
+    /// might be desirable.
+    ///
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn encoding_stats_as_mask(&self) -> bool {
+        self.encoding_stats_as_mask
+    }
+
+    /// Convert `encoding_stats` from a vector of [`PageEncodingStats`] to a bitmask. This can
+    /// speed up metadata decoding while still enabling some use cases served by the full stats.
+    ///
+    /// See [`ColumnChunkMetaData::page_encoding_stats_mask`] for more information.
+    ///
+    /// [`PageEncodingStats`]: crate::file::metadata::PageEncodingStats
+    /// [`ColumnChunkMetaData::page_encoding_stats_mask`]:
+    /// crate::file::metadata::ColumnChunkMetaData::page_encoding_stats_mask
+    pub fn set_encoding_stats_as_mask(&mut self, val: bool) {
+        self.encoding_stats_as_mask = val;
     }
+
+    // with_encoding_stats_as_mask
+    add_mutator!(encoding_stats_as_mask, bool);

Review Comment:
   > Now that I've done the macro, it saves all of 3 lines per instance. I'm fine with doing away with it.
   
   I thought it was pretty clear



##########
parquet/src/file/metadata/mod.rs:
##########
@@ -1274,7 +1321,13 @@ impl ColumnChunkMetaDataBuilder {
 
     /// Sets page encoding stats for this column chunk.
     pub fn set_page_encoding_stats(mut self, value: Vec<PageEncodingStats>) -> Self {
-        self.0.encoding_stats = Some(value);
+        self.0.encoding_stats = Some(ParquetPageEncodingStats::Full(value));

Review Comment:
   It might be nice here in the comments to call out that setting the stats will override and mask that was set, and vice versa.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2534913853


##########
parquet/src/file/metadata/options.rs:
##########
@@ -0,0 +1,191 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Options used to control metadata parsing
+
+use paste::paste;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+use crate::schema::types::SchemaDescPtr;
+
+/// Options that can be set to control what parts of the Parquet file footer
+/// metadata will be decoded and made present in the [`ParquetMetaData`] returned
+/// by [`ParquetMetaDataReader`] and [`ParquetMetaDataPushDecoder`].
+///
+/// [`ParquetMetaData`]: crate::file::metadata::ParquetMetaData
+/// [`ParquetMetaDataReader`]: crate::file::metadata::ParquetMetaDataReader
+/// [`ParquetMetaDataPushDecoder`]: crate::file::metadata::ParquetMetaDataPushDecoder
+#[derive(Default, Debug, Clone)]
+pub struct ParquetMetaDataOptions {
+    schema_descr: Option<SchemaDescPtr>,
+    encoding_stats_as_mask: bool,

Review Comment:
   Filed #8859



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3542499595

   > Given this observation, what do you think about removing the `skip_encoding_stats` option? If it makes the API more complicated, and doesn't make decoding faster, why are we adding it?
   
   Well, there's a couple things coming up. I'm working on speeding up the skipping code, and when we have the skip index this will be even faster. There are also other stats to skip in there (chunk `Statistics`, size stats, geo stats, bloom filter pointers). We could have a single option to skip all of them, but I can see wanting to enable some and not others depending on the use case. Filtering on a sorted column would want the chunk stats, filtering on unsorted might want the bloom filter but not other stats. If I want a size estimate for planning purposes but don't plan on filtering I would want size stats and nothing else. I think we should support all of these. I can see wanting different options for different columns in a single query.
   
   But I can also see saying if the stats are enabling page pruning, the cost savings from the pruning should outweigh the cost of decoding the stats that enable that pruning, so don't worry so much and keep this simple for now. We can make it more fine grained later if need be.
   
   
   
   
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#discussion_r2538938642


##########
parquet/src/file/metadata/options.rs:
##########
@@ -48,9 +98,79 @@ impl ParquetMetaDataOptions {
         self.schema_descr = Some(val);
     }
 
-    /// Provide a schema to use when decoding the metadata. Returns `Self` for chaining.
+    /// Call [`Self::set_schema`] and return `Self` for chaining.
     pub fn with_schema(mut self, val: SchemaDescPtr) -> Self {
-        self.schema_descr = Some(val);
+        self.set_schema(val);
+        self
+    }
+
+    /// Returns whether to present the [`encoding_stats`] field of the Parquet `ColumnMetaData`
+    /// as a bitmask.

Review Comment:
   Done in https://github.com/apache/arrow-rs/pull/8797/commits/96753792588c4093f71ffe184ff3ad7acf8f3535



##########
parquet/src/file/metadata/options.rs:
##########
@@ -17,8 +17,53 @@
 
 //! Options used to control metadata parsing
 
+use std::collections::HashSet;
+use std::sync::Arc;
+
 use crate::schema::types::SchemaDescPtr;
 
+/// Enum to control decoding of some Parquet statistics fields.
+///
+/// # Example
+/// ```rust
+/// use parquet::file::metadata::ParquetStatisticsPolicy;
+/// use parquet::file::serialized_reader::ReadOptionsBuilder;
+/// use parquet::arrow::arrow_reader::ArrowReaderOptions;
+///
+/// // Set arrow options to skip encoding statistics for all columns.
+/// let options =
+///     ArrowReaderOptions::new().with_encoding_stats_policy(ParquetStatisticsPolicy::SkipAll);
+///
+/// // Set serialized reader options to decode encoding statistics for all columns.
+/// let options =
+///     ReadOptionsBuilder::new().with_encoding_stats_policy(ParquetStatisticsPolicy::KeepAll)
+///     .build();
+///
+/// // Set arrow options to skip encoding statistics for all columns, but to decode statistics
+/// // for columns 0 and 1.
+/// let options = ArrowReaderOptions::new()
+///     .with_encoding_stats_policy(ParquetStatisticsPolicy::skip_except(&[0, 1]));
+/// ```
+#[derive(Debug, Clone)]
+pub enum ParquetStatisticsPolicy {
+    /// Decode the relevant statistics for all columns.
+    KeepAll,
+    /// Skip decoding the relevant statistics for all columns.
+    SkipAll,
+    /// Skip decoding the relevant statistics for all columns not in the provided set
+    /// of column indices.
+    SkipExcept(HashSet<usize>),
+}
+
+impl ParquetStatisticsPolicy {
+    /// Create a `ParquetStatisticsPolicy` to skip all columns except those in `keep`.
+    pub fn skip_except(keep: &[usize]) -> Self {

Review Comment:
   Thanks for the help and patience 🙏. I've been wanting to get this right before forging ahead with other options.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add ability to skip or transform page encoding statistics in Parquet metadata [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8797:
URL: https://github.com/apache/arrow-rs/pull/8797#issuecomment-3552899564

   @alamb I think this can wait. Thanks!


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org