calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [2/3] calcite git commit: [CALCITE-1071] Improve hash functions
Date Wed, 03 Feb 2016 05:01:37 GMT
[CALCITE-1071] Improve hash functions


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/ecf4d6dc
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/ecf4d6dc
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/ecf4d6dc

Branch: refs/heads/master
Commit: ecf4d6dcb4b6fdc40828d0c853ae10abc0550a76
Parents: 7b944ad
Author: Julian Hyde <jhyde@apache.org>
Authored: Tue Feb 2 15:01:17 2016 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Tue Feb 2 15:36:00 2016 -0800

----------------------------------------------------------------------
 .../calcite/avatica/AvaticaParameter.java       |  14 +-
 .../apache/calcite/avatica/ColumnMetaData.java  | 259 +++----------------
 .../avatica/ConnectionPropertiesImpl.java       |  76 +-----
 .../java/org/apache/calcite/avatica/Meta.java   | 254 ++++++------------
 .../org/apache/calcite/avatica/QueryState.java  |  39 +--
 .../calcite/avatica/util/TimeUnitRange.java     |  16 +-
 .../calcite/interpreter/TableScanNode.java      |   4 +-
 .../org/apache/calcite/jdbc/JavaRecordType.java |   3 +-
 .../org/apache/calcite/materialize/Lattice.java |   6 +-
 .../materialize/MaterializationActor.java       |   3 +-
 .../org/apache/calcite/materialize/TileKey.java |   5 +-
 .../org/apache/calcite/plan/RelOptCostImpl.java |   4 +-
 .../apache/calcite/plan/RelOptRuleOperand.java  |   9 +-
 .../calcite/plan/SubstitutionVisitor.java       |  18 +-
 .../calcite/plan/volcano/VolcanoCost.java       |   5 +-
 .../apache/calcite/rel/RelDistributions.java    |   3 +-
 .../apache/calcite/rel/RelFieldCollation.java   |  26 +-
 .../apache/calcite/rel/core/AggregateCall.java  |   6 +-
 .../calcite/rel/logical/LogicalWindow.java      |  12 +-
 .../java/org/apache/calcite/rex/RexLiteral.java |   3 +-
 .../org/apache/calcite/rex/RexLocalRef.java     |   6 +-
 .../org/apache/calcite/runtime/Utilities.java   |  63 ++++-
 .../org/apache/calcite/sql/SqlDataTypeSpec.java |   8 +-
 .../apache/calcite/sql/SqlIntervalLiteral.java  |   6 +-
 .../java/org/apache/calcite/sql/SqlLiteral.java |   3 +-
 .../org/apache/calcite/sql/SqlOperator.java     |   6 +-
 .../apache/calcite/sql/fun/SqlCastFunction.java |  17 +-
 .../apache/calcite/sql/parser/SqlParserPos.java |  23 +-
 .../org/apache/calcite/sql/util/SqlString.java  |   3 +-
 .../calcite/sql/validate/SqlMonikerImpl.java    |   3 +-
 .../apache/calcite/sql2rel/RelDecorrelator.java |   5 +-
 .../java/org/apache/calcite/util/NlsString.java |  14 +-
 .../main/java/org/apache/calcite/util/Pair.java |  28 +-
 .../main/java/org/apache/calcite/util/Util.java |  32 +--
 .../apache/calcite/util/mapping/IntPair.java    |   4 +-
 .../org/apache/calcite/test/CalciteAssert.java  |   7 +-
 .../java/org/apache/calcite/util/UtilTest.java  |  12 +-
 .../org/apache/calcite/linq4j/GroupingImpl.java |  11 +-
 .../calcite/linq4j/tree/AbstractNode.java       |   5 +-
 .../linq4j/tree/ArrayLengthRecordField.java     |   5 +-
 .../calcite/linq4j/tree/BinaryExpression.java   |   7 +-
 .../calcite/linq4j/tree/BlockStatement.java     |   6 +-
 .../apache/calcite/linq4j/tree/CatchBlock.java  |   6 +-
 .../calcite/linq4j/tree/ClassDeclaration.java   |  11 +-
 .../linq4j/tree/ConditionalExpression.java      |   5 +-
 .../linq4j/tree/ConditionalStatement.java       |   5 +-
 .../calcite/linq4j/tree/ConstantExpression.java |   5 +-
 .../linq4j/tree/ConstructorDeclaration.java     |   6 +-
 .../linq4j/tree/DeclarationStatement.java       |   7 +-
 .../calcite/linq4j/tree/FieldDeclaration.java   |   6 +-
 .../calcite/linq4j/tree/ForStatement.java       |   8 +-
 .../calcite/linq4j/tree/FunctionExpression.java |   6 +-
 .../calcite/linq4j/tree/GotoStatement.java      |   8 +-
 .../calcite/linq4j/tree/IndexExpression.java    |   6 +-
 .../calcite/linq4j/tree/LabelStatement.java     |   6 +-
 .../apache/calcite/linq4j/tree/LabelTarget.java |   4 +-
 .../calcite/linq4j/tree/MemberExpression.java   |   6 +-
 .../linq4j/tree/MethodCallExpression.java       |  12 +-
 .../calcite/linq4j/tree/MethodDeclaration.java  |   8 +-
 .../calcite/linq4j/tree/NewArrayExpression.java |   6 +-
 .../calcite/linq4j/tree/NewExpression.java      |   8 +-
 .../calcite/linq4j/tree/TernaryExpression.java  |   7 +-
 .../calcite/linq4j/tree/ThrowStatement.java     |   6 +-
 .../calcite/linq4j/tree/TryStatement.java       |  15 +-
 .../linq4j/tree/TypeBinaryExpression.java       |   6 +-
 .../calcite/linq4j/tree/UnaryExpression.java    |   5 +-
 .../calcite/linq4j/tree/WhileStatement.java     |   7 +-
 67 files changed, 424 insertions(+), 790 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
index 0f0b473..3c5a9ab 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
@@ -21,6 +21,8 @@ import org.apache.calcite.avatica.proto.Common;
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
+import java.util.Objects;
+
 /**
  * Metadata for a parameter.
  */
@@ -72,16 +74,8 @@ public class AvaticaParameter {
   }
 
   @Override public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((className == null) ? 0 : className.hashCode());
-    result = prime * result + ((name == null) ? 0 : name.hashCode());
-    result = prime * result + parameterType;
-    result = prime * result + precision;
-    result = prime * result + scale;
-    result = prime * result + (signed ? 1231 : 1237);
-    result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
-    return result;
+    return Objects.hash(className, name, parameterType, precision, scale,
+        signed, typeName);
   }
 
   @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java b/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java
index 170c310..60e744d 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java
@@ -214,150 +214,35 @@ public class ColumnMetaData {
   }
 
   @Override public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + (autoIncrement ? 1231 : 1237);
-    result = prime * result + (caseSensitive ? 1231 : 1237);
-    result = prime * result + ((catalogName == null) ? 0 : catalogName.hashCode());
-    result = prime * result + ((columnClassName == null) ? 0 : columnClassName.hashCode());
-    result = prime * result + ((columnName == null) ? 0 : columnName.hashCode());
-    result = prime * result + (currency ? 1231 : 1237);
-    result = prime * result + (definitelyWritable ? 1231 : 1237);
-    result = prime * result + displaySize;
-    result = prime * result + ((label == null) ? 0 : label.hashCode());
-    result = prime * result + nullable;
-    result = prime * result + ordinal;
-    result = prime * result + precision;
-    result = prime * result + (readOnly ? 1231 : 1237);
-    result = prime * result + scale;
-    result = prime * result + ((schemaName == null) ? 0 : schemaName.hashCode());
-    result = prime * result + (searchable ? 1231 : 1237);
-    result = prime * result + (signed ? 1231 : 1237);
-    result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
-    result = prime * result + ((type == null) ? 0 : type.hashCode());
-    result = prime * result + (writable ? 1231 : 1237);
-    return result;
+    return Objects.hash(autoIncrement, caseSensitive, catalogName,
+        columnClassName, columnName, currency, definitelyWritable, displaySize,
+        label, nullable, ordinal, precision, readOnly, scale, schemaName,
+        searchable, signed, tableName, type, writable);
   }
 
-  @Override public boolean equals(Object obj) {
-    if (obj == this) {
-      return true;
-    }
-    if (obj instanceof ColumnMetaData) {
-      ColumnMetaData other = (ColumnMetaData) obj;
-
-      if (autoIncrement != other.autoIncrement) {
-        return false;
-      }
-
-      if (caseSensitive != other.caseSensitive) {
-        return false;
-      }
-
-      if (null == catalogName) {
-        if (null != other.catalogName) {
-          return false;
-        }
-      } else if (!catalogName.equals(other.catalogName)) {
-        return false;
-      }
-
-      if (null == columnClassName) {
-        if (null != other.columnClassName) {
-          return false;
-        }
-      } else if (!columnClassName.equals(other.columnClassName)) {
-        return false;
-      }
-
-      if (null == columnName) {
-        if (null != other.columnName) {
-          return false;
-        }
-      } else if (!columnName.equals(other.columnName)) {
-        return false;
-      }
-
-      if (currency != other.currency) {
-        return false;
-      }
-
-      if (definitelyWritable != other.definitelyWritable) {
-        return false;
-      }
-
-      if (displaySize != other.displaySize) {
-        return false;
-      }
-
-      if (null == label) {
-        if (null != other.label) {
-          return false;
-        }
-      } else if (!label.equals(other.label)) {
-        return false;
-      }
-
-      if (nullable != other.nullable) {
-        return false;
-      }
-
-      if (ordinal != other.ordinal) {
-        return false;
-      }
-
-      if (precision != other.precision) {
-        return false;
-      }
-
-      if (readOnly != other.readOnly) {
-        return false;
-      }
-
-      if (scale != other.scale) {
-        return false;
-      }
-
-      if (null == schemaName) {
-        if (null != other.schemaName) {
-          return false;
-        }
-      } else if (!schemaName.equals(other.schemaName)) {
-        return false;
-      }
-
-      if (searchable != other.searchable) {
-        return false;
-      }
-
-      if (signed != other.signed) {
-        return false;
-      }
-
-      if (null == tableName) {
-        if (null != other.tableName) {
-          return false;
-        }
-      } else if (!tableName.equals(other.tableName)) {
-        return false;
-      }
-
-      if (null == type) {
-        if (null != other.type) {
-          return false;
-        }
-      } else if (!type.equals(other.type)) {
-        return false;
-      }
-
-      if (writable != other.writable) {
-        return false;
-      }
-
-      return true;
-    }
-
-    return false;
+  @Override public boolean equals(Object o) {
+    return o == this
+        || o instanceof ColumnMetaData
+        && autoIncrement == ((ColumnMetaData) o).autoIncrement
+        && caseSensitive == ((ColumnMetaData) o).caseSensitive
+        && Objects.equals(catalogName, ((ColumnMetaData) o).catalogName)
+        && Objects.equals(columnClassName, ((ColumnMetaData) o).columnClassName)
+        && Objects.equals(columnName, ((ColumnMetaData) o).columnName)
+        && currency == ((ColumnMetaData) o).currency
+        && definitelyWritable == ((ColumnMetaData) o).definitelyWritable
+        && displaySize == ((ColumnMetaData) o).displaySize
+        && Objects.equals(label, ((ColumnMetaData) o).label)
+        && nullable == ((ColumnMetaData) o).nullable
+        && ordinal == ((ColumnMetaData) o).ordinal
+        && precision == ((ColumnMetaData) o).precision
+        && readOnly == ((ColumnMetaData) o).readOnly
+        && scale == ((ColumnMetaData) o).scale
+        && Objects.equals(schemaName, ((ColumnMetaData) o).schemaName)
+        && searchable == ((ColumnMetaData) o).searchable
+        && signed == ((ColumnMetaData) o).signed
+        && Objects.equals(tableName, ((ColumnMetaData) o).tableName)
+        && Objects.equals(type, ((ColumnMetaData) o).type)
+        && writable == ((ColumnMetaData) o).writable;
   }
 
   private static <T> T first(T t0, T t1) {
@@ -603,41 +488,15 @@ public class ColumnMetaData {
     }
 
     @Override public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + id;
-      result = prime * result + ((name == null) ? 0 : name.hashCode());
-      result = prime * result + ((rep == null) ? 0 : rep.hashCode());
-      return result;
+      return Objects.hash(id, name, rep);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (o instanceof AvaticaType) {
-        AvaticaType other = (AvaticaType) o;
-
-        if (id != other.id) {
-          return false;
-        }
-
-        if (name == null) {
-          if (other.name != null) {
-            return false;
-          }
-        } else if (!name.equals(other.name)) {
-          return false;
-        }
-
-        if (rep != other.rep) {
-          return false;
-        }
-
-        return true;
-      }
-
-      return false;
+      return o == this
+          || o instanceof AvaticaType
+          && id == ((AvaticaType) o).id
+          && Objects.equals(name, ((AvaticaType) o).name)
+          && rep == ((AvaticaType) o).rep;
     }
   }
 
@@ -674,30 +533,14 @@ public class ColumnMetaData {
     }
 
     @Override public int hashCode() {
-      return 31 * (super.hashCode() + (null == columns ? 0 : columns.hashCode()));
+      return Objects.hash(id, name, rep, columns);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (!super.equals(o)) {
-        return false;
-      }
-
-      if (o instanceof StructType) {
-        StructType other = (StructType) o;
-
-        if (null == columns) {
-          if (null != other.columns) {
-            return false;
-          }
-        }
-
-        return columns.equals(other.columns);
-      }
-
-      return false;
+      return o == this
+          || o instanceof StructType
+          && super.equals(o)
+          && Objects.equals(columns, ((StructType) o).columns);
     }
   }
 
@@ -724,30 +567,14 @@ public class ColumnMetaData {
     }
 
     @Override public int hashCode() {
-      return 31 * (super.hashCode() + (null == component ? 0 : component.hashCode()));
+      return Objects.hash(id, name, rep, component);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (!super.equals(o)) {
-        return false;
-      }
-
-      if (o instanceof ArrayType) {
-        ArrayType other = (ArrayType) o;
-
-        if (null == component) {
-          if (null != other.component) {
-            return false;
-          }
-        }
-
-        return component.equals(other.component);
-      }
-
-      return false;
+      return o == this
+          || o instanceof ArrayType
+          && super.equals(o)
+          && Objects.equals(component, ((ArrayType) o).component);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/ConnectionPropertiesImpl.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/ConnectionPropertiesImpl.java b/avatica/src/main/java/org/apache/calcite/avatica/ConnectionPropertiesImpl.java
index 4bef781..e4b01bc 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/ConnectionPropertiesImpl.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/ConnectionPropertiesImpl.java
@@ -25,6 +25,7 @@ import com.google.protobuf.Descriptors.Descriptor;
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Objects;
 
 /** Concrete implementation of {@link Meta.ConnectionProperties}. Provides additional state
  * tracking to enable {@code RemoteMeta} to lazily push changes up to a query server.
@@ -181,73 +182,20 @@ public class ConnectionPropertiesImpl implements Meta.ConnectionProperties {
   }
 
   @Override public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((autoCommit == null) ? 0 : autoCommit.hashCode());
-    result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
-    result = prime * result + (isDirty ? 1231 : 1237);
-    result = prime * result + ((readOnly == null) ? 0 : readOnly.hashCode());
-    result = prime * result + ((schema == null) ? 0 : schema.hashCode());
-    result = prime * result
-        + ((transactionIsolation == null) ? 0 : transactionIsolation.hashCode());
-    return result;
+    return Objects.hash(autoCommit, catalog, isDirty, readOnly, schema,
+        transactionIsolation);
   }
 
   @Override public boolean equals(Object o) {
-    if (o == this) {
-      return true;
-    }
-    if (o instanceof ConnectionPropertiesImpl) {
-      ConnectionPropertiesImpl other = (ConnectionPropertiesImpl) o;
-
-      if (null == autoCommit) {
-        if (null != other.autoCommit) {
-          return false;
-        }
-      } else if (!autoCommit.equals(other.autoCommit)) {
-        return false;
-      }
-
-      if (null == catalog) {
-        if (null != other.catalog) {
-          return false;
-        }
-      } else if (!catalog.equals(other.catalog)) {
-        return false;
-      }
-
-      if (isDirty != other.isDirty) {
-        return false;
-      }
-
-      if (null == readOnly) {
-        if (null != other.readOnly) {
-          return false;
-        }
-      } else if (!readOnly.equals(other.readOnly)) {
-        return false;
-      }
-
-      if (null == schema) {
-        if (null != other.schema) {
-          return false;
-        }
-      } else if (!schema.equals(other.schema)) {
-        return false;
-      }
-
-      if (null == transactionIsolation) {
-        if (null != other.transactionIsolation) {
-          return false;
-        }
-      } else if (!transactionIsolation.equals(other.transactionIsolation)) {
-        return false;
-      }
-
-      return true;
-    }
-
-    return false;
+    return o == this
+        || o instanceof ConnectionPropertiesImpl
+        && Objects.equals(autoCommit, ((ConnectionPropertiesImpl) o).autoCommit)
+        && Objects.equals(catalog, ((ConnectionPropertiesImpl) o).catalog)
+        && isDirty == ((ConnectionPropertiesImpl) o).isDirty
+        && Objects.equals(readOnly, ((ConnectionPropertiesImpl) o).readOnly)
+        && Objects.equals(schema, ((ConnectionPropertiesImpl) o).schema)
+        && Objects.equals(transactionIsolation,
+            ((ConnectionPropertiesImpl) o).transactionIsolation);
   }
 
   public Common.ConnectionProperties toProto() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/Meta.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/Meta.java b/avatica/src/main/java/org/apache/calcite/avatica/Meta.java
index e9b28d5..392086c 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/Meta.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/Meta.java
@@ -599,50 +599,16 @@ public interface Meta {
     }
 
     @Override public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());
-      result = prime * result + ((fieldNames == null) ? 0 : fieldNames.hashCode());
-      result = prime * result + ((fields == null) ? 0 : fields.hashCode());
-      result = prime * result + ((style == null) ? 0 : style.hashCode());
-      return result;
+      return Objects.hash(clazz, fieldNames, fields, style);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (o instanceof CursorFactory) {
-        CursorFactory other = (CursorFactory) o;
-
-        if (null == clazz) {
-          if (null != other.clazz) {
-            return false;
-          }
-        } else if (!clazz.equals(other.clazz)) {
-          return false;
-        }
-
-        if (null == fieldNames) {
-          if (null != other.fieldNames) {
-            return false;
-          }
-        } else if (!fieldNames.equals(other.fieldNames)) {
-          return false;
-        }
-
-        if (null == fields) {
-          if (null != other.fields) {
-            return false;
-          }
-        } else if (!fields.equals(other.fields)) {
-          return false;
-        }
-
-        return style == other.style;
-      }
-
-      return false;
+      return o == this
+          || o instanceof CursorFactory
+          && Objects.equals(clazz, ((CursorFactory) o).clazz)
+          && Objects.equals(fieldNames, ((CursorFactory) o).fieldNames)
+          && Objects.equals(fields, ((CursorFactory) o).fields)
+          && style == ((CursorFactory) o).style;
     }
   }
 
@@ -666,7 +632,7 @@ public interface Meta {
   }
 
   /** Result of preparing a statement. */
-  public class Signature {
+  class Signature {
     public final List<ColumnMetaData> columns;
     public final String sql;
     public final List<AvaticaParameter> parameters;
@@ -784,63 +750,21 @@ public interface Meta {
     }
 
     @Override public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((columns == null) ? 0 : columns.hashCode());
-      result = prime * result + ((cursorFactory == null) ? 0 : cursorFactory.hashCode());
-      result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
-      result = prime * result + ((sql == null) ? 0 : sql.hashCode());
-      return result;
+      return Objects.hash(columns, cursorFactory, parameters, sql);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (o instanceof Signature) {
-        Signature other = (Signature) o;
-
-        if (null == columns) {
-          if (null != other.columns) {
-            return false;
-          }
-        } else if (!columns.equals(other.columns)) {
-          return false;
-        }
-
-        if (null == cursorFactory) {
-          if (null != other.cursorFactory) {
-            return false;
-          }
-        } else if (!cursorFactory.equals(other.cursorFactory)) {
-          return false;
-        }
-
-        if (null == parameters) {
-          if (null != other.parameters) {
-            return false;
-          }
-        } else if (!parameters.equals(other.parameters)) {
-          return false;
-        }
-
-        if (null == sql) {
-          if (null != other.sql) {
-            return false;
-          }
-        } else if (!sql.equals(other.sql)) {
-          return false;
-        }
-
-        return true;
-      }
-
-      return false;
+      return o == this
+          || o instanceof Signature
+          && Objects.equals(columns, ((Signature) o).columns)
+          && Objects.equals(cursorFactory, ((Signature) o).cursorFactory)
+          && Objects.equals(parameters, ((Signature) o).parameters)
+          && Objects.equals(sql, ((Signature) o).sql);
     }
   }
 
   /** A collection of rows. */
-  public class Frame {
+  class Frame {
     /** Frame that has zero rows and is the last frame. */
     public static final Frame EMPTY =
         new Frame(0, true, Collections.emptyList());
@@ -946,7 +870,7 @@ public interface Meta {
           .setStringValue((String) element);
       } else if (element instanceof Character) {
         valueBuilder.setType(Common.Rep.CHARACTER)
-          .setStringValue(((Character) element).toString());
+          .setStringValue(element.toString());
       // Bytes
       } else if (element instanceof byte[]) {
         valueBuilder.setType(Common.Rep.BYTE_STRING)
@@ -1077,7 +1001,7 @@ public interface Meta {
       case FLOAT:
         return Long.valueOf(protoElement.getNumberValue()).floatValue();
       case DOUBLE:
-        return Double.valueOf(protoElement.getDoubleValue());
+        return protoElement.getDoubleValue();
       case NUMBER:
         // TODO more cases here to expand on? BigInteger?
         return BigDecimal.valueOf(protoElement.getDoubleValue());
@@ -1098,78 +1022,72 @@ public interface Meta {
     }
 
     @Override public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + (done ? 1231 : 1237);
-      result = prime * result + (int) (offset ^ (offset >>> 32));
-      result = prime * result + ((rows == null) ? 0 : rows.hashCode());
-      return result;
+      return Objects.hash(done, offset, rows);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (o instanceof Frame) {
-        Frame other = (Frame) o;
+      return o == this
+          || o instanceof Frame
+          && equalRows(rows, ((Frame) o).rows)
+          && offset == ((Frame) o).offset
+          && done == ((Frame) o).done;
+    }
 
-        if (null == rows) {
-          if (null != other.rows) {
-            return false;
-          }
-        } else {
-          Iterator<Object> iter1 = rows.iterator();
-          Iterator<Object> iter2 = other.rows.iterator();
-          while (iter1.hasNext() && iter2.hasNext()) {
-            Object obj1 = iter1.next();
-            Object obj2 = iter2.next();
-
-            // Can't just call equals on an array
-            if (obj1 instanceof Object[]) {
-              if (obj2 instanceof Object[]) {
-                // Compare array and array
-                if (!Arrays.equals((Object[]) obj1, (Object[]) obj2)) {
-                  return false;
-                }
-              } else if (obj2 instanceof List) {
-                // compare array and list
-                @SuppressWarnings("unchecked")
-                List<Object> obj2List = (List<Object>) obj2;
-                if (!Arrays.equals((Object[]) obj1, obj2List.toArray(new Object[0]))) {
-                  return false;
-                }
-              } else {
-                // compare array and something that isn't an array will always fail
+    private static boolean equalRows(Iterable<Object> rows, Iterable<Object> otherRows) {
+      if (null == rows) {
+        if (null != otherRows) {
+          return false;
+        }
+      } else {
+        Iterator<Object> iter1 = rows.iterator();
+        Iterator<Object> iter2 = otherRows.iterator();
+        while (iter1.hasNext() && iter2.hasNext()) {
+          Object obj1 = iter1.next();
+          Object obj2 = iter2.next();
+
+          // Can't just call equals on an array
+          if (obj1 instanceof Object[]) {
+            if (obj2 instanceof Object[]) {
+              // Compare array and array
+              if (!Arrays.equals((Object[]) obj1, (Object[]) obj2)) {
                 return false;
               }
-            } else if (obj1 instanceof List) {
-              if (obj2 instanceof Object[]) {
-                // Compare list and array
-                @SuppressWarnings("unchecked")
-                List<Object> obj1List = (List<Object>) obj1;
-                if (!Arrays.equals(obj1List.toArray(new Object[0]), (Object[]) obj2)) {
-                  return false;
-                }
-              } else if (!obj1.equals(obj2)) {
-                // compare list and something else, let it fall to equals()
+            } else if (obj2 instanceof List) {
+              // compare array and list
+              @SuppressWarnings("unchecked")
+              List<Object> obj2List = (List<Object>) obj2;
+              if (!Arrays.equals((Object[]) obj1, obj2List.toArray())) {
+                return false;
+              }
+            } else {
+              // compare array and something that isn't an array will always fail
+              return false;
+            }
+          } else if (obj1 instanceof List) {
+            if (obj2 instanceof Object[]) {
+              // Compare list and array
+              @SuppressWarnings("unchecked")
+              List<Object> obj1List = (List<Object>) obj1;
+              if (!Arrays.equals(obj1List.toArray(), (Object[]) obj2)) {
                 return false;
               }
             } else if (!obj1.equals(obj2)) {
-              // Not an array, leave it to equals()
+              // compare list and something else, let it fall to equals()
               return false;
             }
-          }
-
-          // More elements in one of the iterables
-          if (iter1.hasNext() || iter2.hasNext()) {
+          } else if (!obj1.equals(obj2)) {
+            // Not an array, leave it to equals()
             return false;
           }
         }
 
-        return offset == other.offset && done == other.done;
+        // More elements in one of the iterables
+        if (iter1.hasNext() || iter2.hasNext()) {
+          return false;
+        }
       }
 
-      return false;
+      return true;
     }
   }
 
@@ -1221,41 +1139,15 @@ public interface Meta {
     }
 
     @Override public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((connectionId == null) ? 0 : connectionId.hashCode());
-      result = prime * result + id;
-      result = prime * result + ((signature == null) ? 0 : signature.hashCode());
-      return result;
+      return Objects.hash(connectionId, id, signature);
     }
 
     @Override public boolean equals(Object o) {
-      if (o == this) {
-        return true;
-      }
-      if (o instanceof StatementHandle) {
-        StatementHandle other = (StatementHandle) o;
-
-        if (null == connectionId) {
-          if (null != other.connectionId) {
-            return false;
-          }
-        } else if (!connectionId.equals(other.connectionId)) {
-          return false;
-        }
-
-        if (null == signature) {
-          if (null != other.signature) {
-            return false;
-          }
-        } else if (!signature.equals(other.signature)) {
-          return false;
-        }
-
-        return id == other.id;
-      }
-
-      return false;
+      return o == this
+          || o instanceof StatementHandle
+          && Objects.equals(connectionId, ((StatementHandle) o).connectionId)
+          && Objects.equals(signature, ((StatementHandle) o).signature)
+          && id == ((StatementHandle) o).id;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/QueryState.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/QueryState.java b/avatica/src/main/java/org/apache/calcite/avatica/QueryState.java
index c702f3c..4ca9ce1 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/QueryState.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/QueryState.java
@@ -40,7 +40,7 @@ public class QueryState {
   /**
    * An enumeration that represents how a ResultSet was created.
    */
-  public static enum StateType {
+  public enum StateType {
     SQL,
     METADATA;
 
@@ -451,38 +451,15 @@ public class QueryState {
   }
 
   @Override public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((metaDataOperation == null) ? 0 : metaDataOperation.hashCode());
-    result = prime * result + Arrays.hashCode(operationArgs);
-    result = prime * result + ((sql == null) ? 0 : sql.hashCode());
-    return result;
+    return Objects.hash(metaDataOperation, Arrays.hashCode(operationArgs), sql);
   }
 
-  @Override public boolean equals(Object obj) {
-    if (this == obj) {
-      return true;
-    }
-    if (!(obj instanceof QueryState)) {
-      return false;
-    }
-
-    QueryState other = (QueryState) obj;
-    if (metaDataOperation != other.metaDataOperation) {
-      return false;
-    }
-    if (!Arrays.deepEquals(operationArgs, other.operationArgs)) {
-      return false;
-    }
-    if (sql == null) {
-      if (other.sql != null) {
-        return false;
-      }
-    } else if (!sql.equals(other.sql)) {
-      return false;
-    }
-
-    return true;
+  @Override public boolean equals(Object o) {
+    return o == this
+        || o instanceof QueryState
+        && metaDataOperation == ((QueryState) o).metaDataOperation
+        && Arrays.deepEquals(operationArgs, ((QueryState) o).operationArgs)
+        && Objects.equals(sql, ((QueryState) o).sql);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/avatica/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java b/avatica/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
index 5f91811..4d9b322 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
@@ -19,6 +19,7 @@ package org.apache.calcite.avatica.util;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /** A range of time units. The first is more significant than the
  * other (e.g. year-to-day) or the same as the other (e.g. month). */
@@ -62,14 +63,13 @@ public enum TimeUnitRange {
    * @return Time unit range, or null if not valid
    */
   public static TimeUnitRange of(TimeUnit startUnit, TimeUnit endUnit) {
-    return MAP.get(new Pair<TimeUnit>(startUnit, endUnit));
+    return MAP.get(new Pair<>(startUnit, endUnit));
   }
 
   private static Map<Pair<TimeUnit>, TimeUnitRange> createMap() {
-    Map<Pair<TimeUnit>, TimeUnitRange> map =
-        new HashMap<Pair<TimeUnit>, TimeUnitRange>();
+    Map<Pair<TimeUnit>, TimeUnitRange> map = new HashMap<>();
     for (TimeUnitRange value : values()) {
-      map.put(new Pair<TimeUnit>(value.startUnit, value.endUnit), value);
+      map.put(new Pair<>(value.startUnit, value.endUnit), value);
     }
     return Collections.unmodifiableMap(map);
   }
@@ -98,12 +98,8 @@ public enum TimeUnitRange {
     @Override public boolean equals(Object obj) {
       return obj == this
           || obj instanceof Pair
-          && equals(left, ((Pair) obj).left)
-          && equals(right, ((Pair) obj).right);
-    }
-
-    private static boolean equals(Object a, Object b) {
-      return (a == b) || (a != null && a.equals(b));
+          && Objects.equals(left, ((Pair) obj).left)
+          && Objects.equals(right, ((Pair) obj).right);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/interpreter/TableScanNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/TableScanNode.java b/core/src/main/java/org/apache/calcite/interpreter/TableScanNode.java
index c88627b..dd75d57 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/TableScanNode.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/TableScanNode.java
@@ -42,7 +42,6 @@ import org.apache.calcite.util.Util;
 import org.apache.calcite.util.mapping.Mapping;
 import org.apache.calcite.util.mapping.Mappings;
 
-import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
@@ -51,6 +50,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.List;
+import java.util.Objects;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -227,7 +227,7 @@ public class TableScanNode implements Node {
       }
       final Enumerable<Row> rowEnumerable = Enumerables.toRow(enumerable1);
       final ImmutableIntList rejectedProjects;
-      if (Objects.equal(projects, originalProjects)) {
+      if (Objects.equals(projects, originalProjects)) {
         rejectedProjects = null;
       } else {
         // We projected extra columns because they were needed in filters. Now

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java b/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
index 45d4492..831d696 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
@@ -22,6 +22,7 @@ import org.apache.calcite.rel.type.RelRecordType;
 import com.google.common.base.Preconditions;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Record type based on a Java class. The fields of the type are the fields
@@ -46,7 +47,7 @@ public class JavaRecordType extends RelRecordType {
   }
 
   @Override public int hashCode() {
-    return fieldList.hashCode() ^ clazz.hashCode();
+    return Objects.hash(fieldList, clazz);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/materialize/Lattice.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/Lattice.java b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
index 244a245..a0f2186 100644
--- a/core/src/main/java/org/apache/calcite/materialize/Lattice.java
+++ b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
@@ -63,6 +63,7 @@ import com.google.common.collect.Sets;
 import java.math.BigInteger;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -233,8 +234,7 @@ public class Lattice {
   }
 
   public String sql(ImmutableBitSet groupSet, List<Measure> aggCallList) {
-    final ImmutableBitSet.Builder columnSetBuilder =
-        ImmutableBitSet.builder(groupSet);
+    final ImmutableBitSet.Builder columnSetBuilder = groupSet.rebuild();
     for (Measure call : aggCallList) {
       for (Column arg : call.args) {
         columnSetBuilder.set(arg.ordinal);
@@ -481,7 +481,7 @@ public class Lattice {
     }
 
     @Override public int hashCode() {
-      return com.google.common.base.Objects.hashCode(agg, args);
+      return Objects.hash(agg, args);
     }
 
     @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java b/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
index 3a21694..4564478 100644
--- a/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
+++ b/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
@@ -26,6 +26,7 @@ import com.google.common.collect.Multimap;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Actor that manages the state of materializations in the system.
@@ -105,7 +106,7 @@ class MaterializationActor {
     }
 
     @Override public int hashCode() {
-      return com.google.common.base.Objects.hashCode(sql, schema, path);
+      return Objects.hash(sql, schema, path);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/materialize/TileKey.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/TileKey.java b/core/src/main/java/org/apache/calcite/materialize/TileKey.java
index 8fb8124..34564be 100644
--- a/core/src/main/java/org/apache/calcite/materialize/TileKey.java
+++ b/core/src/main/java/org/apache/calcite/materialize/TileKey.java
@@ -18,9 +18,10 @@ package org.apache.calcite.materialize;
 
 import org.apache.calcite.util.ImmutableBitSet;
 
-import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 
+import java.util.Objects;
+
 /** Definition of a particular combination of dimensions and measures of a
  * lattice that is the basis of a materialization.
  *
@@ -41,7 +42,7 @@ public class TileKey {
   }
 
   @Override public int hashCode() {
-    return Objects.hashCode(lattice, dimensions);
+    return Objects.hash(lattice, dimensions);
   }
 
   @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java b/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
index 7c5aeca..c0285d2 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
@@ -16,7 +16,7 @@
  */
 package org.apache.calcite.plan;
 
-import org.apache.calcite.util.Util;
+import org.apache.calcite.runtime.Utilities;
 
 /**
  * RelOptCostImpl provides a default implementation for the {@link RelOptCost}
@@ -70,7 +70,7 @@ public class RelOptCostImpl implements RelOptCost {
   }
 
   @Override public int hashCode() {
-    return Util.hashCode(getRows());
+    return Utilities.hashCode(getRows());
   }
 
   // implement RelOptCost

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java b/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
index e95d7df..12f52c1 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
@@ -17,13 +17,13 @@
 package org.apache.calcite.plan;
 
 import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.util.Util;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Operand that determines whether a {@link RelOptRule}
@@ -145,10 +145,7 @@ public class RelOptRuleOperand {
   }
 
   public int hashCode() {
-    int h = clazz.hashCode();
-    h = Util.hash(h, trait);
-    h = Util.hash(h, children);
-    return h;
+    return Objects.hash(clazz, trait, children);
   }
 
   public boolean equals(Object obj) {
@@ -161,7 +158,7 @@ public class RelOptRuleOperand {
     RelOptRuleOperand that = (RelOptRuleOperand) obj;
 
     return (this.clazz == that.clazz)
-        && com.google.common.base.Objects.equal(this.trait, that.trait)
+        && Objects.equals(this.trait, that.trait)
         && this.children.equals(that.children);
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
index 560dda1..6aa935b 100644
--- a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
+++ b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
@@ -65,7 +65,6 @@ import org.apache.calcite.util.trace.CalciteTrace;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Equivalence;
 import com.google.common.base.Function;
-import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
@@ -84,6 +83,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 import static org.apache.calcite.rex.RexUtil.andNot;
@@ -1688,7 +1688,7 @@ public class SubstitutionVisitor {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(input,
+      return Objects.hash(input,
           PAIRWISE_STRING_EQUIVALENCE.hash(projects));
     }
 
@@ -1734,7 +1734,7 @@ public class SubstitutionVisitor {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(input, condition.toString());
+      return Objects.hash(input, condition.toString());
     }
 
     @Override public StringBuilder digest(StringBuilder buf) {
@@ -1785,7 +1785,7 @@ public class SubstitutionVisitor {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(input, groupSet, aggCalls);
+      return Objects.hash(input, groupSet, aggCalls);
     }
 
     @Override public StringBuilder digest(StringBuilder buf) {
@@ -1834,13 +1834,13 @@ public class SubstitutionVisitor {
       return obj == this
           || obj instanceof MutableSort
           && collation.equals(((MutableSort) obj).collation)
-          && Objects.equal(offset, ((MutableSort) obj).offset)
-          && Objects.equal(fetch, ((MutableSort) obj).fetch)
+          && Objects.equals(offset, ((MutableSort) obj).offset)
+          && Objects.equals(fetch, ((MutableSort) obj).fetch)
           && input.equals(((MutableSort) obj).input);
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(input, collation, offset, fetch);
+      return Objects.hash(input, collation, offset, fetch);
     }
 
     @Override public StringBuilder digest(StringBuilder buf) {
@@ -1908,7 +1908,7 @@ public class SubstitutionVisitor {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(type, inputs);
+      return Objects.hash(type, inputs);
     }
 
     @Override public StringBuilder digest(StringBuilder buf) {
@@ -2028,7 +2028,7 @@ public class SubstitutionVisitor {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(left, right, condition.toString(), joinType);
+      return Objects.hash(left, right, condition.toString(), joinType);
     }
 
     @Override public StringBuilder digest(StringBuilder buf) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java
index f933640..a28b00b 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoCost.java
@@ -19,7 +19,8 @@ package org.apache.calcite.plan.volcano;
 import org.apache.calcite.plan.RelOptCost;
 import org.apache.calcite.plan.RelOptCostFactory;
 import org.apache.calcite.plan.RelOptUtil;
-import org.apache.calcite.util.Util;
+
+import java.util.Objects;
 
 /**
  * <code>VolcanoCost</code> represents the cost of a plan node.
@@ -119,7 +120,7 @@ class VolcanoCost implements RelOptCost {
   }
 
   @Override public int hashCode() {
-    return Util.hashCode(rowCount) + Util.hashCode(cpu) + Util.hashCode(io);
+    return Objects.hash(rowCount, cpu, io);
   }
 
   public boolean equals(RelOptCost other) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rel/RelDistributions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/RelDistributions.java b/core/src/main/java/org/apache/calcite/rel/RelDistributions.java
index 24fee52..f739da8 100644
--- a/core/src/main/java/org/apache/calcite/rel/RelDistributions.java
+++ b/core/src/main/java/org/apache/calcite/rel/RelDistributions.java
@@ -28,6 +28,7 @@ import com.google.common.collect.Ordering;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
 import javax.annotation.Nonnull;
 
 /**
@@ -97,7 +98,7 @@ public class RelDistributions {
     }
 
     @Override public int hashCode() {
-      return Util.hash(type.hashCode(), keys);
+      return Objects.hash(type, keys);
     }
 
     @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rel/RelFieldCollation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/RelFieldCollation.java b/core/src/main/java/org/apache/calcite/rel/RelFieldCollation.java
index 9f605e2..c216912 100644
--- a/core/src/main/java/org/apache/calcite/rel/RelFieldCollation.java
+++ b/core/src/main/java/org/apache/calcite/rel/RelFieldCollation.java
@@ -20,6 +20,8 @@ import org.apache.calcite.sql.validate.SqlMonotonicity;
 
 import com.google.common.base.Preconditions;
 
+import java.util.Objects;
+
 /**
  * Definition of the ordering of one field of a {@link RelNode} whose
  * output is to be sorted.
@@ -86,7 +88,7 @@ public class RelFieldCollation {
       this.shortString = shortString;
     }
 
-    /** Converts thie direction to a
+    /** Converts the direction to a
      * {@link org.apache.calcite.sql.validate.SqlMonotonicity}. */
     public SqlMonotonicity monotonicity() {
       switch (this) {
@@ -219,22 +221,16 @@ public class RelFieldCollation {
     return copy(fieldIndex + offset);
   }
 
-  // implement Object
-  public boolean equals(Object obj) {
-    if (!(obj instanceof RelFieldCollation)) {
-      return false;
-    }
-    RelFieldCollation other = (RelFieldCollation) obj;
-    return (fieldIndex == other.fieldIndex)
-        && (direction == other.direction)
-        && (nullDirection == other.nullDirection);
+  @Override public boolean equals(Object o) {
+    return this == o
+        || o instanceof RelFieldCollation
+        && fieldIndex == ((RelFieldCollation) o).fieldIndex
+        && direction == ((RelFieldCollation) o).direction
+        && nullDirection == ((RelFieldCollation) o).nullDirection;
   }
 
-  // implement Object
-  public int hashCode() {
-    return this.fieldIndex
-        | (this.direction.ordinal() << 4)
-        | (this.nullDirection.ordinal() << 8);
+  @Override public int hashCode() {
+    return Objects.hash(fieldIndex, direction, nullDirection);
   }
 
   public int getFieldIndex() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java b/core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java
index d35f7e1..2c4ee63 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java
@@ -24,11 +24,11 @@ import org.apache.calcite.sql.type.SqlTypeUtil;
 import org.apache.calcite.util.mapping.Mapping;
 import org.apache.calcite.util.mapping.Mappings;
 
-import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Call to an aggFunction function within an
@@ -184,7 +184,7 @@ public class AggregateCall {
    * @param name New name (may be null)
    */
   public AggregateCall rename(String name) {
-    if (Objects.equal(this.name, name)) {
+    if (Objects.equals(this.name, name)) {
       return this;
     }
     return new AggregateCall(aggFunction, distinct, argList, filterArg, type,
@@ -225,7 +225,7 @@ public class AggregateCall {
   }
 
   @Override public int hashCode() {
-    return aggFunction.hashCode() + argList.hashCode();
+    return Objects.hash(aggFunction, distinct, argList, filterArg);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java b/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java
index 783a649..9053ce2 100644
--- a/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java
+++ b/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java
@@ -39,7 +39,6 @@ import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Litmus;
 import org.apache.calcite.util.Pair;
 
-import com.google.common.base.Objects;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.LinkedListMultimap;
@@ -53,6 +52,7 @@ import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Sub-class of {@link org.apache.calcite.rel.core.Window}
@@ -325,11 +325,7 @@ public final class LogicalWindow extends Window {
     }
 
     @Override public int hashCode() {
-      return com.google.common.base.Objects.hashCode(groupSet,
-          orderKeys,
-          isRows,
-          lowerBound,
-          upperBound);
+      return Objects.hash(groupSet, orderKeys, isRows, lowerBound, upperBound);
     }
 
     @Override public boolean equals(Object obj) {
@@ -337,8 +333,8 @@ public final class LogicalWindow extends Window {
           || obj instanceof WindowKey
           && groupSet.equals(((WindowKey) obj).groupSet)
           && orderKeys.equals(((WindowKey) obj).orderKeys)
-          && Objects.equal(lowerBound, ((WindowKey) obj).lowerBound)
-          && Objects.equal(upperBound, ((WindowKey) obj).upperBound)
+          && Objects.equals(lowerBound, ((WindowKey) obj).lowerBound)
+          && Objects.equals(upperBound, ((WindowKey) obj).upperBound)
           && isRows == ((WindowKey) obj).isRows;
     }
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
index acdebec..26f8e4a 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
@@ -44,6 +44,7 @@ import java.util.AbstractList;
 import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.TimeZone;
 
 /**
@@ -608,7 +609,7 @@ public class RexLiteral extends RexNode {
   }
 
   public int hashCode() {
-    return com.google.common.base.Objects.hashCode(value, type);
+    return Objects.hash(value, type);
   }
 
   public static Comparable value(RexNode node) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/rex/RexLocalRef.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexLocalRef.java b/core/src/main/java/org/apache/calcite/rex/RexLocalRef.java
index 57a3aff..60180ce 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexLocalRef.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexLocalRef.java
@@ -18,9 +18,9 @@ package org.apache.calcite.rex;
 
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.util.Util;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Local variable.
@@ -68,9 +68,7 @@ public class RexLocalRef extends RexSlot {
   }
 
   public int hashCode() {
-    return Util.hash(
-        type.hashCode(),
-        index);
+    return Objects.hash(type, index);
   }
 
   public <R> R accept(RexVisitor<R> visitor) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/runtime/Utilities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/Utilities.java b/core/src/main/java/org/apache/calcite/runtime/Utilities.java
index cf4fc0c..a97a038 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Utilities.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Utilities.java
@@ -41,40 +41,85 @@ public class Utilities {
     return v == null ? 0 : v.hashCode();
   }
 
+  /** Computes the hash code of a {@code double} value. Equivalent to
+   * {@link Double}{@code .hashCode(double)}, but that method was only
+   * introduced in JDK 1.8.
+   *
+   * @param v Value
+   * @return Hash code
+   */
+  public static int hashCode(double v) {
+    long bits = Double.doubleToLongBits(v);
+    return hashCode(bits);
+  }
+
+  /** Computes the hash code of a {@code float} value. Equivalent to
+   * {@link Float}{@code .hashCode(float)}, but that method was only
+   * introduced in JDK 1.8.
+   *
+   * @param v Value
+   * @return Hash code
+   */
+  public static int hashCode(float v) {
+    return Float.floatToIntBits(v);
+  }
+
+  /** Computes the hash code of a {@code long} value. Equivalent to
+   * {@link Long}{@code .hashCode(long)}, but that method was only
+   * introduced in JDK 1.8.
+   *
+   * @param v Value
+   * @return Hash code
+   */
+  public static int hashCode(long v) {
+    return (int) (v ^ (v >>> 32));
+  }
+
+  /** Computes the hash code of a {@code boolean} value. Equivalent to
+   * {@link Boolean}{@code .hashCode(boolean)}, but that method was only
+   * introduced in JDK 1.8.
+   *
+   * @param v Value
+   * @return Hash code
+   */
+  public static int hashCode(boolean v) {
+    return v ? 1231 : 1237;
+  }
+
   public static int hash(int h, boolean v) {
-    return h * 37 + (v ? 2 : 1);
+    return h * 31 + hashCode(v);
   }
 
   public static int hash(int h, byte v) {
-    return h * 37 + v;
+    return h * 31 + v;
   }
 
   public static int hash(int h, char v) {
-    return h * 37 + v;
+    return h * 31 + v;
   }
 
   public static int hash(int h, short v) {
-    return h * 37 + v;
+    return h * 31 + v;
   }
 
   public static int hash(int h, int v) {
-    return h * 37 + v;
+    return h * 31 + v;
   }
 
   public static int hash(int h, long v) {
-    return h * 37 + (int) (v ^ (v >>> 32));
+    return h * 31 + hashCode(v);
   }
 
   public static int hash(int h, float v) {
-    return hash(h, Float.floatToIntBits(v));
+    return hash(h, hashCode(v));
   }
 
   public static int hash(int h, double v) {
-    return hash(h, Double.doubleToLongBits(v));
+    return hash(h, hashCode(v));
   }
 
   public static int hash(int h, Object v) {
-    return h * 37 + (v == null ? 1 : v.hashCode());
+    return h * 31 + (v == null ? 1 : v.hashCode());
   }
 
   public static int compare(boolean v0, boolean v1) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java b/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
index 8ce7923..2cffb82 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
@@ -29,9 +29,8 @@ import org.apache.calcite.sql.validate.SqlValidatorScope;
 import org.apache.calcite.util.Litmus;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Objects;
-
 import java.nio.charset.Charset;
+import java.util.Objects;
 import java.util.TimeZone;
 
 import static org.apache.calcite.util.Static.RESOURCE;
@@ -254,11 +253,10 @@ public class SqlDataTypeSpec extends SqlNode {
     if (this.scale != that.scale) {
       return litmus.fail(this + "!=" + node);
     }
-    if (!Objects.equal(this.timeZone, that.timeZone)) {
+    if (!Objects.equals(this.timeZone, that.timeZone)) {
       return litmus.fail(this + "!=" + node);
     }
-    if (!com.google.common.base.Objects.equal(this.charSetName,
-        that.charSetName)) {
+    if (!Objects.equals(this.charSetName, that.charSetName)) {
       return litmus.fail(this + "!=" + node);
     }
     return litmus.succeed();

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java b/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
index ff47657..a31b8ba 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
@@ -19,7 +19,8 @@ package org.apache.calcite.sql;
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.util.Litmus;
-import org.apache.calcite.util.Util;
+
+import java.util.Objects;
 
 /**
  * A SQL literal representing a time interval.
@@ -128,8 +129,7 @@ public class SqlIntervalLiteral extends SqlLiteral {
     }
 
     public int hashCode() {
-      int h = Util.hash(sign, intervalStr);
-      return Util.hash(h, intervalQualifier);
+      return Objects.hash(sign, intervalStr, intervalQualifier);
     }
 
     public SqlIntervalQualifier getIntervalQualifier() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java b/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
index 32714c6..625e11c 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
@@ -39,6 +39,7 @@ import java.math.BigDecimal;
 import java.nio.charset.Charset;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.Calendar;
+import java.util.Objects;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -471,7 +472,7 @@ public class SqlLiteral extends SqlNode {
       return false;
     }
     SqlLiteral that = (SqlLiteral) obj;
-    return com.google.common.base.Objects.equal(value, that.value);
+    return Objects.equals(value, that.value);
   }
 
   public int hashCode() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
index bef8b59..476a1c5 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
@@ -34,6 +34,7 @@ import org.apache.calcite.util.Util;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -357,9 +358,8 @@ public abstract class SqlOperator {
     return name.equals(testName);
   }
 
-  // override Object
-  public int hashCode() {
-    return kind.hashCode() + name.hashCode();
+  @Override public int hashCode() {
+    return Objects.hash(kind, name);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
index c7ded0b..3742c8e 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
@@ -40,6 +40,7 @@ import org.apache.calcite.sql.validate.SqlMonotonicity;
 
 import com.google.common.collect.ImmutableSet;
 
+import java.util.Objects;
 import java.util.Set;
 
 import static org.apache.calcite.util.Static.RESOURCE;
@@ -222,19 +223,15 @@ public class SqlCastFunction extends SqlFunction {
       this.castTo = castTo;
     }
 
-    @Override public boolean equals(Object obj) {
-      // TODO Auto-generated method stub
-      if (obj.getClass() != TypeFamilyCast.class) {
-        return false;
-      }
-      TypeFamilyCast other = (TypeFamilyCast) obj;
-      return this.castFrom.equals(other.castFrom)
-          && this.castTo.equals(other.castTo);
+    @Override public boolean equals(Object o) {
+      return o == this
+          || o instanceof TypeFamilyCast
+          && castFrom.equals(((TypeFamilyCast) o).castFrom)
+          && castTo.equals(((TypeFamilyCast) o).castTo);
     }
 
     @Override public int hashCode() {
-      // TODO Auto-generated method stub
-      return castFrom.hashCode() + castTo.hashCode();
+      return Objects.hash(castFrom, castTo);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
index 5028282..0e321d1 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
@@ -25,6 +25,7 @@ import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -81,22 +82,16 @@ public class SqlParserPos implements Serializable {
   //~ Methods ----------------------------------------------------------------
 
   public int hashCode() {
-    return lineNumber
-        ^ (columnNumber << 2)
-        ^ (endLineNumber << 5)
-        ^ (endColumnNumber << 7);
+    return Objects.hash(lineNumber, columnNumber, endLineNumber, endColumnNumber);
   }
 
-  public boolean equals(Object obj) {
-    if (obj instanceof SqlParserPos) {
-      final SqlParserPos that = (SqlParserPos) obj;
-      return (that.lineNumber == this.lineNumber)
-          && (that.columnNumber == this.columnNumber)
-          && (that.endLineNumber == this.endLineNumber)
-          && (that.endColumnNumber == this.endColumnNumber);
-    } else {
-      return false;
-    }
+  public boolean equals(Object o) {
+    return o == this
+        || o instanceof SqlParserPos
+        && this.lineNumber == ((SqlParserPos) o).lineNumber
+        && this.columnNumber == ((SqlParserPos) o).columnNumber
+        && this.endLineNumber == ((SqlParserPos) o).endLineNumber
+        && this.endColumnNumber == ((SqlParserPos) o).endColumnNumber;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/util/SqlString.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/util/SqlString.java b/core/src/main/java/org/apache/calcite/sql/util/SqlString.java
index 79a7a48..92b295c 100644
--- a/core/src/main/java/org/apache/calcite/sql/util/SqlString.java
+++ b/core/src/main/java/org/apache/calcite/sql/util/SqlString.java
@@ -48,7 +48,8 @@ public class SqlString {
   }
 
   @Override public boolean equals(Object obj) {
-    return obj instanceof SqlString
+    return obj == this
+        || obj instanceof SqlString
         && s.equals(((SqlString) obj).s);
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql/validate/SqlMonikerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlMonikerImpl.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlMonikerImpl.java
index d14f76c..e2c5825 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlMonikerImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlMonikerImpl.java
@@ -24,6 +24,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
+import java.util.Objects;
 
 /**
  * A generic implementation of {@link SqlMoniker}.
@@ -61,7 +62,7 @@ public class SqlMonikerImpl implements SqlMoniker {
   }
 
   @Override public int hashCode() {
-    return Util.hash(type.ordinal(), names);
+    return Objects.hash(type, names);
   }
 
   public SqlMonikerType getType() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index 252e6d1..ecfd124 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -110,6 +110,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
+import java.util.Objects;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -2423,9 +2424,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
     }
 
     @Override public int hashCode() {
-      return com.google.common.base.Objects.hashCode(mapRefRelToCorVar,
-          mapCorVarToCorRel,
-          mapFieldAccessToCorVar);
+      return Objects.hash(mapRefRelToCorVar, mapCorVarToCorRel, mapFieldAccessToCorVar);
     }
 
     /** Creates a CorelMap with given contents. */

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/util/NlsString.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/NlsString.java b/core/src/main/java/org/apache/calcite/util/NlsString.java
index 1a49e5d..aa68eec 100644
--- a/core/src/main/java/org/apache/calcite/util/NlsString.java
+++ b/core/src/main/java/org/apache/calcite/util/NlsString.java
@@ -20,8 +20,6 @@ import org.apache.calcite.runtime.SqlFunctions;
 import org.apache.calcite.sql.SqlCollation;
 import org.apache.calcite.sql.SqlUtil;
 
-import com.google.common.base.Objects;
-
 import java.nio.CharBuffer;
 import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
@@ -29,6 +27,7 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.List;
+import java.util.Objects;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -95,10 +94,7 @@ public class NlsString implements Comparable<NlsString> {
   }
 
   public int hashCode() {
-    int h = value.hashCode();
-    h = Util.hash(h, charsetName);
-    h = Util.hash(h, collation);
-    return h;
+    return Objects.hash(value, charsetName, collation);
   }
 
   public boolean equals(Object obj) {
@@ -106,9 +102,9 @@ public class NlsString implements Comparable<NlsString> {
       return false;
     }
     NlsString that = (NlsString) obj;
-    return Objects.equal(value, that.value)
-        && Objects.equal(charsetName, that.charsetName)
-        && Objects.equal(collation, that.collation);
+    return Objects.equals(value, that.value)
+        && Objects.equals(charsetName, that.charsetName)
+        && Objects.equals(collation, that.collation);
   }
 
   // implement Comparable

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/util/Pair.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Pair.java b/core/src/main/java/org/apache/calcite/util/Pair.java
index f4f5b8d..cf4baac 100644
--- a/core/src/main/java/org/apache/calcite/util/Pair.java
+++ b/core/src/main/java/org/apache/calcite/util/Pair.java
@@ -16,16 +16,16 @@
  */
 package org.apache.calcite.util;
 
-import com.google.common.base.Objects;
 import com.google.common.collect.Iterators;
 
 import java.io.Serializable;
 import java.util.AbstractList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import javax.annotation.Nonnull;
 
 /**
  * Pair of objects.
@@ -71,7 +71,7 @@ public class Pair<T1, T2>
    * @return A Pair
    */
   public static <T1, T2> Pair<T1, T2> of(T1 left, T2 right) {
-    return new Pair<T1, T2>(left, right);
+    return new Pair<>(left, right);
   }
 
   //~ Methods ----------------------------------------------------------------
@@ -79,18 +79,24 @@ public class Pair<T1, T2>
   public boolean equals(Object obj) {
     return this == obj
         || (obj instanceof Pair)
-        && Objects.equal(this.left, ((Pair) obj).left)
-        && com.google.common.base.Objects.equal(this.right, ((Pair) obj).right);
+        && Objects.equals(this.left, ((Pair) obj).left)
+        && Objects.equals(this.right, ((Pair) obj).right);
   }
 
-  public int hashCode() {
-    int h1 = Util.hash(0, left);
-    return Util.hash(h1, right);
+  /** {@inheritDoc}
+   *
+   * <p>Computes hash code consistent with {@link Map.Entry#hashCode()}. */
+  @Override public int hashCode() {
+    int keyHash = left == null ? 0 : left.hashCode();
+    int valueHash = right == null ? 0 : right.hashCode();
+    return keyHash ^ valueHash;
   }
 
-  public int compareTo(Pair<T1, T2> that) {
+  public int compareTo(@Nonnull Pair<T1, T2> that) {
+    //noinspection unchecked
     int c = compare((Comparable) this.left, (Comparable) that.left);
     if (c == 0) {
+      //noinspection unchecked
       c = compare((Comparable) this.right, (Comparable) that.right);
     }
     return c;
@@ -147,8 +153,8 @@ public class Pair<T1, T2>
    * @param pairs Collection of Pair objects
    * @return map with the same contents as the collection
    */
-  public static <K, V> Map<K, V> toMap(Collection<Pair<K, V>> pairs) {
-    HashMap<K, V> map = new HashMap<K, V>();
+  public static <K, V> Map<K, V> toMap(Iterable<Pair<K, V>> pairs) {
+    final Map<K, V> map = new HashMap<>();
     for (Pair<K, V> pair : pairs) {
       map.put(pair.left, pair.right);
     }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/util/Util.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Util.java b/core/src/main/java/org/apache/calcite/util/Util.java
index 099f13c..7ec4fd5 100644
--- a/core/src/main/java/org/apache/calcite/util/Util.java
+++ b/core/src/main/java/org/apache/calcite/util/Util.java
@@ -29,7 +29,6 @@ import org.apache.calcite.sql.fun.SqlRowOperator;
 import org.apache.calcite.sql.util.SqlBasicVisitor;
 
 import com.google.common.base.Function;
-import com.google.common.base.Objects;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -68,6 +67,7 @@ import java.util.AbstractList;
 import java.util.AbstractMap;
 import java.util.AbstractSet;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -78,6 +78,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.Set;
 import java.util.TimeZone;
@@ -263,7 +264,10 @@ public class Util {
 
   /**
    * Combines two integers into a hash code.
+   *
+   * @deprecated Use {@link Objects#hash(Object...)}
    */
+  @Deprecated // to be removed before 2.0
   public static int hash(
       int i,
       int j) {
@@ -273,7 +277,10 @@ public class Util {
   /**
    * Computes a hash code from an existing hash code and an object (which may
    * be null).
+   *
+   * @deprecated Use {@link Objects#hash(Object...)}
    */
+  @Deprecated // to be removed before 2.0
   public static int hash(
       int h,
       Object o) {
@@ -284,22 +291,14 @@ public class Util {
   /**
    * Computes a hash code from an existing hash code and an array of objects
    * (which may be null).
+   *
+   * @deprecated Use {@link Objects#hash(Object...)}
    */
+  @Deprecated // to be removed before 2.0
   public static int hashArray(
       int h,
       Object[] a) {
-    // The hashcode for a null array and an empty array should be different
-    // than h, so use magic numbers.
-    if (a == null) {
-      return hash(h, 19690429);
-    }
-    if (a.length == 0) {
-      return hash(h, 19690721);
-    }
-    for (int i = 0; i < a.length; i++) {
-      h = hash(h, a[i]);
-    }
-    return h;
+    return h ^ Arrays.hashCode(a);
   }
 
   /** Computes the hash code of a {@code double} value. Equivalent to
@@ -308,7 +307,10 @@ public class Util {
    *
    * @param v Value
    * @return Hash code
+   *
+   * @deprecated Use {@link org.apache.calcite.runtime.Utilities#hashCode(double)}
    */
+  @Deprecated // to be removed before 2.0
   public static int hashCode(double v) {
     long bits = Double.doubleToLongBits(v);
     return (int) (bits ^ (bits >>> 32));
@@ -2078,7 +2080,7 @@ public class Util {
         E e = list.get(i);
         for (int j = i - 1; j >= 0; j--) {
           E e1 = list.get(j);
-          if (Objects.equal(e, e1)) {
+          if (Objects.equals(e, e1)) {
             return i;
           }
         }
@@ -2127,7 +2129,7 @@ public class Util {
       return false;
     }
     for (int i = 0; i < size; i++) {
-      if (!Objects.equal(list0.get(i), list1.get(i))) {
+      if (!Objects.equals(list0.get(i), list1.get(i))) {
         return false;
       }
     }

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/main/java/org/apache/calcite/util/mapping/IntPair.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/mapping/IntPair.java b/core/src/main/java/org/apache/calcite/util/mapping/IntPair.java
index 7160f39..87865b7 100644
--- a/core/src/main/java/org/apache/calcite/util/mapping/IntPair.java
+++ b/core/src/main/java/org/apache/calcite/util/mapping/IntPair.java
@@ -16,6 +16,8 @@
  */
 package org.apache.calcite.util.mapping;
 
+import org.apache.calcite.runtime.Utilities;
+
 import java.util.AbstractList;
 import java.util.List;
 
@@ -56,7 +58,7 @@ public class IntPair {
   }
 
   public int hashCode() {
-    return this.source ^ (this.target << 4);
+    return Utilities.hash(source, target);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
index e37aa2c..48d0f6c 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
@@ -40,7 +40,6 @@ import org.apache.calcite.util.Util;
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
 import com.google.common.base.Joiner;
-import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
@@ -75,11 +74,13 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Properties;
 import java.util.TimeZone;
 import java.util.TreeSet;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Nonnull;
 import javax.sql.DataSource;
 
 import static org.hamcrest.CoreMatchers.containsString;
@@ -1049,7 +1050,7 @@ public class CalciteAssert {
       private static final LoadingCache<ConnectionFactory, Connection> POOL =
           CacheBuilder.newBuilder().build(
               new CacheLoader<ConnectionFactory, Connection>() {
-                public Connection load(ConnectionFactory key) throws Exception {
+                public Connection load(@Nonnull ConnectionFactory key) throws Exception {
                   return key.createConnection();
                 }
               });
@@ -1091,7 +1092,7 @@ public class CalciteAssert {
     }
 
     @Override public int hashCode() {
-      return Objects.hashCode(map, postProcessors);
+      return Objects.hash(map, postProcessors);
     }
 
     public Connection createConnection() throws SQLException {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/core/src/test/java/org/apache/calcite/util/UtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/util/UtilTest.java b/core/src/test/java/org/apache/calcite/util/UtilTest.java
index 8bedcbc..42a2d78 100644
--- a/core/src/test/java/org/apache/calcite/util/UtilTest.java
+++ b/core/src/test/java/org/apache/calcite/util/UtilTest.java
@@ -24,6 +24,7 @@ import org.apache.calcite.linq4j.function.Function1;
 import org.apache.calcite.linq4j.function.Parameter;
 import org.apache.calcite.runtime.FlatLists;
 import org.apache.calcite.runtime.Resources;
+import org.apache.calcite.runtime.Utilities;
 import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.util.SqlBuilder;
 import org.apache.calcite.sql.util.SqlString;
@@ -1174,7 +1175,7 @@ public class UtilTest {
     }
   }
 
-  /** Unit test for {@link Util#hashCode(double)}. */
+  /** Unit test for {@link Utilities#hashCode(double)}. */
   @Test public void testHash() {
     checkHash(0d);
     checkHash(1d);
@@ -1187,7 +1188,14 @@ public class UtilTest {
   }
 
   public void checkHash(double v) {
-    assertThat(new Double(v).hashCode(), equalTo(Util.hashCode(v)));
+    assertThat(new Double(v).hashCode(), is(Utilities.hashCode(v)));
+    final long long_ = (long) v;
+    assertThat(new Long(long_).hashCode(), is(Utilities.hashCode(long_)));
+    final float float_ = (float) v;
+    assertThat(new Float(float_).hashCode(), is(Utilities.hashCode(float_)));
+    final boolean boolean_ = v != 0;
+    assertThat(Boolean.valueOf(boolean_).hashCode(),
+        is(Utilities.hashCode(boolean_)));
   }
 
   /** Unit test for {@link Util#startsWith}. */

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/linq4j/src/main/java/org/apache/calcite/linq4j/GroupingImpl.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/GroupingImpl.java b/linq4j/src/main/java/org/apache/calcite/linq4j/GroupingImpl.java
index de23558..42de3bf 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/GroupingImpl.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/GroupingImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.calcite.linq4j;
 
+import com.google.common.base.Preconditions;
+
 import java.util.Collection;
 import java.util.Map;
 
@@ -31,16 +33,19 @@ class GroupingImpl<K, V> extends AbstractEnumerable<V>
   private final Collection<V> values;
 
   GroupingImpl(K key, Collection<V> values) {
-    this.key = key;
-    this.values = values;
+    this.key = Preconditions.checkNotNull(key);
+    this.values = Preconditions.checkNotNull(values);
   }
 
   @Override public String toString() {
     return key + ": " + values;
   }
 
+  /** {@inheritDoc}
+   *
+   * <p>Computes hash code consistent with {@link Map.Entry#hashCode()}. */
   @Override public int hashCode() {
-    return (11 + key.hashCode()) * 37 + values.hashCode();
+    return key.hashCode() ^ values.hashCode();
   }
 
   @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/AbstractNode.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/AbstractNode.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/AbstractNode.java
index 4e73b29..c74adc6 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/AbstractNode.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/AbstractNode.java
@@ -17,6 +17,7 @@
 package org.apache.calcite.linq4j.tree;
 
 import java.lang.reflect.Type;
+import java.util.Objects;
 
 /**
  * Abstract implementation of {@link Node}.
@@ -95,9 +96,7 @@ public abstract class AbstractNode implements Node {
   }
 
   @Override public int hashCode() {
-    int result = nodeType != null ? nodeType.hashCode() : 0;
-    result = 31 * result + (type != null ? type.hashCode() : 0);
-    return result;
+    return Objects.hash(nodeType, type);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ArrayLengthRecordField.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ArrayLengthRecordField.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ArrayLengthRecordField.java
index 26cb55f..9071f11 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ArrayLengthRecordField.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ArrayLengthRecordField.java
@@ -18,6 +18,7 @@ package org.apache.calcite.linq4j.tree;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Type;
+import java.util.Objects;
 
 /**
  * Represents a length field of a RecordType
@@ -78,9 +79,7 @@ public class ArrayLengthRecordField implements Types.RecordField {
   }
 
   @Override public int hashCode() {
-    int result = fieldName.hashCode();
-    result = 31 * result + clazz.hashCode();
-    return result;
+    return Objects.hash(fieldName, clazz);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java
index 37cead1..eb73da3 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BinaryExpression.java
@@ -17,6 +17,7 @@
 package org.apache.calcite.linq4j.tree;
 
 import java.lang.reflect.Type;
+import java.util.Objects;
 
 /**
  * Represents an expression that has a binary operator.
@@ -191,11 +192,7 @@ public class BinaryExpression extends Expression {
   }
 
   @Override public int hashCode() {
-    int result = super.hashCode();
-    result = 31 * result + expression0.hashCode();
-    result = 31 * result + expression1.hashCode();
-    result = 31 * result + (primitive != null ? primitive.hashCode() : 0);
-    return result;
+    return Objects.hash(nodeType, type, expression0, expression1, primitive);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/ecf4d6dc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockStatement.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockStatement.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockStatement.java
index 364afeb..26a8c09 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockStatement.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockStatement.java
@@ -19,6 +19,7 @@ package org.apache.calcite.linq4j.tree;
 import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -40,7 +41,7 @@ public class BlockStatement extends Statement {
   }
 
   private boolean distinctVariables(boolean fail) {
-    Set<String> names = new HashSet<String>();
+    Set<String> names = new HashSet<>();
     for (Statement statement : statements) {
       if (statement instanceof DeclarationStatement) {
         String name = ((DeclarationStatement) statement).parameter.name;
@@ -103,8 +104,7 @@ public class BlockStatement extends Statement {
   @Override public int hashCode() {
     int result = hash;
     if (result == 0) {
-      result = super.hashCode();
-      result = 31 * result + statements.hashCode();
+      result = Objects.hash(nodeType, type, statements);
       if (result == 0) {
         result = 1;
       }


Mime
View raw message