cecemei commented on code in PR #18541:
URL: https://github.com/apache/druid/pull/18541#discussion_r2408975841


##########
processing/src/main/java/org/apache/druid/segment/nested/StructuredData.java:
##########
@@ -133,16 +135,28 @@ private Number asNumber()
     return (Number) value;
   }
 
+  @SuppressWarnings("ReturnValueIgnored")
+  public int getSizeEstimate()
+  {
+    if (sizeEstimate < 0) {
+      hash.getAsLong(); // trigger hash computation which also sets 
sizeEstimate
+    }
+    Preconditions.checkState(sizeEstimate >= 0, "sizeEstimate not 
initialized");
+    return sizeEstimate;
+  }
+
   @Override
   public int compareTo(StructuredData o)
   {
-    if (this.equals(o)) {
+    if (this == o) {

Review Comment:
   I thought this equal/compareTo is strange since it's not consistent. Equal 
doesn't handle nested array equal, if there's `Object[]` in a nested field, 
they don't equal, even though the compareTo returns equal since they're still 
the same data. But I've only seen places using compareTo so it might be fine. 
   
   Anyway I reverted the compareTo/equals part of change, removed the original 
hashCode method since it doesn't seem to make sense to keep two hash method. My 
fix is also not a perfect solution, since: 1. it sort of require object to be 
serialized even for the equal check now, 2. it still have the issue of hash 
collision. 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to