andygrove commented on code in PR #3755:
URL: https://github.com/apache/datafusion-comet/pull/3755#discussion_r2971752181


##########
native/core/src/parquet/schema_adapter.rs:
##########
@@ -111,35 +112,41 @@ impl PhysicalExprAdapterFactory for 
SparkPhysicalExprAdapterFactory {
         // to the original physical names. This is necessary because 
downstream code
         // (reassign_expr_columns) looks up columns by name in the actual 
stream
         // schema, which uses the original physical file column names.
-        let (adapted_physical_schema, logical_to_physical_names) =
-            if !self.parquet_options.case_sensitive {
-                let logical_to_physical: HashMap<String, String> = 
logical_file_schema
-                    .fields()
-                    .iter()
-                    .filter_map(|logical_field| {
-                        physical_file_schema
-                            .fields()
-                            .iter()
-                            .find(|pf| {
-                                pf.name().to_lowercase() == 
logical_field.name().to_lowercase()
-                                    && pf.name() != logical_field.name()
-                            })
-                            .map(|pf| (logical_field.name().clone(), 
pf.name().clone()))
-                    })
-                    .collect();
-                let remapped =
-                    remap_physical_schema_names(&logical_file_schema, 
&physical_file_schema);
-                (
-                    remapped,
-                    if logical_to_physical.is_empty() {
-                        None
-                    } else {
-                        Some(logical_to_physical)
-                    },
-                )
-            } else {
-                (Arc::clone(&physical_file_schema), None)
-            };
+        let (adapted_physical_schema, logical_to_physical_names) = if !self
+            .parquet_options
+            .case_sensitive
+        {
+            // Pre-compute lowercased physical field names to avoid repeated
+            // to_lowercase() calls in the O(n*m) matching loop.

Review Comment:
   Is there any chance we could use `eq_ignore_ascii_case` to avoid allocating 
the lower case strings?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to