liyafan82 opened a new pull request #1839: [CALCITE-3836] The hash codes of 
RelNodes are unreliable
URL: https://github.com/apache/calcite/pull/1839
 
 
   For all sub-classes of AbstractRelNode, the hashCode methods depend on 
AbstractRelNode#hashCode, because it is declared as final.
   
   AbstractRelNode#hashCode depends on Object#hashCode, which is called 
identify hash code. The details of identity hash code depends on the specific 
JVM implementation. For many JVMs, the implementation is based on the object 
address in the memory. The problem is that, the address of an object may change 
in a JVM, due to GC, memory contraction, etc. So the hash code of an object may 
change, even if the content of the object is not changed (This can be confirmed 
from the JavaDoc of Object#hashCode).
   
   This problem may cause severe issues that are hard to diagnose and debug, 
like an object is in the hash table, but cannot be retrieved; duplicate objects 
in the hash map, etc.
   
   To solve the problem, we compute a hash code solely from the node id. This 
is consistent with the previous semantics, and solves the above problem.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to