[
https://issues.apache.org/jira/browse/IMPALA-7711?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tim Armstrong updated IMPALA-7711:
----------------------------------
Component/s: Catalog
> Hash code improvements for CatalogdMetaProvider
> -----------------------------------------------
>
> Key: IMPALA-7711
> URL: https://issues.apache.org/jira/browse/IMPALA-7711
> Project: IMPALA
> Issue Type: Improvement
> Components: Catalog
> Affects Versions: Impala 3.2.0
> Reporter: Paul Rogers
> Priority: Minor
>
> 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.
> Finally, some methods include the class when computing the hash, but no
> subclasses exist:
> {code:java}
> private static class DbCacheKey {
> ...
> public int hashCode() {
> return Objects.hash(getClass(), dbName_, type_);
> }
> {code}
> No need to include the class if either a) no subclasses exist, or b)
> subclasses include attributes not in the base class.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]