accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [4/4] git commit: ACCUMULO-1800 fix deletes, added test
Date Tue, 22 Oct 2013 14:29:48 GMT
ACCUMULO-1800 fix deletes, added test


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

Branch: refs/heads/master
Commit: 8ec4cb840aff77bba3f3dc2e1b98a1c4de7c89ab
Parents: fb82945 3143b9c
Author: Eric Newton <eric.newton@gmail.com>
Authored: Tue Oct 22 10:30:07 2013 -0400
Committer: Eric Newton <eric.newton@gmail.com>
Committed: Tue Oct 22 10:30:07 2013 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/proxy/ProxyServer.java  | 12 +++++-----
 .../org/apache/accumulo/proxy/SimpleTest.java   | 24 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8ec4cb84/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --cc proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index cec8cfc,c6e74f1..ee993b9
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@@ -1161,41 -1144,6 +1161,41 @@@ public class ProxyServer implements Acc
      }
    }
    
 +  private void addUpdatesToMutation(HashMap<Text,ColumnVisibility> vizMap, Mutation
m, List<ColumnUpdate> cu) {
 +    for (ColumnUpdate update : cu) {
 +      ColumnVisibility viz = EMPTY_VIS;
 +      if (update.isSetColVisibility()) {
 +        viz = getCahcedCV(vizMap, update.getColVisibility());
 +      }
 +      byte[] value = new byte[0];
 +      if (update.isSetValue())
 +        value = update.getValue();
 +      if (update.isSetTimestamp()) {
 +        if (update.isSetDeleteCell()) {
 +          m.putDelete(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp());
 +        } else {
-           if (update.isSetDeleteCell()) {
-             m.putDelete(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp());
-           } else {
-             m.put(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp(),
value);
-           }
++          m.put(update.getColFamily(), update.getColQualifier(), viz, update.getTimestamp(),
value);
 +        }
 +      } else {
-         m.put(update.getColFamily(), update.getColQualifier(), viz, value);
++        if (update.isSetDeleteCell()) {
++          m.putDelete(new Text(update.getColFamily()), new Text(update.getColQualifier()),
viz);
++        } else {
++          m.put(new Text(update.getColFamily()), new Text(update.getColQualifier()), viz,
new Value(value));
++        }
 +      }
 +    }
 +  }
 +  
 +  private static ColumnVisibility getCahcedCV(HashMap<Text,ColumnVisibility> vizMap,
byte[] cv) {
 +    ColumnVisibility viz;
 +    Text vizText = new Text(cv);
 +    viz = vizMap.get(vizText);
 +    if (viz == null) {
 +      vizMap.put(vizText, viz = new ColumnVisibility(vizText));
 +    }
 +    return viz;
 +  }
 +  
    @Override
    public String createWriter(ByteBuffer login, String tableName, WriterOptions opts) throws
org.apache.accumulo.proxy.thrift.AccumuloException,
        org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
TException {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8ec4cb84/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --cc proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index 242ef08,3bd552d..8b1ab8b
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@@ -699,8 -678,33 +699,32 @@@ public class SimpleTest 
        fail("exception not thrown");
      } catch (UnknownWriter uw) {}
    }
 -  
 +
    @Test(timeout = 10000)
+   public void testDelete() throws Exception {
 -    if (client.tableExists(creds, TABLE_TEST))
 -      client.deleteTable(creds, TABLE_TEST);
++    final String TABLE_TEST = makeTableName();
+ 
+     client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
+     client.updateAndFlush(creds, TABLE_TEST, mutation("row0", "cf", "cq", "value"));
+     String scanner = client.createScanner(creds, TABLE_TEST, null);
+     ScanResult entries = client.nextK(scanner, 10);
+     client.closeScanner(scanner);
+     assertFalse(entries.more);
+     assertEquals(1, entries.results.size());
+     
+     ColumnUpdate upd = new ColumnUpdate(s2bb("cf"), s2bb("cq"));
+     upd.setDeleteCell(true);
+     Map<ByteBuffer,List<ColumnUpdate>> delete = Collections.singletonMap(s2bb("row0"),
Collections.singletonList(upd));
+     
+     client.updateAndFlush(creds, TABLE_TEST, delete);
+     
+     scanner = client.createScanner(creds, TABLE_TEST, null);
+     entries = client.nextK(scanner, 10);
+     client.closeScanner(scanner);
+     assertEquals(0, entries.results.size());
+   }
+ 
+   @Test(timeout = 10000)
    public void testInstanceOperations() throws Exception {
      int tservers = 0;
      for (String tserver : client.getTabletServers(creds)) {


Mime
View raw message