You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bu...@apache.org on 2014/03/27 17:59:11 UTC

[3/6] git commit: ACCUMULO-2544: Fix match boundaries for MockTableOperations.deleteRows to be consistent with actual accumulo instance

ACCUMULO-2544: Fix match boundaries for MockTableOperations.deleteRows to be consistent with actual accumulo instance

Signed-off-by: Sean Busbey <bu...@cloudera.com>


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

Branch: refs/heads/master
Commit: 7ec60f1bcac4c274653d2779f1996138f3a275b7
Parents: 72c9af4
Author: Michael Fagan <mf...@arcus-research.com>
Authored: Tue Mar 25 14:58:37 2014 -0600
Committer: Sean Busbey <bu...@cloudera.com>
Committed: Thu Mar 27 11:42:39 2014 -0500

----------------------------------------------------------------------
 .../accumulo/core/client/mock/MockTableOperations.java  | 12 ++++++++----
 .../core/client/mock/MockTableOperationsTest.java       |  6 +++++-
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7ec60f1b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
index f088b1f..dc4a619 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
@@ -55,9 +55,9 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 
 public class MockTableOperations extends TableOperationsHelper {
-
-  final private MockAccumulo acu;
-  final private String username;
+  private static final byte[] ZERO = {0};
+  private final MockAccumulo acu;
+  private final String username;
 
   MockTableOperations(MockAccumulo acu, String username) {
     this.acu = acu;
@@ -314,7 +314,11 @@ public class MockTableOperations extends TableOperationsHelper {
     if (!exists(tableName))
       throw new TableNotFoundException(tableName, tableName, "");
     MockTable t = acu.tables.get(tableName);
-    Set<Key> keep = new TreeSet<Key>(t.table.tailMap(new Key(start)).headMap(new Key(end)).keySet());
+    Text startText = new Text(start);
+    Text endText = new Text(end);
+    startText.append(ZERO, 0, 1);
+    endText.append(ZERO, 0, 1);
+    Set<Key> keep = new TreeSet<Key>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
     t.table.keySet().removeAll(keep);
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7ec60f1b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
index da361b0..e377884 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
@@ -267,9 +267,13 @@ public class MockTableOperationsTest {
     bw.flush();
     to.deleteRows("test", new Text("1"), new Text("2"));
     Scanner s = connector.createScanner("test", Constants.NO_AUTHS);
+    int oneCnt = 0;
     for (Entry<Key,Value> entry : s) {
-      Assert.assertTrue(entry.getKey().getRow().toString().charAt(0) != '1');
+      char rowStart = entry.getKey().getRow().toString().charAt(0);
+      Assert.assertTrue(rowStart != '2');
+      oneCnt += rowStart == '1' ? 1 : 0;
     }
+    Assert.assertEquals(5, oneCnt);
   }
   
 }