accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [4/6] accumulo git commit: Merge branch '1.7' into 1.8
Date Mon, 09 Jan 2017 23:40:06 GMT
Merge branch '1.7' into 1.8

Conflicts:
	shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java
	shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java


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

Branch: refs/heads/master
Commit: 4cc53bb1251f5b2b722a3050c2d4f55945183c9b
Parents: da47fb2 c3d8703
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Mon Jan 9 18:14:23 2017 -0500
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Mon Jan 9 18:14:23 2017 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/shell/Shell.java   |  2 +-
 .../accumulo/shell/commands/GrepCommand.java    | 75 ++++++++---------
 .../accumulo/shell/commands/ScanCommand.java    | 86 ++++++++++----------
 3 files changed, 84 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cc53bb1/shell/src/main/java/org/apache/accumulo/shell/Shell.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cc53bb1/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java
----------------------------------------------------------------------
diff --cc shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java
index 70c5db2,6d20790..6b69bae
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GrepCommand.java
@@@ -39,43 -39,40 +39,44 @@@ public class GrepCommand extends ScanCo
  
    @Override
    public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
throws Exception {
-     final PrintFile printFile = getOutputFile(cl);
+     try (final PrintFile printFile = getOutputFile(cl)) {
  
-     final String tableName = OptUtil.getTableOpt(cl, shellState);
+       final String tableName = OptUtil.getTableOpt(cl, shellState);
  
-     if (cl.getArgList().isEmpty()) {
-       throw new MissingArgumentException("No terms specified");
-     }
-     final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
-     final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
+       if (cl.getArgList().isEmpty()) {
+         throw new MissingArgumentException("No terms specified");
+       }
+       final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
+       final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
  
-     // handle first argument, if present, the authorizations list to
-     // scan with
-     int numThreads = 20;
-     if (cl.hasOption(numThreadsOpt.getOpt())) {
-       numThreads = Integer.parseInt(cl.getOptionValue(numThreadsOpt.getOpt()));
-     }
-     final Authorizations auths = getAuths(cl, shellState);
-     final BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName,
auths, numThreads);
-     scanner.setRanges(Collections.singletonList(getRange(cl, interpeter)));
+       // handle first argument, if present, the authorizations list to
+       // scan with
+       int numThreads = 20;
+       if (cl.hasOption(numThreadsOpt.getOpt())) {
+         numThreads = Integer.parseInt(cl.getOptionValue(numThreadsOpt.getOpt()));
+       }
+       final Authorizations auths = getAuths(cl, shellState);
+       final BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName,
auths, numThreads);
+       scanner.setRanges(Collections.singletonList(getRange(cl, interpeter)));
  
-     scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
+       scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
  
-     setupSampling(tableName, cl, shellState, scanner);
++      setupSampling(tableName, cl, shellState, scanner);
 +
-     for (int i = 0; i < cl.getArgs().length; i++) {
-       setUpIterator(Integer.MAX_VALUE - cl.getArgs().length + i, "grep" + i, cl.getArgs()[i],
scanner, cl);
-     }
-     try {
-       // handle columns
-       fetchColumns(cl, scanner, interpeter);
+       for (int i = 0; i < cl.getArgs().length; i++) {
+         setUpIterator(Integer.MAX_VALUE - cl.getArgs().length + i, "grep" + i, cl.getArgs()[i],
scanner, cl);
+       }
+       try {
+         // handle columns
+         fetchColumns(cl, scanner, interpeter);
  
-       // output the records
-       final FormatterConfig config = new FormatterConfig();
-       config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
-       printRecords(cl, shellState, config, scanner, formatter, printFile);
-     } finally {
-       scanner.close();
+         // output the records
 -        printRecords(cl, shellState, scanner, formatter, printFile);
++        final FormatterConfig config = new FormatterConfig();
++        config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
++        printRecords(cl, shellState, config, scanner, formatter, printFile);
+       } finally {
+         scanner.close();
+       }
      }
  
      return 0;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/4cc53bb1/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
----------------------------------------------------------------------
diff --cc shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
index e1da444,b6eb8d6..4a18108
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
@@@ -79,55 -65,48 +80,53 @@@ public class ScanCommand extends Comman
  
    @Override
    public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
throws Exception {
-     final PrintFile printFile = getOutputFile(cl);
-     final String tableName = OptUtil.getTableOpt(cl, shellState);
+     try (final PrintFile printFile = getOutputFile(cl)) {
+       final String tableName = OptUtil.getTableOpt(cl, shellState);
  
-     final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
-     final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
+       final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
+       final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
  
-     String classLoaderContext = null;
-     if (cl.hasOption(contextOpt.getOpt())) {
-       classLoaderContext = cl.getOptionValue(contextOpt.getOpt());
-     }
-     // handle first argument, if present, the authorizations list to
-     // scan with
-     final Authorizations auths = getAuths(cl, shellState);
-     final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
-     if (null != classLoaderContext) {
-       scanner.setClassLoaderContext(classLoaderContext);
-     }
-     // handle session-specific scan iterators
-     addScanIterators(shellState, cl, scanner, tableName);
++      String classLoaderContext = null;
++      if (cl.hasOption(contextOpt.getOpt())) {
++        classLoaderContext = cl.getOptionValue(contextOpt.getOpt());
++      }
+       // handle first argument, if present, the authorizations list to
+       // scan with
+       final Authorizations auths = getAuths(cl, shellState);
+       final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
 -
++      if (null != classLoaderContext) {
++        scanner.setClassLoaderContext(classLoaderContext);
++      }
+       // handle session-specific scan iterators
+       addScanIterators(shellState, cl, scanner, tableName);
  
-     // handle remaining optional arguments
-     scanner.setRange(getRange(cl, interpeter));
+       // handle remaining optional arguments
+       scanner.setRange(getRange(cl, interpeter));
  
-     // handle columns
-     fetchColumns(cl, scanner, interpeter);
+       // handle columns
+       fetchColumns(cl, scanner, interpeter);
  
-     // set timeout
-     scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
+       // set timeout
+       scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
  
-     setupSampling(tableName, cl, shellState, scanner);
++      setupSampling(tableName, cl, shellState, scanner);
 +
-     // output the records
+       // output the records
 +
-     final FormatterConfig config = new FormatterConfig();
-     config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
-     if (cl.hasOption(showFewOpt.getOpt())) {
-       final String showLength = cl.getOptionValue(showFewOpt.getOpt());
-       try {
-         final int length = Integer.parseInt(showLength);
-         config.setShownLength(length);
-       } catch (NumberFormatException nfe) {
-         shellState.getReader().println("Arg must be an integer.");
-       } catch (IllegalArgumentException iae) {
-         shellState.getReader().println("Arg must be greater than one.");
++      final FormatterConfig config = new FormatterConfig();
++      config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
+       if (cl.hasOption(showFewOpt.getOpt())) {
+         final String showLength = cl.getOptionValue(showFewOpt.getOpt());
+         try {
+           final int length = Integer.parseInt(showLength);
 -          if (length < 1) {
 -            throw new IllegalArgumentException();
 -          }
 -          BinaryFormatter.getlength(length);
 -          printBinaryRecords(cl, shellState, scanner, printFile);
++          config.setShownLength(length);
+         } catch (NumberFormatException nfe) {
+           shellState.getReader().println("Arg must be an integer.");
+         } catch (IllegalArgumentException iae) {
+           shellState.getReader().println("Arg must be greater than one.");
+         }
 -
 -      } else {
 -        printRecords(cl, shellState, scanner, formatter, printFile);
        }
-     }
-     printRecords(cl, shellState, config, scanner, formatter, printFile);
-     if (printFile != null) {
-       printFile.close();
++      printRecords(cl, shellState, config, scanner, formatter, printFile);
      }
  
      return 0;
@@@ -343,10 -324,13 +342,15 @@@
      o.addOption(interpreterOpt);
      o.addOption(formatterInterpeterOpt);
      o.addOption(timeoutOption);
-     o.addOption(outputFileOpt);
+     if (Arrays.asList(new String[] {ScanCommand.class.getName(), GrepCommand.class.getName(),
EGrepCommand.class.getName()})
+         .contains(this.getClass().getName())) {
+       // supported subclasses must handle the output file option properly
+       // only add this option to commands which handle it correctly
+       o.addOption(outputFileOpt);
+     }
      o.addOption(profileOpt);
 +    o.addOption(sampleOpt);
 +    o.addOption(contextOpt);
  
      return o;
    }


Mime
View raw message