liurenjie1024 commented on code in PR #323: URL: https://github.com/apache/iceberg-rust/pull/323#discussion_r1579248989
########## 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: TBH I prefer the entry api which make code more concise, but this is not a blocker. ########## crates/iceberg/src/scan.rs: ########## @@ -186,6 +240,25 @@ impl TableScan { .boxed()) } + fn create_manifest_evaluator( + id: i32, + schema: SchemaRef, + table_metadata: Arc<TableMetadata>, + case_sensitive: bool, + filter: &Predicate, + ) -> crate::Result<ManifestEvaluator> { + let bound_predicate = filter.bind(schema.clone(), case_sensitive).unwrap(); Review Comment: ```suggestion let bound_predicate = filter.bind(schema.clone(), case_sensitive)?; ``` We should not panic here. ########## crates/iceberg/src/scan.rs: ########## @@ -186,6 +240,25 @@ impl TableScan { .boxed()) } + fn create_manifest_evaluator( + id: i32, + schema: SchemaRef, + table_metadata: Arc<TableMetadata>, + case_sensitive: bool, + filter: &Predicate, + ) -> crate::Result<ManifestEvaluator> { + let bound_predicate = filter.bind(schema.clone(), case_sensitive).unwrap(); + + let partition_spec = table_metadata.partition_spec_by_id(id).unwrap(); Review Comment: ```suggestion let partition_spec = table_metadata.partition_spec_by_id(id)?; ``` Why panic here? -- 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