hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r603940 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/Shell.java src/java/org/apache/hadoop/hbase/shell/SelectCommand.java src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java
Date Thu, 13 Dec 2007 15:43:06 GMT
Author: stack
Date: Thu Dec 13 07:43:04 2007
New Revision: 603940

URL: http://svn.apache.org/viewvc?rev=603940&view=rev
Log:
HADOOP-2351 If select command returns no result, it doesn't need to show
the header information

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=603940&r1=603939&r2=603940&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Thu Dec 13 07:43:04 2007
@@ -117,6 +117,10 @@
                (Edward Yoon via Stack)
    HADOOP-2407 Keeping MapFile.Reader open is expensive: Part 2
    HADOOP-2047 Add an '--master=X' and '--html' command-line parameters to shell
+               (Edward Yoon via Stack)
+   HADOOP-2351 If select command returns no result, it doesn't need to show the
+               header information (Edward Yoon via Stack)
+               
 
 Release 0.15.1
 Branch 0.15

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java?rev=603940&r1=603939&r2=603940&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java Thu
Dec 13 07:43:04 2007
@@ -47,6 +47,7 @@
   public static final boolean DEFAULT_BELL_ENABLED = true;
   public static String MASTER_ADDRESS = null;
   public static String HTML_OPTION = null;
+  public static int RELAUNCH_FLAG = 7;
 
   /** Return the boolean value indicating whether end of command or not */
   static boolean isEndOfCommand(String line) {
@@ -78,6 +79,14 @@
    */
   public static void main(String args[]) throws IOException {
     argumentParsing(args);
+    if (args.length != 0) {
+      if (args[0].equals("--help") || args[0].equals("-h")) {
+        System.out
+            .println("Usage: ./bin/hbase shell [--master:master_address:port] [--html]\n");
+        System.exit(1);
+      }
+    }
+    
     HBaseConfiguration conf = new HBaseConfiguration();
     ConsoleReader reader = new ConsoleReader();
     System.setSecurityManager(new ShellSecurityManager());
@@ -90,11 +99,10 @@
     }
     if (HTML_OPTION != null) {
       tableFormater = new HtmlTableFormatter(out);
-      System.out.println("--html");
     }
 
     HelpCommand help = new HelpCommand(out, tableFormater);
-    if (args.length == 0 || !args[0].equals("7")) {
+    if (args.length == 0 || !args[0].equals(String.valueOf(Shell.RELAUNCH_FLAG))) {
       help.printVersion();
     }
     StringBuilder queryStr = new StringBuilder();

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java?rev=603940&r1=603939&r2=603940&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
Thu Dec 13 07:43:04 2007
@@ -37,6 +37,7 @@
 import org.apache.hadoop.hbase.HStoreKey;
 import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.Shell;
 import org.apache.hadoop.hbase.shell.generated.Parser;
 import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.io.Text;
@@ -113,8 +114,10 @@
         byte[][] result = null;
         ParsedColumns parsedColumns = getColumns(admin, false);
         boolean multiple = parsedColumns.isMultiple() || this.version > 1;
-        formatter.header(multiple ? HEADER_COLUMN_CELL : null);
         for (Text column : parsedColumns.getColumns()) {
+          if(count == 0) {
+            formatter.header(multiple ? HEADER_COLUMN_CELL : null);
+          }
           if (this.timestamp != 0) {
             result = table.get(this.rowKey, column, this.timestamp, this.version);
           } else {
@@ -131,8 +134,10 @@
           }
         }
       } else {
-        formatter.header(isMultiple() ? HEADER_COLUMN_CELL : null);
         for (Map.Entry<Text, byte[]> e : table.getRow(this.rowKey).entrySet()) {
+          if(count == 0) {
+            formatter.header(isMultiple() ? HEADER_COLUMN_CELL : null);
+          }
           Text key = e.getKey();
           String keyStr = key.toString();
           if (!this.columns.contains(STAR) && !this.columns.contains(keyStr)) {
@@ -147,6 +152,10 @@
           count++;
         }
       }
+      
+      if(count == 0 && Shell.HTML_OPTION != null) {
+        formatter.header(isMultiple() ? HEADER_COLUMN_CELL : null);
+      }
       formatter.footer();
     } catch (IOException e) {
       e.printStackTrace();
@@ -209,8 +218,10 @@
       HStoreKey key = new HStoreKey();
       TreeMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
       // If only one column in query, then don't print out the column.
-      formatter.header((parsedColumns.isMultiple()) ? HEADER : HEADER_ROW_CELL);
       while (scan.next(key, results) && checkLimit(count)) {
+        if(count == 0) {
+          formatter.header((parsedColumns.isMultiple()) ? HEADER : HEADER_ROW_CELL);
+        }
         Text r = key.getRow();
         for (Text columnKey : results.keySet()) {
           String cellData = toString(columnKey, results.get(columnKey));
@@ -229,6 +240,11 @@
         // Clear results else subsequent results polluted w/ previous finds.
         results.clear();
       }
+      
+      if(count == 0 && Shell.HTML_OPTION != null) {
+        formatter.header((parsedColumns.isMultiple()) ? HEADER : HEADER_ROW_CELL);
+      }
+      
       formatter.footer();
       scan.close();
     } catch (IOException e) {

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java?rev=603940&r1=603939&r2=603940&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShellSecurityManager.java
Thu Dec 13 07:43:04 2007
@@ -21,6 +21,8 @@
 
 import java.io.IOException;
 import java.security.Permission;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.hadoop.hbase.Shell;
 
@@ -47,9 +49,16 @@
       // I didn't figure out How can catch the ExitException in shell main.
       // So, I just Re-launching the shell.
       Shell shell = new Shell();
-      String[] args = new String[] { String.valueOf(7) };
+
+      List<String> argList = new ArrayList<String>();
+      argList.add(String.valueOf(Shell.RELAUNCH_FLAG));
+      if(Shell.HTML_OPTION != null)
+        argList.add(Shell.HTML_OPTION);
+      if(Shell.MASTER_ADDRESS != null)
+        argList.add(Shell.MASTER_ADDRESS);
+
       try {
-        shell.main(args);
+        shell.main(argList.toArray(new String[] {}));
       } catch (IOException e) {
         e.printStackTrace();
       }



Mime
View raw message