etseidl commented on code in PR #11157:
URL: https://github.com/apache/arrow-rs/pull/11157#discussion_r4088366080


##########
parquet/src/file/metadata/reader.rs:
##########
@@ -104,6 +107,114 @@ impl From<bool> for PageIndexPolicy {
     }
 }
 
+/// Struct to specify column chunks for which metadata is required.
+///
+/// Column chunks are identified by row group index and column index. This 
struct
+/// allows for specifying vertical slices of column chunk data (via 
[`Self::columns`]),
+/// horizontal slices (via [`Self::row_groups`]), or the intersection of the 
two
+/// (via [`Self::row_groups_and_columns`]).
+///
+/// At present this is only used to select elements of the [Page Index] for 
decoding.
+///
+/// # Examples
+///
+/// To select columns 0 and 1 from all row groups:
+/// ```rust
+/// # use parquet::file::metadata::ColumnChunkMask;
+/// let mask = ColumnChunkMask::columns([0, 1]);
+/// ```
+///
+/// To select all columns from row group 2:
+/// ```rust
+/// # use parquet::file::metadata::ColumnChunkMask;
+/// let mask = ColumnChunkMask::row_groups([2]);
+/// ```
+///
+/// To select columns 1 and 3 from row group 0:
+/// ```rust
+/// # use parquet::file::metadata::ColumnChunkMask;
+/// let mask = ColumnChunkMask::row_groups_and_columns([0], [1, 3]);
+/// ```
+///
+/// [Page Index]: https://parquet.apache.org/docs/file-format/pageindex/
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
+pub struct ColumnChunkMask {
+    // using i32 because that's how thrift vectors are sized
+    row_groups: Option<Arc<BTreeSet<i32>>>,
+    columns: Option<Arc<BTreeSet<i32>>>,
+}
+
+impl ColumnChunkMask {
+    /// Select all row groups and columns.
+    pub fn all() -> Self {
+        Self::default()
+    }
+
+    /// Select only the listed columns.
+    ///
+    /// Any indices in `columns` that are less than zero will be ignored. 
Passing an empty
+    /// set is treated the same as selecting all columns.
+    pub fn columns(columns: impl IntoIterator<Item = i32>) -> Self {

Review Comment:
   Well, the issue is parquet doesn't allow arrays to be sized beyond 
`i32::MAX`. It was probably a mistake to use `usize` elsewhere, but I guess 
that horse is out of the barn. I'll rethink this.



-- 
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]

Reply via email to