accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [1/2] git commit: ACCUMULO-1626 fixed equals method in mutation
Date Wed, 31 Jul 2013 16:22:05 GMT
Updated Branches:
  refs/heads/1.5.1-SNAPSHOT 8622b4d67 -> 6eddb392a


ACCUMULO-1626 fixed equals method in mutation


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

Branch: refs/heads/1.5.1-SNAPSHOT
Commit: acc4fd16f6390579c82e9635a3fa614f3822bfba
Parents: 3e97167
Author: Keith Turner <keith@deenlo.com>
Authored: Wed Jul 31 11:48:15 2013 -0400
Committer: Keith Turner <keith@deenlo.com>
Committed: Wed Jul 31 11:48:15 2013 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/data/Mutation.java |  1 +
 .../apache/accumulo/core/data/MutationTest.java | 69 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/acc4fd16/src/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/data/Mutation.java b/src/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
index 4e21b6d..3979da9 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/data/Mutation.java
@@ -495,6 +495,7 @@ public class Mutation implements Writable {
   
   public boolean equals(Mutation m) {
     serialize();
+    m.serialize();
     if (Arrays.equals(row, m.row) && entries == m.entries && Arrays.equals(data,
m.data)) {
       if (values == null && m.values == null)
         return true;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/acc4fd16/src/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
----------------------------------------------------------------------
diff --git a/src/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java b/src/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
index d50c15e..38ddcad 100644
--- a/src/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
+++ b/src/core/src/test/java/org/apache/accumulo/core/data/MutationTest.java
@@ -347,4 +347,73 @@ public class MutationTest extends TestCase {
     assertEquals(m2.getUpdates().get(1), "cf2", "cq2", "cv2", 0l, false, false, "v2");
     
   }
+  
+  public void testEquals() {
+    Mutation m1 = new Mutation("r1");
+    
+    m1.put("cf1", "cq1", "v1");
+    m1.put("cf1", "cq1", new ColumnVisibility("A&B"), "v2");
+    m1.put("cf1", "cq1", 3, "v3");
+    m1.put("cf1", "cq1", new ColumnVisibility("A&B&C"), 4, "v4");
+    m1.putDelete("cf2", "cf3");
+    m1.putDelete("cf2", "cf4", 3);
+    m1.putDelete("cf2", "cf4", new ColumnVisibility("A&B&C"), 3);
+    
+    // m2 has same data as m1
+    Mutation m2 = new Mutation("r1");
+    
+    m2.put("cf1", "cq1", "v1");
+    m2.put("cf1", "cq1", new ColumnVisibility("A&B"), "v2");
+    m2.put("cf1", "cq1", 3, "v3");
+    m2.put("cf1", "cq1", new ColumnVisibility("A&B&C"), 4, "v4");
+    m2.putDelete("cf2", "cf3");
+    m2.putDelete("cf2", "cf4", 3);
+    m2.putDelete("cf2", "cf4", new ColumnVisibility("A&B&C"), 3);
+    
+    // m3 has differnt row than m1
+    Mutation m3 = new Mutation("r2");
+    
+    m3.put("cf1", "cq1", "v1");
+    m3.put("cf1", "cq1", new ColumnVisibility("A&B"), "v2");
+    m3.put("cf1", "cq1", 3, "v3");
+    m3.put("cf1", "cq1", new ColumnVisibility("A&B&C"), 4, "v4");
+    m3.putDelete("cf2", "cf3");
+    m3.putDelete("cf2", "cf4", 3);
+    m3.putDelete("cf2", "cf4", new ColumnVisibility("A&B&C"), 3);
+
+    // m4 has a different column than m1
+    Mutation m4 = new Mutation("r1");
+    
+    m4.put("cf2", "cq1", "v1");
+    m4.put("cf1", "cq1", new ColumnVisibility("A&B"), "v2");
+    m4.put("cf1", "cq1", 3, "v3");
+    m4.put("cf1", "cq1", new ColumnVisibility("A&B&C"), 4, "v4");
+    m4.putDelete("cf2", "cf3");
+    m4.putDelete("cf2", "cf4", 3);
+    m4.putDelete("cf2", "cf4", new ColumnVisibility("A&B&C"), 3);
+    
+    // m5 has a different value than m1
+    Mutation m5 = new Mutation("r1");
+    
+    m5.put("cf1", "cq1", "v1");
+    m5.put("cf1", "cq1", new ColumnVisibility("A&B"), "v2");
+    m5.put("cf1", "cq1", 3, "v4");
+    m5.put("cf1", "cq1", new ColumnVisibility("A&B&C"), 4, "v4");
+    m5.putDelete("cf2", "cf3");
+    m5.putDelete("cf2", "cf4", 3);
+    m5.putDelete("cf2", "cf4", new ColumnVisibility("A&B&C"), 3);
+
+    assertEquals(m1, m1);
+    assertEquals(m1, m2);
+    assertEquals(m2, m1);
+    assertFalse(m1.equals(m3));
+    assertFalse(m3.equals(m1));
+    assertFalse(m1.equals(m4));
+    assertFalse(m4.equals(m1));
+    assertFalse(m3.equals(m4));
+    assertFalse(m1.equals(m5));
+    assertFalse(m5.equals(m1));
+    assertFalse(m3.equals(m5));
+    assertFalse(m4.equals(m5));
+  }
 }


Mime
View raw message