fluo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [1/2] incubator-fluo git commit: Fixes #740 - Use Java hashcode helper methods. * Removed hashCode() method from Bytes. * Add hashCode() method to MutableBytes. * Used Java helper methods for hashCode() methods in data classes. * Added test to BytesT
Date Mon, 01 Aug 2016 15:38:52 GMT
Repository: incubator-fluo
Updated Branches:
  refs/heads/master 69f8369c7 -> 540097174


Fixes #740 - Use Java hashcode helper methods.
*  Removed hashCode() method from Bytes.
*  Add hashCode() method to MutableBytes.
*  Used Java helper methods for hashCode() methods in data classes.
*  Added test to BytesTest to check for proper hashing.


Project: http://git-wip-us.apache.org/repos/asf/incubator-fluo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fluo/commit/61a43a7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fluo/tree/61a43a7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fluo/diff/61a43a7b

Branch: refs/heads/master
Commit: 61a43a7b84db631b8bd8a58e0a802c367f5dda7b
Parents: 051a33b
Author: Christopher McTague <cjmctague@vwc.edu>
Authored: Thu Jul 28 14:35:28 2016 -0400
Committer: Keith Turner <kturner@apache.org>
Committed: Mon Aug 1 10:46:25 2016 -0400

----------------------------------------------------------------------
 .../api/src/main/java/org/apache/fluo/api/data/Column.java   | 2 +-
 .../src/main/java/org/apache/fluo/api/data/ColumnValue.java  | 3 ++-
 .../src/main/java/org/apache/fluo/api/data/RowColumn.java    | 2 +-
 .../main/java/org/apache/fluo/api/data/RowColumnValue.java   | 4 +++-
 .../src/test/java/org/apache/fluo/core/data/BytesTest.java   | 8 ++++++++
 .../test/java/org/apache/fluo/core/data/RowColumnTest.java   | 2 +-
 6 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/api/src/main/java/org/apache/fluo/api/data/Column.java
----------------------------------------------------------------------
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/Column.java b/modules/api/src/main/java/org/apache/fluo/api/data/Column.java
index 8d17a93..0c0ed29 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/Column.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/Column.java
@@ -172,7 +172,7 @@ public class Column implements Comparable<Column>, Serializable
{
 
   @Override
   public int hashCode() {
-    return family.hashCode() + 31 * (31 * qualifier.hashCode() + visibility.hashCode());
+    return Objects.hash(family, qualifier, visibility);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/api/src/main/java/org/apache/fluo/api/data/ColumnValue.java
----------------------------------------------------------------------
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/ColumnValue.java b/modules/api/src/main/java/org/apache/fluo/api/data/ColumnValue.java
index 4080e8c..92def93 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/ColumnValue.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/ColumnValue.java
@@ -16,6 +16,7 @@
 package org.apache.fluo.api.data;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * @since 1.0.0
@@ -73,7 +74,7 @@ public class ColumnValue implements Serializable, Comparable<ColumnValue>
{
 
   @Override
   public int hashCode() {
-    return column.hashCode() + 31 * val.hashCode();
+    return Objects.hash(column, val);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java
----------------------------------------------------------------------
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java
index 1fa43d7..28ead11 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumn.java
@@ -122,7 +122,7 @@ public class RowColumn implements Comparable<RowColumn>, Serializable
{
 
   @Override
   public int hashCode() {
-    return row.hashCode() + 31 * col.hashCode();
+    return Objects.hash(row, col);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumnValue.java
----------------------------------------------------------------------
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/RowColumnValue.java b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumnValue.java
index de32948..f1a325e 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/RowColumnValue.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/RowColumnValue.java
@@ -15,6 +15,8 @@
 
 package org.apache.fluo.api.data;
 
+import java.util.Objects;
+
 /**
  * An immutable object that can hold a row, column, and value.
  *
@@ -49,7 +51,7 @@ public class RowColumnValue extends RowColumn {
 
   @Override
   public int hashCode() {
-    return super.hashCode() + 31 * val.hashCode();
+    return Objects.hash(super.hashCode(), val);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/core/src/test/java/org/apache/fluo/core/data/BytesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/fluo/core/data/BytesTest.java b/modules/core/src/test/java/org/apache/fluo/core/data/BytesTest.java
index 00eee55..7512a51 100644
--- a/modules/core/src/test/java/org/apache/fluo/core/data/BytesTest.java
+++ b/modules/core/src/test/java/org/apache/fluo/core/data/BytesTest.java
@@ -82,6 +82,14 @@ public class BytesTest {
   }
 
   @Test
+  public void testHashSubsequence() {
+    Bytes b1 = Bytes.of("abcde");
+    Bytes b2 = Bytes.of("cde");
+
+    Assert.assertEquals(b2.hashCode(), b1.subSequence(2, 5).hashCode());
+  }
+
+  @Test
   public void testCompare() {
     Bytes b1 = Bytes.of("a");
     Bytes b2 = Bytes.of("b");

http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/61a43a7b/modules/core/src/test/java/org/apache/fluo/core/data/RowColumnTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/fluo/core/data/RowColumnTest.java b/modules/core/src/test/java/org/apache/fluo/core/data/RowColumnTest.java
index dfd51e5..e3e3a04 100644
--- a/modules/core/src/test/java/org/apache/fluo/core/data/RowColumnTest.java
+++ b/modules/core/src/test/java/org/apache/fluo/core/data/RowColumnTest.java
@@ -50,7 +50,7 @@ public class RowColumnTest {
     Assert.assertEquals(new Column("cf2"), rc.getColumn());
     Assert.assertEquals(new RowColumn(Bytes.of("r2"), new Column("cf2")), rc);
     Assert.assertEquals("r2 cf2  ", rc.toString());
-    Assert.assertEquals(4007699, rc.hashCode());
+    Assert.assertEquals(123316141, rc.hashCode());
   }
 
   @Test


Mime
View raw message