Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
Impala 3.2.0
-
None
-
None
-
ghx-label-4
Description
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:
Note for Java 7 and later: This method should be treated as deprecated; use Objects.hash(java.lang.Object...) instead.
Second, hash codes are combined incorrectly. Consider:
public int hashCode() { return Objects.hashCode(super.hashCode(), version_); }
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:
public int hashCode() { return super.hashCode() * 31 + Objects.hashCode(version_); }
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:
private static class DbCacheKey { ... public int hashCode() { return Objects.hash(getClass(), dbName_, type_); }
No need to include the class if either a) no subclasses exist, or b) subclasses include attributes not in the base class.