Xuanwo commented on code in PR #25:
URL: https://github.com/apache/iceberg-rust/pull/25#discussion_r1288064292


##########
crates/iceberg/src/spec/schema.rs:
##########
@@ -84,28 +206,853 @@ impl Schema {
     pub fn schema_id(&self) -> i32 {
         self.schema_id
     }
+
+    /// Returns [`r#struct`].
+    #[inline]
+    pub fn as_struct(&self) -> &StructType {
+        &self.r#struct
+    }
+
+    /// Get field id by full name.
+    pub fn field_id_by_name(&self, name: &str) -> Option<i32> {
+        self.name_to_id.get(name).cloned()

Review Comment:
   `self.name_to_id.get()` will return an `Option<&i32>` here so it's better to 
perform a `clone` here to make sure users can use `i32` directly instead of 
`*v` by hand. 
   
   - It's a zero cost operation: so we don't need to care about it's perf, even 
in hot path.
   - It's already immutable now: users can't change the value in our 
`name_to_id`.
   
   > I'm guessing we can use `copied()` here (alought it doesn't have real 
meanings).
    



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