jonathanc-n commented on code in PR #963: URL: https://github.com/apache/iceberg-rust/pull/963#discussion_r1955029747
########## crates/iceberg/src/expr/visitors/strict_metrics_evaluator.rs: ########## @@ -0,0 +1,1854 @@ +// 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. + +use fnv::FnvHashSet; + +use crate::expr::visitors::bound_predicate_visitor::{visit, BoundPredicateVisitor}; +use crate::expr::{BoundPredicate, BoundReference}; +use crate::spec::{DataFile, Datum, Schema}; +use crate::Result; + +#[allow(dead_code)] +const ROWS_MUST_MATCH: Result<bool> = Ok(true); +#[allow(dead_code)] +const ROWS_MIGHT_NOT_MATCH: Result<bool> = Ok(false); + +#[allow(dead_code)] +pub(crate) struct StrictMetricsEvaluator<'a> { + data_file: &'a DataFile, + schema: Schema, +} + +impl<'a> StrictMetricsEvaluator<'a> { + #[allow(dead_code)] + fn new(data_file: &'a DataFile, schema: Schema) -> Self { + StrictMetricsEvaluator { data_file, schema } + } + + /// Evaluate this `StrictMetricsEvaluator`'s filter predicate against the + /// provided [`DataFile`]'s metrics. Used by [`TableScan`] to + /// see if this `DataFile` contains data that could match + /// the scan's filter. + #[allow(dead_code)] + pub(crate) fn eval( + filter: &'a BoundPredicate, + data_file: &'a DataFile, + schema: Schema, + ) -> crate::Result<bool> { + if data_file.record_count == 0 { + return ROWS_MUST_MATCH; + } + + let mut evaluator = Self::new(data_file, schema); Review Comment: This is mutable because the bound predicate visitor takes in a mutable reference of the evaluator. in rust you have to declare as mutable as well as pass it in with `mut` to let the compiler know the function can modify -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org