wzx140 commented on code in PR #11764:
URL: https://github.com/apache/iceberg/pull/11764#discussion_r1885468839


##########
api/src/main/java/org/apache/iceberg/types/Types.java:
##########
@@ -824,7 +827,10 @@ public boolean equals(Object o) {
 
     @Override
     public int hashCode() {
-      return Objects.hash(NestedField.class, Arrays.hashCode(fields));
+      if (hashCode == NO_HASHCODE) {
+        hashCode = Objects.hash(NestedField.class, Arrays.hashCode(fields));
+      }
+      return hashCode;

Review Comment:
   In this scenario, there is no multi-threaded access, but the method 
`structType.hashCode` might be accessed by multiple threads in other contexts. 
   
   I think the main purpose of this cache is to reduce a significant amount of 
redundant computation. Introducing additional complexity to completely avoid 
redundant computation might not be necessary, as even with multi-threaded 
access, the redundant computation would only occur a few times (up to the 
number of threads), which should be negligible.



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