parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject parquet-mr git commit: PARQUET-314: Fix broken equals implementations
Date Mon, 22 Jun 2015 19:37:50 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master 079bcd033 -> 29283b775


PARQUET-314: Fix broken equals implementations

Author: Nezih Yigitbasi <nyigitbasi@netflix.com>

Closes #223 from nezihyigitbasi/parquet-fixes and squashes the following commits:

5279e60 [Nezih Yigitbasi] Override Object.equals properly


Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/29283b77
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/29283b77
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/29283b77

Branch: refs/heads/master
Commit: 29283b775291bf03cd9a7e1aaa496faaa5757578
Parents: 079bcd0
Author: Nezih Yigitbasi <nyigitbasi@netflix.com>
Authored: Mon Jun 22 12:37:37 2015 -0700
Committer: Ryan Blue <blue@apache.org>
Committed: Mon Jun 22 12:37:37 2015 -0700

----------------------------------------------------------------------
 .../org/apache/parquet/column/ColumnDescriptor.java  |  9 +++++++--
 .../apache/parquet/column/statistics/Statistics.java | 15 +++++++++++----
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/29283b77/parquet-column/src/main/java/org/apache/parquet/column/ColumnDescriptor.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/ColumnDescriptor.java
b/parquet-column/src/main/java/org/apache/parquet/column/ColumnDescriptor.java
index 5a44116..8244913 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/ColumnDescriptor.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/ColumnDescriptor.java
@@ -106,8 +106,13 @@ public class ColumnDescriptor implements Comparable<ColumnDescriptor>
{
   }
 
   @Override
-  public boolean equals(Object obj) {
-    return Arrays.equals(path, ((ColumnDescriptor)obj).path);
+  public boolean equals(Object other) {
+    if (other == this)
+      return true;
+    if (!(other instanceof ColumnDescriptor))
+      return false;
+    ColumnDescriptor descriptor = (ColumnDescriptor) other;
+    return Arrays.equals(path, descriptor.path);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/29283b77/parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java
----------------------------------------------------------------------
diff --git a/parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java
b/parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java
index ba135f5..5424414 100644
--- a/parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java
+++ b/parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java
@@ -117,19 +117,26 @@ public abstract class Statistics<T extends Comparable<T>>
{
 
   /**
    * Equality comparison method to compare two statistics objects.
-   * @param stats Statistics object to compare against
+   * @param other Object to compare against
    * @return true if objects are equal, false otherwise
    */
-  public boolean equals(Statistics stats) {
+  @Override
+  public boolean equals(Object other) {
+    if (other == this)
+      return true;
+    if (!(other instanceof Statistics))
+      return false;
+    Statistics stats = (Statistics) other;
     return Arrays.equals(stats.getMaxBytes(), this.getMaxBytes()) &&
-           Arrays.equals(stats.getMinBytes(), this.getMinBytes()) &&
-           stats.getNumNulls() == this.getNumNulls();
+            Arrays.equals(stats.getMinBytes(), this.getMinBytes()) &&
+            stats.getNumNulls() == this.getNumNulls();
   }
 
   /**
    * Hash code for the statistics object
    * @return hash code int
    */
+  @Override
   public int hashCode() {
     return 31 * Arrays.hashCode(getMaxBytes()) + 17 * Arrays.hashCode(getMinBytes()) + Long.valueOf(this.getNumNulls()).hashCode();
   }


Mime
View raw message