ZENOTME commented on code in PR #731:
URL: https://github.com/apache/iceberg-rust/pull/731#discussion_r1899342562


##########
crates/iceberg/src/spec/schema.rs:
##########
@@ -1132,6 +1132,213 @@ impl ReassignFieldIds {
     }
 }
 
+/// A post order schema visitor with partner.
+///
+/// For order of methods called, please refer to [`visit_schema_with_partner`].
+pub trait SchemaWithPartnerVisitor<P> {
+    /// Return type of this visitor.
+    type T;
+
+    /// Called before struct field.
+    fn before_struct_field(&mut self, _field: &NestedFieldRef, _partner: &P) 
-> Result<()> {
+        Ok(())
+    }
+    /// Called after struct field.
+    fn after_struct_field(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+    /// Called before list field.
+    fn before_list_element(&mut self, _field: &NestedFieldRef, _partner: &P) 
-> Result<()> {
+        Ok(())
+    }
+    /// Called after list field.
+    fn after_list_element(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+    /// Called before map key field.
+    fn before_map_key(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+    /// Called after map key field.
+    fn after_map_key(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+    /// Called before map value field.
+    fn before_map_value(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+    /// Called after map value field.
+    fn after_map_value(&mut self, _field: &NestedFieldRef, _partner: &P) -> 
Result<()> {
+        Ok(())
+    }
+
+    /// Called before every type, if this function return `Some`, the 
following visiting will be skipped.
+    /// This function used to implement early return.
+    fn visit_type_before(&mut self, _ty: &Type, _partner: &P) -> 
Result<Option<Self::T>> {
+        return Ok(None);
+    }
+
+    /// Called after schema's type visited.
+    fn schema(&mut self, schema: &Schema, partner: &P, value: Self::T) -> 
Result<Self::T>;
+    /// Called after struct's field type visited.
+    fn field(&mut self, field: &NestedFieldRef, partner: &P, value: Self::T) 
-> Result<Self::T>;
+    /// Called after struct's fields visited.
+    fn r#struct(
+        &mut self,
+        r#struct: &StructType,
+        partner: &P,
+        results: Vec<Self::T>,
+    ) -> Result<Self::T>;
+    /// Called after list fields visited.
+    fn list(&mut self, list: &ListType, partner: &P, value: Vec<Self::T>) -> 
Result<Self::T>;

Review Comment:
   In the visit fucnton, this function will be called after visit all child 
column. So the `Vec` means the result return by all child columns, and then 
this function may combine this result.



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