incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1241121 - in /incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands: ScanCommand.java SelectrowCommand.java
Date Mon, 06 Feb 2012 19:29:26 GMT
Author: kturner
Date: Mon Feb  6 19:29:26 2012
New Revision: 1241121

URL: http://svn.apache.org/viewvc?rev=1241121&view=rev
Log:
ACCUMULO-372 deprecated selectrow and add -r option to scan in accumulo shell

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SelectrowCommand.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java?rev=1241121&r1=1241120&r2=1241121&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java
Mon Feb  6 19:29:26 2012
@@ -41,7 +41,7 @@ import org.apache.hadoop.io.Text;
 
 public class ScanCommand extends Command {
   
-  private Option scanOptAuths, scanOptStartRow, scanOptEndRow, scanOptColumns, disablePaginationOpt,
tableOpt, showFewOpt;
+  private Option scanOptAuths, scanOptStartRow, scanOptEndRow, scanOptRow, scanOptColumns,
disablePaginationOpt, tableOpt, showFewOpt;
   protected Option timestampOpt;
   
   public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException,
@@ -133,10 +133,19 @@ public class ScanCommand extends Command
   }
   
   protected Range getRange(CommandLine cl) {
-    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;
-    Range r = new Range(startRow, endRow);
-    return r;
+    if ((cl.hasOption(scanOptStartRow.getOpt()) || cl.hasOption(scanOptEndRow.getOpt()))
&& 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()
+          + ") are mutally exclusive ");
+    }
+
+    if (cl.hasOption(scanOptRow.getOpt())) {
+      return new Range(new Text(cl.getOptionValue(scanOptRow.getOpt())));
+    } 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;
+      return new Range(startRow, endRow);
+    }
   }
   
   protected Authorizations getAuths(CommandLine cl, Shell shellState) throws AccumuloSecurityException,
AccumuloException {
@@ -160,6 +169,7 @@ public class ScanCommand extends Command
     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)");
+    scanOptRow = new Option("r", "row", true, "row to scan");
     scanOptColumns = new Option("c", "columns", true, "comma-separated columns");
     timestampOpt = new Option("st", "show-timestamps", false, "enables displaying timestamps");
     disablePaginationOpt = new Option("np", "no-pagination", false, "disables pagination
of output");
@@ -167,6 +177,7 @@ public class ScanCommand extends Command
     showFewOpt = new Option("f", "show few", true, "Only shows certain amount of characters");
     
     scanOptAuths.setArgName("comma-separated-authorizations");
+    scanOptRow.setArgName("row");
     scanOptStartRow.setArgName("start-row");
     scanOptEndRow.setArgName("end-row");
     scanOptColumns.setArgName("{<columnfamily>[:<columnqualifier>]}");
@@ -176,6 +187,7 @@ public class ScanCommand extends Command
     showFewOpt.setArgName("int");
     
     o.addOption(scanOptAuths);
+    o.addOption(scanOptRow);
     o.addOption(scanOptStartRow);
     o.addOption(scanOptEndRow);
     o.addOption(scanOptColumns);

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SelectrowCommand.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SelectrowCommand.java?rev=1241121&r1=1241120&r2=1241121&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SelectrowCommand.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SelectrowCommand.java
Mon Feb  6 19:29:26 2012
@@ -32,6 +32,8 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.hadoop.io.Text;
 
+@Deprecated
+// deprecated since 1.4
 public class SelectrowCommand extends Command {
   
   private Option selectrowOptAuths, timestampOpt, disablePaginationOpt, tableOpt;
@@ -41,6 +43,8 @@ public class SelectrowCommand extends Co
     
     String tableName;
     
+    shellState.log.warn("selectrow is deprecated, use 'scan -r <row>'");
+
     if (cl.hasOption(tableOpt.getOpt())) {
       tableName = cl.getOptionValue(tableOpt.getOpt());
       if (!shellState.getConnector().tableOperations().exists(tableName))



Mime
View raw message