cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [2/6] cassandra git commit: Fix broken BTreeRow.hashCode
Date Wed, 09 Mar 2016 14:28:28 GMT
Fix broken BTreeRow.hashCode

Patch by Branimir Lambov; reviewed by marcuse for CASSANDRA-11316


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

Branch: refs/heads/cassandra-3.5
Commit: f6af142f1e8e9fa86f88b8c3c8bcb9a7294ef0cc
Parents: c2b47ba
Author: Branimir Lambov <branimir.lambov@datastax.com>
Authored: Tue Mar 8 16:19:57 2016 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Mar 9 15:26:44 2016 +0100

----------------------------------------------------------------------
 .../apache/cassandra/db/rows/AbstractRow.java   |  2 +-
 test/unit/org/apache/cassandra/db/RowTest.java  | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f6af142f/src/java/org/apache/cassandra/db/rows/AbstractRow.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/rows/AbstractRow.java b/src/java/org/apache/cassandra/db/rows/AbstractRow.java
index 0295e2e..59addeb 100644
--- a/src/java/org/apache/cassandra/db/rows/AbstractRow.java
+++ b/src/java/org/apache/cassandra/db/rows/AbstractRow.java
@@ -178,7 +178,7 @@ public abstract class AbstractRow extends AbstractCollection<ColumnData>
impleme
     @Override
     public int hashCode()
     {
-        int hash = Objects.hash(clustering(), columns(), primaryKeyLivenessInfo(), deletion());
+        int hash = Objects.hash(clustering(), primaryKeyLivenessInfo(), deletion());
         for (ColumnData cd : this)
             hash += 31 * cd.hashCode();
         return hash;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f6af142f/test/unit/org/apache/cassandra/db/RowTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowTest.java b/test/unit/org/apache/cassandra/db/RowTest.java
index 0af183c..e3f4884 100644
--- a/test/unit/org/apache/cassandra/db/RowTest.java
+++ b/test/unit/org/apache/cassandra/db/RowTest.java
@@ -19,6 +19,8 @@
 package org.apache.cassandra.db;
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 import com.google.common.collect.ImmutableList;
 import org.junit.Before;
@@ -165,6 +167,24 @@ public class RowTest
         Util.assertEmpty(Util.cmd(cfs, dk).includeRow("c1").withNowInSeconds(nowInSeconds
+ ttl + 1).build());
     }
 
+    @Test
+    public void testHashCode()
+    {
+        ColumnDefinition defA = cfm.getColumnDefinition(new ColumnIdentifier("a", true));
+        ColumnDefinition defB = cfm.getColumnDefinition(new ColumnIdentifier("b", true));
+
+        Row.Builder builder = BTreeRow.unsortedBuilder(nowInSeconds);
+        builder.newRow(cfm.comparator.make("c1"));
+        writeSimpleCellValue(builder, cfm, defA, "a1", 0);
+        writeSimpleCellValue(builder, cfm, defA, "a2", 1);
+        writeSimpleCellValue(builder, cfm, defB, "b1", 1);
+        Row row = builder.build();
+
+        Map<Row, Integer> map = new HashMap<>();
+        map.put(row, 1);
+        assertEquals(Integer.valueOf(1), map.get(row));
+    }
+
     private void assertRangeTombstoneMarkers(Slice.Bound start, Slice.Bound end, DeletionTime
deletionTime, Object[] expected)
     {
         AbstractType clusteringType = (AbstractType)cfm.comparator.subtype(0);


Mime
View raw message