Paul Rogers created IMPALA-7711:
-----------------------------------

             Summary: Hash code improvements for CatalogdMetaProvider
                 Key: IMPALA-7711
                 URL: https://issues.apache.org/jira/browse/IMPALA-7711
             Project: IMPALA
          Issue Type: Improvement
    Affects Versions: Impala 3.2.0
            Reporter: Paul Rogers


Consider the classes nested within {{CatalogdMetaProvider}}. A number of 
hashing-related items could use attention.

First, the code uses {{com.google.common.base.Objects}}, however, the Guava 
docs state:

{quote}
Note for Java 7 and later: This method should be treated as deprecated; use 
Objects.hash(java.lang.Object...) instead.
{quote}

Second, hash codes are combined incorrectly. Consider:

{code:java}
    public int hashCode() {
      return Objects.hashCode(super.hashCode(), version_);
    }
{code}

Note that this takes the hash code from the super can hashes it again in the 
subclass. The Java library combines hash codes as follows:

{code:java}
    public int hashCode() {
      return super.hashCode() * 31 + Objects.hashCode(version_);
    }
{code}

Could find no reference to a standard JDK or Guava function that combines hash 
codes, perhaps we should create one.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to