Fokko commented on code in PR #335:
URL: https://github.com/apache/iceberg-rust/pull/335#discussion_r1568751884


##########
crates/iceberg/src/expr/visitors/inclusive_projection.rs:
##########
@@ -0,0 +1,371 @@
+// 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 crate::expr::visitors::bound_predicate_visitor::{visit, 
BoundPredicateVisitor};
+use crate::expr::{BoundPredicate, BoundReference, Predicate};
+use crate::spec::{Datum, PartitionField, PartitionSpecRef};
+use crate::Error;
+use fnv::FnvHashSet;
+use std::collections::HashMap;
+use std::ops::Not;
+
+pub(crate) struct InclusiveProjection {
+    partition_spec: PartitionSpecRef,
+    cached_parts: HashMap<i32, Vec<PartitionField>>,
+}
+
+impl InclusiveProjection {
+    pub(crate) fn new(partition_spec: PartitionSpecRef) -> Self {
+        Self {
+            partition_spec,
+            cached_parts: HashMap::new(),
+        }
+    }
+
+    fn get_parts_for_field_id(&mut self, field_id: i32) -> 
&Vec<PartitionField> {
+        if let std::collections::hash_map::Entry::Vacant(e) = 
self.cached_parts.entry(field_id) {
+            let mut parts: Vec<PartitionField> = vec![];
+            for partition_spec_field in &self.partition_spec.fields {
+                if partition_spec_field.source_id == field_id {
+                    parts.push(partition_spec_field.clone())
+                }
+            }
+
+            e.insert(parts);
+        }
+
+        &self.cached_parts[&field_id]
+    }
+
+    pub(crate) fn project(&mut self, predicate: &BoundPredicate) -> 
crate::Result<Predicate> {

Review Comment:
   > However, this implies that the InclusiveProjection operates on Predicate 
rather than BoundPredicate. This means we have to not only apply rewrite_not 
but also bind before we call visit here.
   
   InclusiveProjection runs on a BoundPredicate. So the order is: rewrite-not, 
bind, and then evaluate.



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

Reply via email to