accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1339751 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/client/mock/ main/java/org/apache/accumulo/core/util/format/ main/java/org/apache/accumulo/core/util/shell/ main/java/org/apache/accumulo/core/util/shell/commands/ t...
Date Thu, 17 May 2012 18:01:34 GMT
Author: billie
Date: Thu May 17 18:01:33 2012
New Revision: 1339751

URL: http://svn.apache.org/viewvc?rev=1339751&view=rev
Log:
ACCUMULO-596 enabled support for additional hex characters, started a shell unit test that can't wait to be expanded to test more commands

Added:
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java   (with props)
Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetGroupsCommand.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java Thu May 17 18:01:33 2012
@@ -16,9 +16,11 @@
  */
 package org.apache.accumulo.core.client.mock;
 
+import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.SortedSet;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchScanner;
@@ -27,6 +29,7 @@ import org.apache.accumulo.core.data.Mut
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.SystemPermission;
 import org.apache.accumulo.core.security.TablePermission;
+import org.apache.hadoop.io.Text;
 
 public class MockAccumulo {
   final Map<String,MockTable> tables = new HashMap<String,MockTable>();
@@ -60,10 +63,18 @@ public class MockAccumulo {
   public BatchScanner createBatchScanner(String tableName, Authorizations authorizations) {
     return new MockBatchScanner(tables.get(tableName), authorizations);
   }
-
+  
   public void createTable(String username, String tableName, boolean useVersions, TimeType timeType) {
     MockTable t = new MockTable(useVersions, timeType);
     t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
     tables.put(tableName, t);
   }
+  
+  public void addSplits(String tableName, SortedSet<Text> partitionKeys) {
+    tables.get(tableName).addSplits(partitionKeys);
+  }
+  
+  public Collection<Text> getSplits(String tableName) {
+    return tables.get(tableName).getSplits();
+  }
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java Thu May 17 18:01:33 2012
@@ -16,11 +16,14 @@
  */
 package org.apache.accumulo.core.client.mock;
 
+import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeSet;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 import org.apache.accumulo.core.client.admin.TimeType;
@@ -32,6 +35,7 @@ import org.apache.accumulo.core.data.Mut
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.IteratorUtil;
 import org.apache.accumulo.core.security.TablePermission;
+import org.apache.hadoop.io.Text;
 
 public class MockTable {
   
@@ -82,6 +86,7 @@ public class MockTable {
   final Map<String,String> settings;
   Map<String,EnumSet<TablePermission>> userPermissions = new HashMap<String,EnumSet<TablePermission>>();
   private TimeType timeType;
+  SortedSet<Text> splits = new TreeSet<Text>();
   
   MockTable(boolean useVersions, TimeType timeType) {
     this.timeType = timeType;
@@ -110,4 +115,12 @@ public class MockTable {
       table.put(new MockMemKey(key, mutationCount), new Value(u.getValue()));
     }
   }
+  
+  public void addSplits(SortedSet<Text> partitionKeys) {
+    splits.addAll(partitionKeys);
+  }
+  
+  public Collection<Text> getSplits() {
+    return splits;
+  }
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java Thu May 17 18:01:33 2012
@@ -84,14 +84,16 @@ public class MockTableOperations extends
   
   @Override
   public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
-    throw new NotImplementedException();
+    if (!exists(tableName))
+      throw new TableNotFoundException(tableName, tableName, "");
+    acu.addSplits(tableName, partitionKeys);
   }
   
   @Override
   public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
     if (!exists(tableName))
       throw new TableNotFoundException(tableName, tableName, "");
-    return Collections.emptyList();
+    return acu.getSplits(tableName);
   }
   
   @Override

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/format/BinaryFormatter.java Thu May 17 18:01:33 2012
@@ -87,7 +87,7 @@ public class BinaryFormatter implements 
     return sb.toString();
   }
   
-  static StringBuilder appendText(StringBuilder sb, Text t) {
+  public static StringBuilder appendText(StringBuilder sb, Text t) {
     return appendBytes(sb, t.getBytes(), 0, t.getLength());
   }
   

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java Thu May 17 18:01:33 2012
@@ -149,6 +149,7 @@ public class Shell extends ShellOptions 
   public static final Logger log = Logger.getLogger(Shell.class);
   private static final Logger audit = Logger.getLogger(Shell.class.getName() + ".audit");
   
+  public static final String CHARSET = "ISO-8859-1";
   public static final int NO_FIXED_ARG_LENGTH_CHECK = -1;
   private static final String SHELL_DESCRIPTION = "Shell - Apache Accumulo Interactive Shell";
   private static final String DEFAULT_AUTH_TIMEOUT = "60"; // in minutes
@@ -863,6 +864,14 @@ public class Shell extends ShellOptions 
     pw.flush();
   }
   
+  public int getExitCode() {
+    return exitCode;
+  }
+  
+  public void resetExitCode() {
+    exitCode = 0;
+  }
+  
   public void setExit(boolean exit) {
     this.exit = exit;
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java Thu May 17 18:01:33 2012
@@ -33,7 +33,7 @@ public class AddSplitsCommand extends Co
   private Option optSplitsFile, base64Opt;
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     boolean decode = cl.hasOption(base64Opt.getOpt());
     
     TreeSet<Text> splits = new TreeSet<Text>();
@@ -53,7 +53,7 @@ public class AddSplitsCommand extends Co
         throw new MissingArgumentException("No split points specified");
       
       for (String s : cl.getArgs()) {
-        splits.add(new Text(s));
+        splits.add(new Text(s.getBytes(Shell.CHARSET)));
       }
     }
     
@@ -76,7 +76,7 @@ public class AddSplitsCommand extends Co
     optSplitsFile = new Option("sf", "splits-file", true, "file with a newline-separated list of rows to split the table with");
     optSplitsFile.setArgName("filename");
     
-    base64Opt = new Option("b64", "base64encoded", false, "decode encoded split points");
+    base64Opt = new Option("b64", "base64encoded", false, "decode encoded split points (splits file only)");
     
     o.addOption(OptUtil.tableOpt("name of the table to add split points to"));
     o.addOption(optSplitsFile);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java Thu May 17 18:01:33 2012
@@ -25,7 +25,7 @@ import org.apache.commons.cli.Options;
 import org.apache.hadoop.io.Text;
 
 public class CompactCommand extends TableOperation {
-  private Option optStartRow, optEndRow, noFlushOption, waitOpt;
+  private Option noFlushOption, waitOpt;
   private boolean flush;
   private Text startRow;
   private Text endRow;
@@ -55,12 +55,8 @@ public class CompactCommand extends Tabl
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
     flush = !cl.hasOption(noFlushOption.getOpt());
-    startRow = null;
-    if (cl.hasOption(optStartRow.getOpt()))
-      startRow = new Text(cl.getOptionValue(optStartRow.getOpt()));
-    endRow = null;
-    if (cl.hasOption(optEndRow.getOpt()))
-      endRow = new Text(cl.getOptionValue(optEndRow.getOpt()));
+    startRow = OptUtil.getStartRow(cl);
+    endRow = OptUtil.getEndRow(cl);
     wait = cl.hasOption(waitOpt.getOpt());
     
     return super.execute(fullCommand, cl, shellState);
@@ -70,10 +66,8 @@ public class CompactCommand extends Tabl
   public Options getOptions() {
     Options opts = super.getOptions();
     
-    optStartRow = new Option("b", "begin-row", true, "begin row");
-    opts.addOption(optStartRow);
-    optEndRow = new Option("e", "end-row", true, "end row");
-    opts.addOption(optEndRow);
+    opts.addOption(OptUtil.startRowOpt());
+    opts.addOption(OptUtil.endRowOpt());
     noFlushOption = new Option("nf", "noFlush", false, "do not flush table data in memory before compacting.");
     opts.addOption(noFlushOption);
     waitOpt = new Option("w", "wait", false, "wait for compact to finish");

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java Thu May 17 18:01:33 2012
@@ -29,10 +29,10 @@ import org.apache.commons.cli.Options;
 public class ConstraintCommand extends Command {
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     int i;
     
-    switch (OptUtil.configureAldOpt(cl)) {
+    switch (OptUtil.getAldOpt(cl)) {
       case ADD:
         for (String constraint : cl.getArgs()) {
           if (!shellState.getConnector().instanceOperations().testClassLoad(constraint, Constraint.class.getName()))

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java Thu May 17 18:01:33 2012
@@ -39,18 +39,20 @@ public class DeleteCommand extends Comma
       IOException, ConstraintViolationException {
     shellState.checkTableState();
     
-    Mutation m = new Mutation(new Text(cl.getArgs()[0]));
+    Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
+    Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
+    Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
     
     if (cl.hasOption(deleteOptAuths.getOpt())) {
       ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(deleteOptAuths.getOpt()));
       if (cl.hasOption(timestampOpt.getOpt()))
-        m.putDelete(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
+        m.putDelete(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
       else
-        m.putDelete(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), le);
+        m.putDelete(colf, colq, le);
     } else if (cl.hasOption(timestampOpt.getOpt()))
-      m.putDelete(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
+      m.putDelete(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
     else
-      m.putDelete(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]));
+      m.putDelete(colf, colq);
     
     BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(), m.estimatedMemoryUsed() + 0L, 0L, 1);
     bw.addMutation(m);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java Thu May 17 18:01:33 2012
@@ -29,7 +29,7 @@ public class DeleteIterCommand extends C
   private Option mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt;
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     String name = cl.getOptionValue(nameOpt.getOpt());
     if (!shellState.getConnector().tableOperations().listIterators(tableName).containsKey(name)) {

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java Thu May 17 18:01:33 2012
@@ -38,7 +38,7 @@ public class DeleteManyCommand extends S
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, ParseException {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     // handle first argument, if present, the authorizations list to
     // scan with

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java Thu May 17 18:01:33 2012
@@ -24,17 +24,13 @@ import org.apache.commons.cli.Options;
 import org.apache.hadoop.io.Text;
 
 public class DeleteRowsCommand extends Command {
-  private Option optStartRow, optEndRow, forceOpt;
+  private Option forceOpt;
   
   @Override
   public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
-    Text startRow = null;
-    if (cl.hasOption(optStartRow.getOpt()))
-      startRow = new Text(cl.getOptionValue(optStartRow.getOpt()));
-    Text endRow = null;
-    if (cl.hasOption(optEndRow.getOpt()))
-      endRow = new Text(cl.getOptionValue(optEndRow.getOpt()));
+    String tableName = OptUtil.getTableOpt(cl, shellState);
+    Text startRow = OptUtil.getStartRow(cl);
+    Text endRow = OptUtil.getEndRow(cl);
     if (!cl.hasOption(forceOpt.getOpt()) && (startRow == null || endRow == null)) {
       shellState.getReader().printString("Not deleting unbounded range. Specify both ends, or use --force\n");
       return 1;
@@ -56,11 +52,9 @@ public class DeleteRowsCommand extends C
   @Override
   public Options getOptions() {
     Options o = new Options();
-    optStartRow = new Option("b", "begin-row", true, "begin row");
-    optEndRow = new Option("e", "end-row", true, "end row");
     forceOpt = new Option("f", "force", false, "delete data even if start or end are not specified");
-    o.addOption(optStartRow);
-    o.addOption(optEndRow);
+    o.addOption(OptUtil.startRowOpt());
+    o.addOption(OptUtil.endRowOpt());
     o.addOption(OptUtil.tableOpt("table to delete a row range from"));
     o.addOption(forceOpt);
     return o;

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java Thu May 17 18:01:33 2012
@@ -32,7 +32,7 @@ public class DeleteScanIterCommand exten
   
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     if (cl.hasOption(allOpt.getOpt())) {
       List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.remove(tableName);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java Thu May 17 18:01:33 2012
@@ -31,7 +31,7 @@ public class FlushCommand extends TableO
   private Text endRow;
   
   private boolean wait;
-  private Option optStartRow, optEndRow, waitOpt;
+  private Option waitOpt;
   
   @Override
   public String description() {
@@ -52,12 +52,8 @@ public class FlushCommand extends TableO
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
     wait = cl.hasOption(waitOpt.getLongOpt());
-    startRow = null;
-    if (cl.hasOption(optStartRow.getOpt()))
-      startRow = new Text(cl.getOptionValue(optStartRow.getOpt()));
-    endRow = null;
-    if (cl.hasOption(optEndRow.getOpt()))
-      endRow = new Text(cl.getOptionValue(optEndRow.getOpt()));
+    startRow = OptUtil.getStartRow(cl);
+    endRow = OptUtil.getEndRow(cl);
     return super.execute(fullCommand, cl, shellState);
   }
   
@@ -66,10 +62,8 @@ public class FlushCommand extends TableO
     Options opts = super.getOptions();
     waitOpt = new Option("w", "wait", false, "wait for flush to finish");
     opts.addOption(waitOpt);
-    optStartRow = new Option("b", "begin-row", true, "begin row");
-    opts.addOption(optStartRow);
-    optEndRow = new Option("e", "end-row", true, "end row");
-    opts.addOption(optEndRow);
+    opts.addOption(OptUtil.startRowOpt());
+    opts.addOption(OptUtil.endRowOpt());
     
     return opts;
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java Thu May 17 18:01:33 2012
@@ -41,7 +41,7 @@ public class FormatterCommand extends Co
   
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     if (cl.hasOption(removeFormatterOption.getOpt())) {
       // Remove the property

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java Thu May 17 18:01:33 2012
@@ -31,7 +31,7 @@ public class GetGroupsCommand extends Co
   
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     Map<String,Set<Text>> groups = shellState.getConnector().tableOperations().getLocalityGroups(tableName);
     

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java Thu May 17 18:01:33 2012
@@ -33,6 +33,7 @@ import org.apache.accumulo.core.data.Ran
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.util.ColumnFQ;
 import org.apache.accumulo.core.util.TextUtil;
+import org.apache.accumulo.core.util.format.BinaryFormatter;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.accumulo.core.util.shell.Shell.Command;
 import org.apache.accumulo.core.util.shell.Shell.PrintFile;
@@ -51,7 +52,7 @@ public class GetSplitsCommand extends Co
   @Override
   public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
       TableNotFoundException {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
     final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
@@ -97,7 +98,8 @@ public class GetSplitsCommand extends Co
   private static String encode(boolean encode, Text text) {
     if (text == null)
       return null;
-    return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text))) : text.toString();
+    BinaryFormatter.getlength(text.getLength());
+    return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text))) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
   }
   
   private static String obscuredTabletName(KeyExtent extent) {

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java Thu May 17 18:01:33 2012
@@ -39,7 +39,7 @@ public class GrepCommand extends ScanCom
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, MissingArgumentException {
     
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     if (cl.getArgList().isEmpty())
       throw new MissingArgumentException("No terms specified");

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java Thu May 17 18:01:33 2012
@@ -44,22 +44,23 @@ public class InsertCommand extends Comma
       IOException, ConstraintViolationException {
     shellState.checkTableState();
     
-    Mutation m = new Mutation(new Text(cl.getArgs()[0]));
+    Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
+    Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
+    Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
+    Value val = new Value(cl.getArgs()[3].getBytes(Shell.CHARSET));
     
     if (cl.hasOption(insertOptAuths.getOpt())) {
       ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(insertOptAuths.getOpt()));
       Shell.log.debug("Authorization label will be set to: " + le.toString());
       
       if (cl.hasOption(timestampOpt.getOpt()))
-        m.put(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())),
-            new Value(cl.getArgs()[3].getBytes()));
+        m.put(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
       else
-        m.put(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), le, new Value(cl.getArgs()[3].getBytes()));
+        m.put(colf, colq, le, val);
     } else if (cl.hasOption(timestampOpt.getOpt()))
-      m.put(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())),
-          new Value(cl.getArgs()[3].getBytes()));
+      m.put(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
     else
-      m.put(new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]), new Value(cl.getArgs()[3].getBytes()));
+      m.put(colf, colq, val);
     
     BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(), m.estimatedMemoryUsed() + 0L, 0L, 1);
     bw.addMutation(m);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java Thu May 17 18:01:33 2012
@@ -35,7 +35,7 @@ public class ListIterCommand extends Com
   
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     Map<String,EnumSet<IteratorScope>> iterators = shellState.getConnector().tableOperations().listIterators(tableName);
     

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java Thu May 17 18:01:33 2012
@@ -32,7 +32,7 @@ public class MaxRowCommand extends ScanC
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, ParseException {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     Range range = getRange(cl);
     Authorizations auths = getAuths(cl, shellState);
     Text startRow = range.getStartKey() == null ? null : range.getStartKey().getRow();

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java Thu May 17 18:01:33 2012
@@ -28,20 +28,16 @@ import org.apache.commons.cli.Options;
 import org.apache.hadoop.io.Text;
 
 public class MergeCommand extends Command {
-  private Option mergeOptStartRow, mergeOptEndRow, verboseOpt, forceOpt, sizeOpt;
+  private Option verboseOpt, forceOpt, sizeOpt;
   
   @Override
   public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws Exception {
     boolean verbose = shellState.isVerbose();
     boolean force = false;
     long size = -1;
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
-    Text startRow = null;
-    if (cl.hasOption(mergeOptStartRow.getOpt()))
-      startRow = new Text(cl.getOptionValue(mergeOptStartRow.getOpt()));
-    Text endRow = null;
-    if (cl.hasOption(mergeOptEndRow.getOpt()))
-      endRow = new Text(cl.getOptionValue(mergeOptEndRow.getOpt()));
+    String tableName = OptUtil.getTableOpt(cl, shellState);
+    Text startRow = OptUtil.getStartRow(cl);
+    Text endRow = OptUtil.getEndRow(cl);
     if (cl.hasOption(verboseOpt.getOpt()))
       verbose = true;
     if (cl.hasOption(forceOpt.getOpt()))
@@ -83,13 +79,11 @@ public class MergeCommand extends Comman
   @Override
   public Options getOptions() {
     Options o = new Options();
-    mergeOptStartRow = new Option("b", "begin-row", true, "begin row");
-    mergeOptEndRow = new Option("e", "end-row", true, "end row");
     verboseOpt = new Option("v", "verbose", false, "verbose output during merge");
     sizeOpt = new Option("s", "size", true, "merge tablets to the given size over the entire table");
     forceOpt = new Option("f", "force", false, "merge small tablets to large tablets, even if it goes over the given size");
-    o.addOption(mergeOptStartRow);
-    o.addOption(mergeOptEndRow);
+    o.addOption(OptUtil.startRowOpt());
+    o.addOption(OptUtil.endRowOpt());
     o.addOption(OptUtil.tableOpt("table to be merged"));
     o.addOption(verboseOpt);
     o.addOption(sizeOpt);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java Thu May 17 18:01:33 2012
@@ -16,20 +16,26 @@
  */
 package org.apache.accumulo.core.util.shell.commands;
 
+import java.io.UnsupportedEncodingException;
+
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionGroup;
+import org.apache.hadoop.io.Text;
 
 public abstract class OptUtil {
-  public static String configureTableOpt(CommandLine cl, Shell shellState) throws TableNotFoundException {
+  public static final String START_ROW_OPT = "b";
+  public static final String END_ROW_OPT = "e";
+  
+  public static String getTableOpt(CommandLine cl, Shell shellState) throws TableNotFoundException {
     String tableName;
     
     if (cl.hasOption(Shell.tableOption)) {
       tableName = cl.getOptionValue(Shell.tableOption);
       if (!shellState.getConnector().tableOperations().exists(tableName))
-        throw new TableNotFoundException(null, tableName, null);
+        throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
     } else {
       shellState.checkTableState();
       tableName = shellState.getTableName();
@@ -59,7 +65,7 @@ public abstract class OptUtil {
     }
   }
   
-  public static AdlOpt configureAldOpt(CommandLine cl) {
+  public static AdlOpt getAldOpt(CommandLine cl) {
     if (cl.hasOption(AdlOpt.ADD.opt)) {
       return AdlOpt.ADD;
     } else if (cl.hasOption(AdlOpt.DELETE.opt)) {
@@ -80,4 +86,30 @@ public abstract class OptUtil {
     og.setRequired(true);
     return og;
   }
+  
+  public static Option startRowOpt() {
+    Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
+    o.setArgName("begin-row");
+    return o;
+  }
+  
+  public static Option endRowOpt() {
+    Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
+    o.setArgName("end-row");
+    return o;
+  }
+  
+  public static Text getStartRow(CommandLine cl) throws UnsupportedEncodingException {
+    if (cl.hasOption(START_ROW_OPT))
+      return new Text(cl.getOptionValue(START_ROW_OPT).getBytes(Shell.CHARSET));
+    else
+      return null;
+  }
+  
+  public static Text getEndRow(CommandLine cl) throws UnsupportedEncodingException {
+    if (cl.hasOption(END_ROW_OPT))
+      return new Text(cl.getOptionValue(END_ROW_OPT).getBytes(Shell.CHARSET));
+    else
+      return null;
+  }
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java Thu May 17 18:01:33 2012
@@ -16,10 +16,12 @@
  */
 package org.apache.accumulo.core.util.shell.commands;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.apache.accumulo.core.util.BadArgumentException;
+import org.apache.accumulo.core.util.shell.Shell;
 
 /**
  * A basic tokenizer for generating tokens from a string. It understands quoted strings and escaped quote characters.
@@ -36,20 +38,26 @@ public class QuotedStringTokenizer imple
   public QuotedStringTokenizer(String t) throws BadArgumentException {
     tokens = new ArrayList<String>();
     this.input = t;
-    createTokens();
+    try {
+      createTokens();
+    } catch (UnsupportedEncodingException e) {
+      throw new IllegalArgumentException(e.getMessage());
+    }
   }
   
   public String[] getTokens() {
     return tokens.toArray(new String[tokens.size()]);
   }
   
-  private void createTokens() throws BadArgumentException {
+  private void createTokens() throws BadArgumentException, UnsupportedEncodingException {
     boolean inQuote = false;
     boolean inEscapeSequence = false;
     String hexChars = null;
     char inQuoteChar = '"';
-    StringBuilder sb = new StringBuilder();
     
+    byte[] token = new byte[input.length()];
+    int tokenLength = 0;
+    byte[] inputBytes = input.getBytes();
     for (int i = 0; i < input.length(); ++i) {
       char ch = input.charAt(i);
       
@@ -59,7 +67,7 @@ public class QuotedStringTokenizer imple
         if (ch == 'x')
           hexChars = "";
         else if (ch == ' ' || ch == '\'' || ch == '"' || ch == '\\')
-          sb.append(ch);
+          token[tokenLength++] = inputBytes[i];
         else
           throw new BadArgumentException("can only escape single quotes, double quotes, the space character, the backslash, and hex input", input, i);
       }
@@ -73,12 +81,12 @@ public class QuotedStringTokenizer imple
           byte b;
           try {
             b = (byte) (0xff & Short.parseShort(hexChars, 16));
-            if (!Character.isValidCodePoint(b))
+            if (!Character.isValidCodePoint(0xff & b))
               throw new NumberFormatException();
           } catch (NumberFormatException e) {
             throw new BadArgumentException("unsupported non-ascii character", input, i);
           }
-          sb.append((char) b);
+          token[tokenLength++] = b;
           hexChars = null;
         }
       }
@@ -86,37 +94,37 @@ public class QuotedStringTokenizer imple
       else if (inQuote) {
         if (ch == inQuoteChar) {
           inQuote = false;
-          tokens.add(sb.toString());
-          sb = new StringBuilder();
+          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+          tokenLength = 0;
         } else if (ch == '\\')
           inEscapeSequence = true;
         else
-          sb.append(ch);
+          token[tokenLength++] = inputBytes[i];
       }
       // not in a quote, either enter a quote, end a token, start escape, or continue a token
       else {
         if (ch == '\'' || ch == '"') {
-          if (sb.length() > 0) {
-            tokens.add(sb.toString());
-            sb = new StringBuilder();
+          if (tokenLength > 0) {
+            tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+            tokenLength = 0;
           }
           inQuote = true;
           inQuoteChar = ch;
-        } else if (ch == ' ' && sb.length() > 0) {
-          tokens.add(sb.toString());
-          sb = new StringBuilder();
+        } else if (ch == ' ' && tokenLength > 0) {
+          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+          tokenLength = 0;
         } else if (ch == '\\')
           inEscapeSequence = true;
         else if (ch != ' ')
-          sb.append(ch);
+          token[tokenLength++] = inputBytes[i];
       }
     }
     if (inQuote)
       throw new BadArgumentException("missing terminating quote", input, input.length());
     else if (inEscapeSequence || hexChars != null)
       throw new BadArgumentException("escape sequence not complete", input, input.length());
-    if (sb.length() > 0)
-      tokens.add(sb.toString());
+    if (tokenLength > 0)
+      tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
   }
   
   @Override

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java Thu May 17 18:01:33 2012
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.List;
 import java.util.Map.Entry;
 
@@ -41,13 +42,13 @@ import org.apache.hadoop.io.Text;
 
 public class ScanCommand extends Command {
   
-  private Option scanOptAuths, scanOptStartRow, scanOptEndRow, scanOptRow, scanOptColumns, disablePaginationOpt, showFewOpt, formatterOpt;
+  private Option scanOptAuths, scanOptRow, scanOptColumns, disablePaginationOpt, showFewOpt, formatterOpt;
   protected Option timestampOpt;
   private Option optStartRowExclusive;
   private Option optEndRowExclusive;
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     Class<? extends Formatter> formatter = null;
     
@@ -138,30 +139,30 @@ public class ScanCommand extends Command
     shellState.printBinaryRecords(scanner, cl.hasOption(timestampOpt.getOpt()), !cl.hasOption(disablePaginationOpt.getOpt()));
   }
   
-  protected void fetchColumns(CommandLine cl, ScannerBase scanner) {
+  protected void fetchColumns(CommandLine cl, ScannerBase scanner) throws UnsupportedEncodingException {
     if (cl.hasOption(scanOptColumns.getOpt())) {
       for (String a : cl.getOptionValue(scanOptColumns.getOpt()).split(",")) {
         String sa[] = a.split(":", 2);
         if (sa.length == 1)
-          scanner.fetchColumnFamily(new Text(a));
+          scanner.fetchColumnFamily(new Text(a.getBytes(Shell.CHARSET)));
         else
-          scanner.fetchColumn(new Text(sa[0]), new Text(sa[1]));
+          scanner.fetchColumn(new Text(sa[0].getBytes(Shell.CHARSET)), new Text(sa[1].getBytes(Shell.CHARSET)));
       }
     }
   }
   
-  protected Range getRange(CommandLine cl) {
-    if ((cl.hasOption(scanOptStartRow.getOpt()) || cl.hasOption(scanOptEndRow.getOpt())) && cl.hasOption(scanOptRow.getOpt())) {
+  protected Range getRange(CommandLine cl) throws UnsupportedEncodingException {
+    if ((cl.hasOption(OptUtil.START_ROW_OPT) || cl.hasOption(OptUtil.END_ROW_OPT)) && cl.hasOption(scanOptRow.getOpt())) {
       // did not see a way to make commons cli do this check... it has mutually exclusive options but does not support the or
-      throw new IllegalArgumentException("Options -" + scanOptRow.getOpt() + " AND (-" + scanOptStartRow.getOpt() + " OR -" + scanOptEndRow.getOpt()
+      throw new IllegalArgumentException("Options -" + scanOptRow.getOpt() + " AND (-" + OptUtil.START_ROW_OPT + " OR -" + OptUtil.END_ROW_OPT
           + ") are mutally exclusive ");
     }
     
     if (cl.hasOption(scanOptRow.getOpt())) {
-      return new Range(new Text(cl.getOptionValue(scanOptRow.getOpt())));
+      return new Range(new Text(cl.getOptionValue(scanOptRow.getOpt()).getBytes(Shell.CHARSET)));
     } else {
-      Text startRow = cl.hasOption(scanOptStartRow.getOpt()) ? new Text(cl.getOptionValue(scanOptStartRow.getOpt())) : null;
-      Text endRow = cl.hasOption(scanOptEndRow.getOpt()) ? new Text(cl.getOptionValue(scanOptEndRow.getOpt())) : null;
+      Text startRow = OptUtil.getStartRow(cl);
+      Text endRow = OptUtil.getEndRow(cl);
       boolean startInclusive = !cl.hasOption(optStartRowExclusive.getOpt());
       boolean endInclusive = !cl.hasOption(optEndRowExclusive.getOpt());
       return new Range(startRow, startInclusive, endRow, endInclusive);
@@ -187,8 +188,6 @@ public class ScanCommand extends Command
     Options o = new Options();
     
     scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations (all user auths are used if this argument is not specified)");
-    scanOptStartRow = new Option("b", "begin-row", true, "begin row (inclusive)");
-    scanOptEndRow = new Option("e", "end-row", true, "end row (inclusive)");
     optStartRowExclusive = new Option("be", "begin-exclusive", false, "make start row exclusive (by default it's inclusive)");
     optStartRowExclusive.setArgName("begin-exclusive");
     optEndRowExclusive = new Option("ee", "end-exclusive", false, "make end row exclusive (by default it's inclusive)");
@@ -202,8 +201,6 @@ public class ScanCommand extends Command
     
     scanOptAuths.setArgName("comma-separated-authorizations");
     scanOptRow.setArgName("row");
-    scanOptStartRow.setArgName("start-row");
-    scanOptEndRow.setArgName("end-row");
     scanOptColumns.setArgName("<columnfamily>[:<columnqualifier>]{,<columnfamily>[:<columnqualifier>]}");
     showFewOpt.setRequired(false);
     showFewOpt.setArgName("int");
@@ -211,8 +208,8 @@ public class ScanCommand extends Command
     
     o.addOption(scanOptAuths);
     o.addOption(scanOptRow);
-    o.addOption(scanOptStartRow);
-    o.addOption(scanOptEndRow);
+    o.addOption(OptUtil.startRowOpt());
+    o.addOption(OptUtil.endRowOpt());
     o.addOption(optStartRowExclusive);
     o.addOption(optEndRowExclusive);
     o.addOption(scanOptColumns);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetGroupsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetGroupsCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetGroupsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetGroupsCommand.java Thu May 17 18:01:33 2012
@@ -34,7 +34,7 @@ public class SetGroupsCommand extends Co
   
   @Override
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     HashMap<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
     
@@ -46,7 +46,7 @@ public class SetGroupsCommand extends Co
       HashSet<Text> colFams = new HashSet<Text>();
       
       for (String family : sa[1].split(",")) {
-        colFams.add(new Text(family));
+        colFams.add(new Text(family.getBytes(Shell.CHARSET)));
       }
       
       groups.put(group, colFams);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java?rev=1339751&r1=1339750&r2=1339751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java Thu May 17 18:01:33 2012
@@ -54,7 +54,7 @@ public class SetIterCommand extends Comm
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, ShellCommandException {
-    String tableName = OptUtil.configureTableOpt(cl, shellState);
+    String tableName = OptUtil.getTableOpt(cl, shellState);
     
     int priority = Integer.parseInt(cl.getOptionValue(priorityOpt.getOpt()));
     

Added: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1339751&view=auto
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java (added)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java Thu May 17 18:01:33 2012
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.util.shell;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import jline.ConsoleReader;
+
+import org.apache.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShellTest {
+  class TestOutputStream extends OutputStream {
+    StringBuilder sb = new StringBuilder();
+    
+    @Override
+    public void write(int b) throws IOException {
+      sb.append((char) (0xff & b));
+    }
+    
+    public String get() {
+      return sb.toString();
+    }
+    
+    public void clear() {
+      sb.setLength(0);
+    }
+  }
+  
+  private TestOutputStream output;
+  private Shell shell;
+  
+  void exec(String cmd) throws IOException {
+    output.clear();
+    shell.execCommand(cmd, true, true);
+  }
+  
+  void exec(String cmd, boolean expectGoodExit) throws IOException {
+    exec(cmd);
+    if (expectGoodExit)
+      assertGoodExit("", true);
+    else
+      assertBadExit();
+  }
+  
+  void exec(String cmd, boolean expectGoodExit, String expectString) throws IOException {
+    exec(cmd, expectGoodExit, expectString, true);
+  }
+  
+  void exec(String cmd, boolean expectGoodExit, String expectString, boolean stringPresent) throws IOException {
+    exec(cmd);
+    if (expectGoodExit)
+      assertGoodExit(expectString, stringPresent);
+    else
+      assertBadExit();
+  }
+  
+  @Before
+  public void setup() throws IOException {
+    Shell.log.setLevel(Level.OFF);
+    output = new TestOutputStream();
+    shell = new Shell(new ConsoleReader(new FileInputStream(FileDescriptor.in), new OutputStreamWriter(output)));
+    shell.config("--fake", "-p", "pass");
+  }
+  
+  void assertGoodExit(String s, boolean stringPresent) {
+    Shell.log.debug(output.get());
+    assertEquals(shell.getExitCode(), 0);
+    if (s.length() > 0)
+      assertEquals(s + " present in " + output.get() + " was not " + stringPresent, stringPresent, output.get().contains(s));
+  }
+  
+  void assertBadExit() {
+    Shell.log.debug(output.get());
+    assertTrue(shell.getExitCode() > 0);
+    shell.resetExitCode();
+  }
+  
+  @Test
+  public void aboutTest() throws IOException {
+    Shell.log.debug("Starting about test -----------------------------------");
+    exec("about", true, "Shell - Apache Accumulo Interactive Shell");
+    exec("about -v", true, "Current user:");
+    exec("about arg", false);
+  }
+  
+  @Test
+  public void addGetSplitsTest() throws IOException {
+    Shell.log.debug("Starting addGetSplits test ----------------------------");
+    exec("addsplits arg", false);
+    exec("createtable test", true);
+    exec("addsplits 1 \\x80", true);
+    exec("getsplits", true, "1\n\\x80");
+    exec("deletetable test -f", true, "Table: [test] has been deleted");
+  }
+  
+  @Test
+  public void insertDeleteScanTest() throws IOException {
+    Shell.log.debug("Starting insertDeleteScan test ------------------------");
+    exec("insert r f q v", false);
+    exec("delete r f q", false);
+    exec("createtable test", true);
+    exec("insert r f q v", true);
+    exec("scan", true, "r f:q []    v");
+    exec("delete r f q", true);
+    exec("scan", true, "r f:q []    v", false);
+    exec("insert \\x90 \\xa0 \\xb0 \\xc0\\xd0\\xe0\\xf0", true);
+    exec("scan", true, "\\x90 \\xA0:\\xB0 []    \\xC0\\xD0");
+    exec("scan -f 2", true, "\\x90 \\xA0:\\xB0 []    \\xC0\\xD0");
+    exec("scan -f 2", true, "\\x90 \\xA0:\\xB0 []    \\xC0\\xD0\\xE0", false);
+    exec("scan -b \\x90 -e \\x90 -c \\xA0", true, "\\x90 \\xA0:\\xB0 []    \\xC0");
+    exec("scan -b \\x90 -e \\x90 -c \\xA0:\\xB0", true, "\\x90 \\xA0:\\xB0 []    \\xC0");
+    exec("scan -b \\x90 -be", true, "\\x90 \\xA0:\\xB0 []    \\xC0", false);
+    exec("scan -e \\x90 -ee", true, "\\x90 \\xA0:\\xB0 []    \\xC0", false);
+    exec("scan -b \\x90\\x00", true, "\\x90 \\xA0:\\xB0 []    \\xC0", false);
+    exec("scan -e \\x8f", true, "\\x90 \\xA0:\\xB0 []    \\xC0", false);
+    exec("delete \\x90 \\xa0 \\xb0", true);
+    exec("scan", true, "\\x90 \\xA0:\\xB0 []    \\xC0", false);
+    exec("deletetable test -f", true, "Table: [test] has been deleted");
+  }
+}

Propchange: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message