cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix LazilyCompactedRowTest
Date Wed, 15 Feb 2012 15:42:44 GMT
Updated Branches:
  refs/heads/cassandra-1.0 984194d0c -> 636e41dc3


Fix LazilyCompactedRowTest

patch by slebresne; reviewed by driftx for CASSANDRA-3915


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

Branch: refs/heads/cassandra-1.0
Commit: 636e41dc3c1827ce438c98fb7a45c2a511083842
Parents: 984194d
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Feb 15 16:41:46 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Feb 15 16:41:46 2012 +0100

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/SuperColumn.java  |   28 +++++++++++++++
 .../cassandra/io/LazilyCompactedRowTest.java       |   12 +++---
 2 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/636e41dc/src/java/org/apache/cassandra/db/SuperColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SuperColumn.java b/src/java/org/apache/cassandra/db/SuperColumn.java
index 75f166c..4358e99 100644
--- a/src/java/org/apache/cassandra/db/SuperColumn.java
+++ b/src/java/org/apache/cassandra/db/SuperColumn.java
@@ -26,6 +26,9 @@ import java.security.MessageDigest;
 import java.util.Collection;
 import java.util.Comparator;
 
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.MarshalException;
@@ -301,6 +304,31 @@ public class SuperColumn extends AbstractColumnContainer implements IColumn
             column.validateFields(metadata);
         }
     }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+            return true;
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        SuperColumn sc = (SuperColumn)o;
+
+        if (!name.equals(sc.name))
+            return false;
+        if (getMarkedForDeleteAt() != sc.getMarkedForDeleteAt())
+            return false;
+        if (getLocalDeletionTime() != sc.getLocalDeletionTime())
+            return false;
+        return Iterables.elementsEqual(columns, sc.columns);
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return Objects.hashCode(name, getMarkedForDeleteAt(), getLocalDeletionTime(), columns);
+    }
 }
 
 class SuperColumnSerializer implements IColumnSerializer

http://git-wip-us.apache.org/repos/asf/cassandra/blob/636e41dc/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java b/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
index 94c71f5..65b2e7e 100644
--- a/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
+++ b/test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
@@ -66,7 +66,7 @@ public class LazilyCompactedRowTest extends CleanupHelper
         AbstractCompactionIterable lazy = new CompactionIterable(OperationType.UNKNOWN,
                                                                  sstables,
                                                                  new LazilyCompactingController(cfs,
sstables, gcBefore, false));
-        assertBytes(sstables, eager, lazy);
+        assertBytes(cfs, sstables, eager, lazy);
 
         // compare eager and parallel-lazy compactions
         eager = new CompactionIterable(OperationType.UNKNOWN,
@@ -76,10 +76,10 @@ public class LazilyCompactedRowTest extends CleanupHelper
                                                                              sstables,
                                                                              new CompactionController(cfs,
sstables, gcBefore, false),
                                                                              0);
-        assertBytes(sstables, eager, parallel);
+        assertBytes(cfs, sstables, eager, parallel);
     }
 
-    private static void assertBytes(Collection<SSTableReader> sstables, AbstractCompactionIterable
ci1, AbstractCompactionIterable ci2) throws IOException
+    private static void assertBytes(ColumnFamilyStore cfs, Collection<SSTableReader>
sstables, AbstractCompactionIterable ci1, AbstractCompactionIterable ci2) throws IOException
     {
         CloseableIterator<AbstractCompactedRow> iter1 = ci1.iterator();
         CloseableIterator<AbstractCompactedRow> iter2 = ci2.iterator();
@@ -132,8 +132,8 @@ public class LazilyCompactedRowTest extends CleanupHelper
             assert bytes1.equals(bytes2);
 
             // cf metadata
-            ColumnFamily cf1 = ColumnFamily.create("Keyspace1", "Standard1");
-            ColumnFamily cf2 = ColumnFamily.create("Keyspace1", "Standard1");
+            ColumnFamily cf1 = ColumnFamily.create(cfs.metadata);
+            ColumnFamily cf2 = ColumnFamily.create(cfs.metadata);
             ColumnFamily.serializer().deserializeFromSSTableNoColumns(cf1, in1);
             ColumnFamily.serializer().deserializeFromSSTableNoColumns(cf2, in2);
             assert cf1.getLocalDeletionTime() == cf2.getLocalDeletionTime();
@@ -145,7 +145,7 @@ public class LazilyCompactedRowTest extends CleanupHelper
             {
                 IColumn c1 = cf1.getColumnSerializer().deserialize(in1);
                 IColumn c2 = cf2.getColumnSerializer().deserialize(in2);
-                assert c1.equals(c2);
+                assert c1.equals(c2) : c1.getString(cfs.metadata.comparator) + " != " + c2.getString(cfs.metadata.comparator);
             }
             // that should be everything
             assert in1.available() == 0;


Mime
View raw message