jecsand838 commented on code in PR #8349:
URL: https://github.com/apache/arrow-rs/pull/8349#discussion_r2365857938


##########
arrow-avro/src/reader/record.rs:
##########
@@ -214,6 +254,148 @@ struct EnumResolution {
     default_index: i32,
 }
 
+#[derive(Debug, Clone, Copy)]
+enum BranchDispatch {
+    NoMatch,
+    ToReader {
+        reader_idx: usize,
+        promotion: Promotion,
+    },
+}
+
+#[derive(Debug)]
+struct UnionResolution {
+    dispatch: Option<Arc<[BranchDispatch]>>,
+    kind: UnionResolvedKind,
+}
+
+#[derive(Debug)]
+enum UnionResolvedKind {
+    Both {
+        reader_type_codes: Arc<[i8]>,
+    },
+    ToSingle {
+        target: Box<Decoder>,
+    },
+    FromSingle {
+        reader_type_codes: Arc<[i8]>,
+        target_reader_index: usize,
+        promotion: Promotion,
+    },
+}
+
+#[derive(Debug, Default)]
+struct UnionResolutionBuilder {
+    fields: Option<UnionFields>,
+    resolved: Option<ResolvedUnion>,
+}
+
+impl UnionResolutionBuilder {
+    #[inline]
+    fn new() -> Self {
+        Self {
+            fields: None,
+            resolved: None,
+        }
+    }
+
+    #[inline]
+    fn with_fields(mut self, fields: UnionFields) -> Self {
+        self.fields = Some(fields);
+        self
+    }
+
+    #[inline]
+    fn with_resolved_union(mut self, resolved_union: &ResolvedUnion) -> Self {
+        self.resolved = Some(resolved_union.clone());

Review Comment:
   Actually I think you're onto something. Let me experiment with a few things 
tonight. We should be able to remove this `clone`.



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

Reply via email to