liamzwbao commented on code in PR #8196:
URL: https://github.com/apache/arrow-rs/pull/8196#discussion_r2292454215


##########
parquet-variant-compute/src/cast_to_variant.rs:
##########
@@ -544,8 +530,41 @@ pub fn cast_to_variant(input: &dyn Array) -> 
Result<VariantArray, ArrowError> {
     Ok(builder.build())
 }
 
-/// Generic function to process run-end encoded arrays
-fn process_run_end_encoded<R: RunEndIndexType>(
+/// Convert union arrays
+fn convert_union(
+    fields: &UnionFields,
+    input: &dyn Array,
+    builder: &mut VariantArrayBuilder,
+) -> Result<(), ArrowError> {
+    let union_array = input.as_union();
+
+    // Convert each child array to variant arrays
+    let mut child_variant_arrays = HashMap::new();
+    for (type_id, _) in fields.iter() {

Review Comment:
   Do you mean using one loop instead of two? That way we will compute the 
child array of each type_id on demand. 
   
   But IIUC, we will use all the child arrays anyway if it's a valid union, and 
I think precomute all the child arrays may benefit the lookup in the second 
loop.



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to