sdd commented on code in PR #323:
URL: https://github.com/apache/iceberg-rust/pull/323#discussion_r1580049448


##########
crates/iceberg/src/scan.rs:
##########
@@ -158,8 +196,24 @@ impl TableScan {
             .await?;
 
             // Generate data file stream
-            let mut entries = iter(manifest_list.entries());
-            while let Some(entry) = entries.next().await {
+            for entry in manifest_list.entries() {
+                // If this scan has a filter, check the partition evaluator 
cache for an existing
+                // PartitionEvaluator that matches this manifest's partition 
spec ID.
+                // Use one from the cache if there is one. If not, create one, 
put it in
+                // the cache, and take a reference to it.
+                #[allow(clippy::map_entry)]
+                if let Some(filter) = filter.as_ref() {
+                    if 
!manifest_evaluator_cache.contains_key(&entry.partition_spec_id) {

Review Comment:
   I also prefer the entry API, but `Self::create_manifest_evaluator` returns a 
`Result<ManifestEvaluator>` rather than a `ManifestEvaluator`. The `?` operator 
can't be used inside the closure passed to the Entry API's 
[or_insert_with_key](https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_insert_with_key)
 method, and this was the least ugly way I found of handling that. If you know 
of a nice way of using the `or_insert_with_key` with en entry_generating 
function that returns a `Result`, please share! :-) 



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