adriangb commented on code in PR #11330:
URL: https://github.com/apache/arrow-rs/pull/11330#discussion_r4171080883


##########
parquet/src/arrow/push_decoder/reader_builder/stages.rs:
##########
@@ -0,0 +1,91 @@
+// 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.
+
+//! [`StageSchedule`]: what each decoding stage of a row group fetches.
+
+use crate::arrow::ProjectionMask;
+
+/// A decoding stage of a row group.
+///
+/// The decoder evaluates the [`RowFilter`] predicates in order, then decodes
+/// the output columns.
+///
+/// [`RowFilter`]: crate::arrow::arrow_reader::RowFilter
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub(crate) enum Stage {
+    /// Evaluation of the predicate at this index in the `RowFilter`.
+    Predicate(usize),
+    /// Decoding of the output columns.
+    Projection,
+}
+
+/// The columns that each decoding stage of a row group fetches.
+///
+/// A stage does not fetch a column that an earlier stage of the same row
+/// group read (see [`columns_to_fetch`]).
+///
+/// [`columns_to_fetch`]: crate::arrow::in_memory_row_group::columns_to_fetch
+#[derive(Debug)]
+pub(crate) struct StageSchedule {
+    /// Columns in the output.
+    projection: ProjectionMask,
+    /// Columns each predicate reads, in evaluation order.
+    predicate_projections: Vec<ProjectionMask>,
+    /// Predicate columns whose decoded values are cached for the output, if
+    /// any.
+    cache_projection: Option<ProjectionMask>,
+}
+
+/// What one decoding stage fetches.
+#[derive(Debug, Clone, Copy)]
+pub(crate) struct StageFetch<'a> {

Review Comment:
   Yeah, fair. As is, it's overkill. The extra bits are for the planner in 
#10555, which needs to [walk every stage in 
order](https://github.com/apache/arrow-rs/blob/ec3b0d2c50ee1d475fc773b1bdb71752854669cc/parquet/src/arrow/push_decoder/scan_plan/mod.rs#L380)
 and [pick the right selection per 
column](https://github.com/apache/arrow-rs/blob/ec3b0d2c50ee1d475fc773b1bdb71752854669cc/parquet/src/arrow/push_decoder/scan_plan/mod.rs#L681)
 the same way the decoder does. Keeping the rule in one spot means the two 
can't drift. I'd suggest we accept the extra abstraction here (it's a refactor 
with no behavior change) since #10555 uses it right away. If #10555 doesn't 
merge, I'll revert 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to