فهرست منبع

HADOOP-2557 Shell count function

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@611537 13f79535-47bb-0310-9956-ffa450edef68
Michael Stack 17 سال پیش
والد
کامیت
4400f2257d

+ 2 - 2
src/contrib/hbase/CHANGES.txt

@@ -2,6 +2,7 @@ HBase Change Log
 
 
 Trunk (unreleased changes)
+
   INCOMPATIBLE CHANGES
    HADOOP-2056 A table with row keys containing colon fails to split regions
    HADOOP-2079 Fix generated HLog, HRegion names
@@ -169,8 +170,7 @@ Trunk (unreleased changes)
    HADOOP-2553 Don't make Long objects calculating hbase type hash codes
    HADOOP-2548 Make TableMap and TableReduce generic
                (Frederik Hedberg via Stack)
-               
-
+   HADOOP-2557 Shell count function (Edward Yoon via Stack)
 
 Release 0.15.1
 Branch 0.15

+ 32 - 19
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj

@@ -129,6 +129,11 @@ TOKEN: /** for HQL statements */
    | <CHANGE: "change">
 }
 
+TOKEN : /** Functions */
+{
+   <COUNT: "count">
+}
+ 
 TOKEN : /** Literals */
 {
    <ID: ["A"-"Z","a"-"z","_","-",":","/","~","."] (["A"-"Z","a"-"z","0"-"9","_","-",":","/","~","."])* >
@@ -575,10 +580,13 @@ SelectCommand selectCommand() :
 }
 {
   <SELECT>
-  columns = columnList()
+  (
+      <COUNT>  columns = getLiteralValues()
+      { select.setCountFunction(true); }
+    | columns = columnList()
+  )
   <FROM>
   tableName = identifier()
-  
   { 
      select.setColumns(columns);
      select.setTable(tableName);
@@ -667,20 +675,17 @@ List<String> getLiteralValues() :
 }
 {    
 <LPAREN>
- { literal = getStringLiteral();
- if(literal != null) values.add(literal); 
+ {
+    literal = getStringLiteral();
+    if(literal != null) values.add(literal); 
  }
+
     (
-<COMMA> { 
-   literal = getStringLiteral(); 
-   if(literal != null) values.add(literal); 
-}
-| ( 
-       <ID>
-     | <STRING_LITERAL>
-     | <QUOTED_IDENTIFIER>
-  )  { values.removeAll(values); }
-        )*
+        <COMMA> { 
+           literal = getStringLiteral(); 
+           if(literal != null) values.add(literal); 
+        }
+    )*
 <RPAREN>
    { 
      return values;
@@ -690,13 +695,21 @@ List<String> getLiteralValues() :
 String getStringLiteral() :
 {
   Token s;
+  String value = null;
 }
 {
- ( s=<STRING_LITERAL> | s=<QUOTED_IDENTIFIER> )
- { 
-   String value = s.image.toString();
-   return value.substring(1,value.length() - 1);
- }
+  (
+    ( s=<STRING_LITERAL> | s=<QUOTED_IDENTIFIER> )
+   { 
+     value = s.image.toString();
+     return value.substring(1,value.length() - 1);
+   }
+   | ( s=<ID> | s=<INTEGER_LITERAL> | s=<ASTERISK> )
+   { 
+     value = s.image.toString();
+     return value;
+   }
+ )
 }
 
 String getColumn() :

+ 1 - 1
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java

@@ -108,7 +108,7 @@ public class HelpCommand extends BasicCommand {
 
     load.put("SELECT", new String[] {
         "Select values from table",
-        "SELECT {column_name, [, column_name] ... | *} FROM table_name "
+        "SELECT {column_name, [, column_name] ... | expr[alias] | * } FROM table_name "
             + "[WHERE row='row_key' | STARTING FROM 'row-key' [UNTIL 'stop-key']] "
             + "[NUM_VERSIONS = version_count] " + "[TIMESTAMP 'timestamp'] "
             + "[LIMIT = row_count] " + "[INTO FILE 'file_name'];" });

+ 47 - 34
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java

@@ -47,8 +47,6 @@ import org.apache.hadoop.io.Text;
 
 /**
  * Selects values from tables.
- * 
- * TODO: INTO FILE is not yet implemented.
  */
 public class SelectCommand extends BasicCommand {
   private Text tableName;
@@ -59,10 +57,10 @@ public class SelectCommand extends BasicCommand {
   private int limit;
   // Count of versions to return.
   private int version;
+  private boolean countFunction = false;
   private boolean whereClause = false;
   private static final String[] HEADER_ROW_CELL = new String[] { "Row", "Cell" };
-  private static final String[] HEADER_COLUMN_CELL = new String[] { "Column",
-      "Cell" };
+  private static final String[] HEADER_COLUMN_CELL = new String[] { "Column", "Cell" };
   private static final String[] HEADER = new String[] { "Row", "Column", "Cell" };
   private static final String ASTERISK = "*";
 
@@ -93,7 +91,11 @@ public class SelectCommand extends BasicCommand {
       HBaseAdmin admin = new HBaseAdmin(conf);
       int count = 0;
       if (whereClause) {
-        count = compoundWherePrint(table, admin);
+        if (countFunction) {
+          count = 1;
+        } else {
+          count = compoundWherePrint(table, admin);
+        }
       } else {
         count = scanPrint(table, admin);
       }
@@ -105,8 +107,8 @@ public class SelectCommand extends BasicCommand {
   }
 
   private boolean isMetaTable() {
-    return (tableName.equals(HConstants.ROOT_TABLE_NAME)
-        || tableName.equals(HConstants.META_TABLE_NAME)) ? true : false;
+    return (tableName.equals(HConstants.ROOT_TABLE_NAME) || tableName
+        .equals(HConstants.META_TABLE_NAME)) ? true : false;
   }
 
   private int compoundWherePrint(HTable table, HBaseAdmin admin) {
@@ -118,7 +120,7 @@ public class SelectCommand extends BasicCommand {
         ParsedColumns parsedColumns = getColumns(admin, false);
         boolean multiple = parsedColumns.isMultiple() || version > 1;
         for (Text column : parsedColumns.getColumns()) {
-          if(count == 0) {
+          if (count == 0) {
             formatter.header(multiple ? HEADER_COLUMN_CELL : null);
           }
           if (timestamp != 0) {
@@ -138,7 +140,7 @@ public class SelectCommand extends BasicCommand {
         }
       } else {
         for (Map.Entry<Text, byte[]> e : table.getRow(rowKey).entrySet()) {
-          if(count == 0) {
+          if (count == 0) {
             formatter.header(isMultiple() ? HEADER_COLUMN_CELL : null);
           }
           Text key = e.getKey();
@@ -155,15 +157,15 @@ public class SelectCommand extends BasicCommand {
           count++;
         }
       }
-      
-      if(count == 0 && Shell.HTML_OPTION != null) {
+
+      if (count == 0 && Shell.HTML_OPTION != null) {
         formatter.header(isMultiple() ? HEADER_COLUMN_CELL : null);
       }
       formatter.footer();
     } catch (IOException e) {
       e.printStackTrace();
     }
-    return count;
+    return 1;
   }
 
   private String toString(final Text columnName, final byte[] cell)
@@ -218,42 +220,48 @@ public class SelectCommand extends BasicCommand {
       } else {
         scan = table.obtainScanner(cols, rowKey, timestamp);
       }
-      
-      if(this.stopRow.toString().length() > 0) {
-        RowFilterInterface filter =  new WhileMatchRowFilter(new StopRowFilter(stopRow));
+
+      if (this.stopRow.toString().length() > 0) {
+        RowFilterInterface filter = new WhileMatchRowFilter(new StopRowFilter(
+            stopRow));
         scan = table.obtainScanner(cols, rowKey, filter);
       }
-      
+
       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.
       while (scan.next(key, results) && checkLimit(count)) {
-        if(count == 0) {
+        if (count == 0 && !countFunction) {
           formatter.header((parsedColumns.isMultiple()) ? HEADER : HEADER_ROW_CELL);
         }
+
         Text r = key.getRow();
-        for (Text columnKey : results.keySet()) {
-          String cellData = toString(columnKey, results.get(columnKey));
-          if (parsedColumns.isMultiple()) {
-            formatter.row(new String[] { r.toString(), columnKey.toString(),
-                cellData });
-          } else {
-            // Don't print out the column since only one specified in query.
-            formatter.row(new String[] { r.toString(), cellData });
-          }
-          count++;
-          if (limit > 0 && count >= limit) {
-            break;
+
+        if (!countFunction) {
+          for (Text columnKey : results.keySet()) {
+            String cellData = toString(columnKey, results.get(columnKey));
+            if (parsedColumns.isMultiple()) {
+              formatter.row(new String[] { r.toString(), columnKey.toString(),
+                  cellData });
+            } else {
+              // Don't print out the column since only one specified in query.
+              formatter.row(new String[] { r.toString(), cellData });
+            }
+            if (limit > 0 && count >= limit) {
+              break;
+            }
           }
         }
+
+        count++;
         // Clear results else subsequent results polluted w/ previous finds.
         results.clear();
       }
-      
-      if(count == 0 && Shell.HTML_OPTION != null) {
+
+      if (count == 0 && Shell.HTML_OPTION != null && !countFunction) {
         formatter.header((parsedColumns.isMultiple()) ? HEADER : HEADER_ROW_CELL);
       }
-      
+
       formatter.footer();
       scan.close();
     } catch (IOException e) {
@@ -279,7 +287,8 @@ public class SelectCommand extends BasicCommand {
           HTableDescriptor[] tables = admin.listTables();
           for (int i = 0; i < tables.length; i++) {
             if (tables[i].getName().equals(tableName)) {
-              result = new ParsedColumns(new ArrayList<Text>(tables[i].families().keySet()));
+              result = new ParsedColumns(new ArrayList<Text>(tables[i].families()
+                  .keySet()));
               break;
             }
           }
@@ -346,10 +355,14 @@ public class SelectCommand extends BasicCommand {
       this.rowKey = new Text(rowKey);
   }
 
+  public void setCountFunction(boolean countFunction) {
+    this.countFunction = countFunction;
+  }
+
   public void setStopRow(String stopRow) {
     this.stopRow = new Text(stopRow);
   }
-  
+
   /**
    * @param version Set maximum versions for this selection
    */

+ 104 - 87
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java

@@ -76,7 +76,7 @@ public class Parser implements ParserConstants {
     case SELECT:
     case ENABLE:
     case DISABLE:
-    case 67:
+    case 68:
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case HELP:
       case ALTER:
@@ -101,7 +101,7 @@ public class Parser implements ParserConstants {
         jj_la1[0] = jj_gen;
         ;
       }
-      jj_consume_token(67);
+      jj_consume_token(68);
       break;
     case 0:
       jj_consume_token(0);
@@ -691,7 +691,24 @@ public class Parser implements ParserConstants {
   String tableName = null;
   int limit;
     jj_consume_token(SELECT);
-    columns = columnList();
+    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+    case COUNT:
+      jj_consume_token(COUNT);
+      columns = getLiteralValues();
+        select.setCountFunction(true);
+      break;
+    case ASTERISK:
+    case ID:
+    case INTEGER_LITERAL:
+    case QUOTED_IDENTIFIER:
+    case STRING_LITERAL:
+      columns = columnList();
+      break;
+    default:
+      jj_la1[22] = jj_gen;
+      jj_consume_token(-1);
+      throw new ParseException();
+    }
     jj_consume_token(FROM);
     tableName = identifier();
      select.setColumns(columns);
@@ -711,7 +728,7 @@ public class Parser implements ParserConstants {
         jj_consume_token(FROM);
         break;
       default:
-        jj_la1[22] = jj_gen;
+        jj_la1[23] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
@@ -724,12 +741,12 @@ public class Parser implements ParserConstants {
       select.setStopRow(stopRow);
         break;
       default:
-        jj_la1[23] = jj_gen;
+        jj_la1[24] = jj_gen;
         ;
       }
       break;
     default:
-      jj_la1[24] = jj_gen;
+      jj_la1[25] = jj_gen;
       ;
     }
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -739,7 +756,7 @@ public class Parser implements ParserConstants {
        select.setTimestamp(timestamp);
       break;
     default:
-      jj_la1[25] = jj_gen;
+      jj_la1[26] = jj_gen;
       ;
     }
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -750,7 +767,7 @@ public class Parser implements ParserConstants {
         select.setVersion(numVersion);
       break;
     default:
-      jj_la1[26] = jj_gen;
+      jj_la1[27] = jj_gen;
       ;
     }
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -765,7 +782,7 @@ public class Parser implements ParserConstants {
       }
       break;
     default:
-      jj_la1[27] = jj_gen;
+      jj_la1[28] = jj_gen;
       ;
     }
     {if (true) return select;}
@@ -803,52 +820,21 @@ public class Parser implements ParserConstants {
   List<String> values = new ArrayList<String>();
   String literal = null;
     jj_consume_token(LPAREN);
-   literal = getStringLiteral();
- if(literal != null) values.add(literal);
+    literal = getStringLiteral();
+    if(literal != null) values.add(literal);
     label_6:
     while (true) {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case COMMA:
-      case ID:
-      case QUOTED_IDENTIFIER:
-      case STRING_LITERAL:
         ;
         break;
       default:
-        jj_la1[28] = jj_gen;
+        jj_la1[29] = jj_gen;
         break label_6;
       }
-      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-      case COMMA:
-        jj_consume_token(COMMA);
-   literal = getStringLiteral();
-   if(literal != null) values.add(literal);
-        break;
-      case ID:
-      case QUOTED_IDENTIFIER:
-      case STRING_LITERAL:
-        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
-        case ID:
-          jj_consume_token(ID);
-          break;
-        case STRING_LITERAL:
-          jj_consume_token(STRING_LITERAL);
-          break;
-        case QUOTED_IDENTIFIER:
-          jj_consume_token(QUOTED_IDENTIFIER);
-          break;
-        default:
-          jj_la1[29] = jj_gen;
-          jj_consume_token(-1);
-          throw new ParseException();
-        }
-       values.removeAll(values);
-        break;
-      default:
-        jj_la1[30] = jj_gen;
-        jj_consume_token(-1);
-        throw new ParseException();
-      }
+      jj_consume_token(COMMA);
+           literal = getStringLiteral();
+           if(literal != null) values.add(literal);
     }
     jj_consume_token(RPAREN);
      {if (true) return values;}
@@ -857,20 +843,51 @@ public class Parser implements ParserConstants {
 
   final public String getStringLiteral() throws ParseException {
   Token s;
+  String value = null;
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+    case QUOTED_IDENTIFIER:
     case STRING_LITERAL:
-      s = jj_consume_token(STRING_LITERAL);
+      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+      case STRING_LITERAL:
+        s = jj_consume_token(STRING_LITERAL);
+        break;
+      case QUOTED_IDENTIFIER:
+        s = jj_consume_token(QUOTED_IDENTIFIER);
+        break;
+      default:
+        jj_la1[30] = jj_gen;
+        jj_consume_token(-1);
+        throw new ParseException();
+      }
+     value = s.image.toString();
+     {if (true) return value.substring(1,value.length() - 1);}
       break;
-    case QUOTED_IDENTIFIER:
-      s = jj_consume_token(QUOTED_IDENTIFIER);
+    case ASTERISK:
+    case ID:
+    case INTEGER_LITERAL:
+      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+      case ID:
+        s = jj_consume_token(ID);
+        break;
+      case INTEGER_LITERAL:
+        s = jj_consume_token(INTEGER_LITERAL);
+        break;
+      case ASTERISK:
+        s = jj_consume_token(ASTERISK);
+        break;
+      default:
+        jj_la1[31] = jj_gen;
+        jj_consume_token(-1);
+        throw new ParseException();
+      }
+     value = s.image.toString();
+     {if (true) return value;}
       break;
     default:
-      jj_la1[31] = jj_gen;
+      jj_la1[32] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
-   String value = s.image.toString();
-   {if (true) return value.substring(1,value.length() - 1);}
     throw new Error("Missing return statement in function");
   }
 
@@ -891,7 +908,7 @@ public class Parser implements ParserConstants {
         col = jj_consume_token(ASTERISK);
         break;
       default:
-        jj_la1[32] = jj_gen;
+        jj_la1[33] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
@@ -907,14 +924,14 @@ public class Parser implements ParserConstants {
         col = jj_consume_token(STRING_LITERAL);
         break;
       default:
-        jj_la1[33] = jj_gen;
+        jj_la1[34] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
         {if (true) return col.image.substring(1,col.image.toString().length() - 1);}
       break;
     default:
-      jj_la1[34] = jj_gen;
+      jj_la1[35] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
@@ -934,7 +951,7 @@ public class Parser implements ParserConstants {
         ;
         break;
       default:
-        jj_la1[35] = jj_gen;
+        jj_la1[36] = jj_gen;
         break label_7;
       }
       jj_consume_token(COMMA);
@@ -958,7 +975,7 @@ public class Parser implements ParserConstants {
         ;
         break;
       default:
-        jj_la1[36] = jj_gen;
+        jj_la1[37] = jj_gen;
         break label_8;
       }
       jj_consume_token(COMMA);
@@ -985,7 +1002,7 @@ public class Parser implements ParserConstants {
         ;
         break;
       default:
-        jj_la1[37] = jj_gen;
+        jj_la1[38] = jj_gen;
         break label_9;
       }
       jj_consume_token(COMMA);
@@ -1007,7 +1024,7 @@ public class Parser implements ParserConstants {
       t = jj_consume_token(INTEGER_LITERAL);
       break;
     default:
-      jj_la1[38] = jj_gen;
+      jj_la1[39] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
@@ -1036,14 +1053,14 @@ public class Parser implements ParserConstants {
         t = jj_consume_token(STRING_LITERAL);
         break;
       default:
-        jj_la1[39] = jj_gen;
+        jj_la1[40] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
        {if (true) return t.image.substring(1,t.image.toString().length() - 1);}
       break;
     default:
-      jj_la1[40] = jj_gen;
+      jj_la1[41] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
@@ -1064,8 +1081,13 @@ public class Parser implements ParserConstants {
     finally { jj_save(0, xla); }
   }
 
-  final private boolean jj_3R_11() {
-    if (jj_scan_token(ID)) return true;
+  final private boolean jj_3R_10() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_11()) {
+    jj_scanpos = xsp;
+    if (jj_3R_12()) return true;
+    }
     return false;
   }
 
@@ -1075,23 +1097,18 @@ public class Parser implements ParserConstants {
     return false;
   }
 
-  final private boolean jj_3R_10() {
+  final private boolean jj_3R_12() {
     Token xsp;
     xsp = jj_scanpos;
-    if (jj_3R_11()) {
+    if (jj_scan_token(66)) {
     jj_scanpos = xsp;
-    if (jj_3R_12()) return true;
+    if (jj_scan_token(67)) return true;
     }
     return false;
   }
 
-  final private boolean jj_3R_12() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_scan_token(65)) {
-    jj_scanpos = xsp;
-    if (jj_scan_token(66)) return true;
-    }
+  final private boolean jj_3R_11() {
+    if (jj_scan_token(ID)) return true;
     return false;
   }
 
@@ -1104,7 +1121,7 @@ public class Parser implements ParserConstants {
   public boolean lookingAhead = false;
   private boolean jj_semLA;
   private int jj_gen;
-  final private int[] jj_la1 = new int[41];
+  final private int[] jj_la1 = new int[42];
   static private int[] jj_la1_0;
   static private int[] jj_la1_1;
   static private int[] jj_la1_2;
@@ -1114,13 +1131,13 @@ public class Parser implements ParserConstants {
       jj_la1_2();
    }
    private static void jj_la1_0() {
-      jj_la1_0 = new int[] {0xf3ffe0,0xf3ffe1,0xf3ffe0,0x0,0x0,0x0,0x0,0x33dbc0,0x33dbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x80000000,0x0,0x2000000,0x3000000,0x8000000,0x3000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
+      jj_la1_0 = new int[] {0xf3ffe0,0xf3ffe1,0xf3ffe0,0x0,0x0,0x0,0x0,0x33dbc0,0x33dbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x80000000,0x0,0x2000000,0x0,0x3000000,0x8000000,0x3000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
    }
    private static void jj_la1_1() {
-      jj_la1_1 = new int[] {0x0,0x0,0x0,0x20000000,0xe0000000,0xe0000000,0x20000000,0x20000000,0x20000000,0x20000000,0x0,0x731c000,0xe0000,0xe00000,0x731c000,0x10,0x10,0x18000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0x20000010,0x20000000,0x20000010,0x0,0x60002000,0x0,0x60002000,0x10,0x10,0x10,0x60000000,0x0,0x20000000,};
+      jj_la1_1 = new int[] {0x0,0x0,0x0,0x40000000,0xc0000000,0xc0000000,0x40000000,0x40000000,0x40000000,0x40000000,0x0,0x731c000,0xe0000,0xe00000,0x731c000,0x10,0x10,0x18000000,0x0,0x0,0x0,0x0,0xe0002000,0x0,0x0,0x0,0x0,0x1,0x2,0x10,0x0,0xc0002000,0xc0002000,0xc0002000,0x0,0xc0002000,0x10,0x10,0x10,0xc0000000,0x0,0x40000000,};
    }
    private static void jj_la1_2() {
-      jj_la1_2 = new int[] {0x0,0x8,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x6,0x6,0x6,0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,};
+      jj_la1_2 = new int[] {0x0,0x10,0x0,0x0,0x1,0x1,0xc,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc,0x0,0xc,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc,0x0,0xc,0x0,0xc,0xc,0x0,0x0,0x0,0x0,0xc,0xc,};
    }
   final private JJCalls[] jj_2_rtns = new JJCalls[1];
   private boolean jj_rescan = false;
@@ -1135,7 +1152,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1148,7 +1165,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1158,7 +1175,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1168,7 +1185,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1177,7 +1194,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1186,7 +1203,7 @@ public class Parser implements ParserConstants {
     token = new Token();
     jj_ntk = -1;
     jj_gen = 0;
-    for (int i = 0; i < 41; i++) jj_la1[i] = -1;
+    for (int i = 0; i < 42; i++) jj_la1[i] = -1;
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
   }
 
@@ -1297,15 +1314,15 @@ public class Parser implements ParserConstants {
 
   public ParseException generateParseException() {
     jj_expentries.removeAllElements();
-    boolean[] la1tokens = new boolean[68];
-    for (int i = 0; i < 68; i++) {
+    boolean[] la1tokens = new boolean[69];
+    for (int i = 0; i < 69; i++) {
       la1tokens[i] = false;
     }
     if (jj_kind >= 0) {
       la1tokens[jj_kind] = true;
       jj_kind = -1;
     }
-    for (int i = 0; i < 41; i++) {
+    for (int i = 0; i < 42; i++) {
       if (jj_la1[i] == jj_gen) {
         for (int j = 0; j < 32; j++) {
           if ((jj_la1_0[i] & (1<<j)) != 0) {
@@ -1320,7 +1337,7 @@ public class Parser implements ParserConstants {
         }
       }
     }
-    for (int i = 0; i < 68; i++) {
+    for (int i = 0; i < 69; i++) {
       if (la1tokens[i]) {
         jj_expentry = new int[1];
         jj_expentry[0] = i;

+ 8 - 6
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/ParserConstants.java

@@ -60,12 +60,13 @@ public interface ParserConstants {
   int NUM_ENTRIES = 58;
   int ADD = 59;
   int CHANGE = 60;
-  int ID = 61;
-  int INTEGER_LITERAL = 62;
-  int FLOATING_POINT_LITERAL = 63;
-  int EXPONENT = 64;
-  int QUOTED_IDENTIFIER = 65;
-  int STRING_LITERAL = 66;
+  int COUNT = 61;
+  int ID = 62;
+  int INTEGER_LITERAL = 63;
+  int FLOATING_POINT_LITERAL = 64;
+  int EXPONENT = 65;
+  int QUOTED_IDENTIFIER = 66;
+  int STRING_LITERAL = 67;
 
   int DEFAULT = 0;
 
@@ -131,6 +132,7 @@ public interface ParserConstants {
     "\"num_entries\"",
     "\"add\"",
     "\"change\"",
+    "\"count\"",
     "<ID>",
     "<INTEGER_LITERAL>",
     "<FLOATING_POINT_LITERAL>",

+ 87 - 79
src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/ParserTokenManager.java

@@ -40,114 +40,117 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
    switch (pos)
    {
       case 0:
-         if ((active0 & 0x1fffcc0fffffffe0L) != 0L)
+         if ((active0 & 0x3fffcc0fffffffe0L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             return 1;
          }
          return -1;
       case 1:
-         if ((active0 & 0x10080800064000L) != 0L)
-            return 1;
-         if ((active0 & 0x1fefc407fff9bfe0L) != 0L)
+         if ((active0 & 0x3fefc407fff9bfe0L) != 0L)
          {
             if (jjmatchedPos != 1)
             {
-               jjmatchedKind = 61;
+               jjmatchedKind = 62;
                jjmatchedPos = 1;
             }
             return 1;
          }
+         if ((active0 & 0x10080800064000L) != 0L)
+            return 1;
          return -1;
       case 2:
-         if ((active0 & 0x800040410008000L) != 0L)
-            return 1;
-         if ((active0 & 0x17ffc003efff3fe0L) != 0L)
+         if ((active0 & 0x37ffc003efff3fe0L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 2;
             return 1;
          }
+         if ((active0 & 0x800040410008000L) != 0L)
+            return 1;
          return -1;
       case 3:
-         if ((active0 & 0x2000004051720L) != 0L)
-            return 1;
-         if ((active0 & 0x17fdc003ebfa28c0L) != 0L)
+         if ((active0 & 0x37fdc003ebfa28c0L) != 0L)
          {
             if (jjmatchedPos != 3)
             {
-               jjmatchedKind = 61;
+               jjmatchedKind = 62;
                jjmatchedPos = 3;
             }
             return 1;
          }
+         if ((active0 & 0x2000004051720L) != 0L)
+            return 1;
          return -1;
       case 4:
-         if ((active0 & 0x400020a0800c0L) != 0L)
-            return 1;
-         if ((active0 & 0x17f9c001e1f22a00L) != 0L)
+         if ((active0 & 0x17b9c001e1f22a00L) != 0L)
          {
-            jjmatchedKind = 61;
-            jjmatchedPos = 4;
+            if (jjmatchedPos != 4)
+            {
+               jjmatchedKind = 62;
+               jjmatchedPos = 4;
+            }
             return 1;
          }
+         if ((active0 & 0x204400020a0800c0L) != 0L)
+            return 1;
          return -1;
       case 5:
          if ((active0 & 0x1008000020720800L) != 0L)
             return 1;
          if ((active0 & 0x7f1c001c1802200L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 5;
             return 1;
          }
          return -1;
       case 6:
+         if ((active0 & 0x800000L) != 0L)
+            return 1;
          if ((active0 & 0x7f1c001c1002200L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 6;
             return 1;
          }
-         if ((active0 & 0x800000L) != 0L)
-            return 1;
          return -1;
       case 7:
+         if ((active0 & 0x200000001002200L) != 0L)
+            return 1;
          if ((active0 & 0x5f1c001c0000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 7;
             return 1;
          }
-         if ((active0 & 0x200000001002200L) != 0L)
-            return 1;
          return -1;
       case 8:
+         if ((active0 & 0x10000080000000L) != 0L)
+            return 1;
          if ((active0 & 0x5e1c00140000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 8;
             return 1;
          }
-         if ((active0 & 0x10000080000000L) != 0L)
-            return 1;
          return -1;
       case 9:
+         if ((active0 & 0x800000000000L) != 0L)
+            return 1;
          if ((active0 & 0x5e1400140000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 9;
             return 1;
          }
-         if ((active0 & 0x800000000000L) != 0L)
-            return 1;
          return -1;
       case 10:
          if ((active0 & 0x521000000000000L) != 0L)
             return 1;
          if ((active0 & 0xc0400140000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 10;
             return 1;
          }
@@ -157,7 +160,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
             return 1;
          if ((active0 & 0xc0000040000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 11;
             return 1;
          }
@@ -165,7 +168,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 12:
          if ((active0 & 0xc0000040000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 12;
             return 1;
          }
@@ -175,7 +178,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
             return 1;
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 13;
             return 1;
          }
@@ -183,7 +186,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 14:
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 14;
             return 1;
          }
@@ -191,7 +194,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 15:
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 15;
             return 1;
          }
@@ -199,7 +202,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 16:
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 16;
             return 1;
          }
@@ -207,7 +210,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 17:
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 17;
             return 1;
          }
@@ -215,7 +218,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 18:
          if ((active0 & 0xc0000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 18;
             return 1;
          }
@@ -223,7 +226,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
       case 19:
          if ((active0 & 0x80000000000000L) != 0L)
          {
-            jjmatchedKind = 61;
+            jjmatchedKind = 62;
             jjmatchedPos = 19;
             return 1;
          }
@@ -267,7 +270,7 @@ private final int jjMoveStringLiteralDfa0_0()
       case 44:
          return jjStopAtPos(0, 36);
       case 59:
-         return jjStopAtPos(0, 67);
+         return jjStopAtPos(0, 68);
       case 60:
          return jjStopAtPos(0, 41);
       case 61:
@@ -282,7 +285,7 @@ private final int jjMoveStringLiteralDfa0_0()
          return jjMoveStringLiteralDfa1_0(0x24000000000000L);
       case 67:
       case 99:
-         return jjMoveStringLiteralDfa1_0(0x1041000040000880L);
+         return jjMoveStringLiteralDfa1_0(0x3041000040000880L);
       case 68:
       case 100:
          return jjMoveStringLiteralDfa1_0(0x901600L);
@@ -376,7 +379,7 @@ private final int jjMoveStringLiteralDfa1_0(long active0)
          return jjMoveStringLiteralDfa2_0(active0, 0x10000408460000L);
       case 79:
       case 111:
-         return jjMoveStringLiteralDfa2_0(active0, 0x43040050000000L);
+         return jjMoveStringLiteralDfa2_0(active0, 0x2043040050000000L);
       case 82:
       case 114:
          if ((active0 & 0x800000000L) != 0L)
@@ -463,7 +466,7 @@ private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
          return jjMoveStringLiteralDfa3_0(active0, 0x80000008040040L);
       case 85:
       case 117:
-         return jjMoveStringLiteralDfa3_0(active0, 0x40000000002000L);
+         return jjMoveStringLiteralDfa3_0(active0, 0x2040000000002000L);
       case 87:
       case 119:
          if ((active0 & 0x10000000L) != 0L)
@@ -522,7 +525,7 @@ private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
          return jjMoveStringLiteralDfa4_0(active0, 0x10000000000000L);
       case 78:
       case 110:
-         return jjMoveStringLiteralDfa4_0(active0, 0x1040000000002000L);
+         return jjMoveStringLiteralDfa4_0(active0, 0x3040000000002000L);
       case 79:
       case 111:
          if ((active0 & 0x40000L) != 0L)
@@ -616,6 +619,11 @@ private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
       case 116:
          if ((active0 & 0x200000000L) != 0L)
             return jjStartNfaWithStates_0(4, 33, 1);
+         else if ((active0 & 0x2000000000000000L) != 0L)
+         {
+            jjmatchedKind = 61;
+            jjmatchedPos = 4;
+         }
          return jjMoveStringLiteralDfa5_0(active0, 0x40000001100800L);
       case 85:
       case 117:
@@ -1208,14 +1216,14 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 0:
                   if ((0x3ff000000000000L & l) != 0L)
                   {
-                     if (kind > 62)
-                        kind = 62;
+                     if (kind > 63)
+                        kind = 63;
                      jjCheckNAddStates(0, 6);
                   }
                   else if ((0x400e00000000000L & l) != 0L)
                   {
-                     if (kind > 61)
-                        kind = 61;
+                     if (kind > 62)
+                        kind = 62;
                      jjCheckNAdd(1);
                   }
                   else if (curChar == 39)
@@ -1228,8 +1236,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 1:
                   if ((0x7ffe00000000000L & l) == 0L)
                      break;
-                  if (kind > 61)
-                     kind = 61;
+                  if (kind > 62)
+                     kind = 62;
                   jjCheckNAdd(1);
                   break;
                case 2:
@@ -1239,8 +1247,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 3:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAddTwoStates(3, 4);
                   break;
                case 5:
@@ -1250,8 +1258,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 6:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAdd(6);
                   break;
                case 7:
@@ -1263,8 +1271,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                      jjCheckNAddTwoStates(8, 9);
                   break;
                case 9:
-                  if (curChar == 34 && kind > 65)
-                     kind = 65;
+                  if (curChar == 34 && kind > 66)
+                     kind = 66;
                   break;
                case 10:
                   if (curChar == 39)
@@ -1287,21 +1295,21 @@ private final int jjMoveNfa_0(int startState, int curPos)
                      jjCheckNAddStates(10, 12);
                   break;
                case 15:
-                  if (curChar == 39 && kind > 66)
-                     kind = 66;
+                  if (curChar == 39 && kind > 67)
+                     kind = 67;
                   break;
                case 16:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 62)
-                     kind = 62;
+                  if (kind > 63)
+                     kind = 63;
                   jjCheckNAddStates(0, 6);
                   break;
                case 17:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 62)
-                     kind = 62;
+                  if (kind > 63)
+                     kind = 63;
                   jjCheckNAdd(17);
                   break;
                case 18:
@@ -1315,8 +1323,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 20:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAddTwoStates(20, 21);
                   break;
                case 22:
@@ -1326,8 +1334,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 23:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAdd(23);
                   break;
                case 24:
@@ -1341,15 +1349,15 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 27:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAdd(27);
                   break;
                case 28:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAddTwoStates(28, 29);
                   break;
                case 30:
@@ -1359,8 +1367,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 31:
                   if ((0x3ff000000000000L & l) == 0L)
                      break;
-                  if (kind > 63)
-                     kind = 63;
+                  if (kind > 64)
+                     kind = 64;
                   jjCheckNAdd(31);
                   break;
                default : break;
@@ -1378,8 +1386,8 @@ private final int jjMoveNfa_0(int startState, int curPos)
                case 1:
                   if ((0x47fffffe87fffffeL & l) == 0L)
                      break;
-                  if (kind > 61)
-                     kind = 61;
+                  if (kind > 62)
+                     kind = 62;
                   jjCheckNAdd(1);
                   break;
                case 4:
@@ -1458,12 +1466,12 @@ null, null, null, null, null, null, null, null, null, null, null, null, null, nu
 null, null, null, null, null, null, null, null, null, "\54", "\50", "\51", "\75", 
 "\76", "\74", null, null, "\41\75", "\52", null, null, null, null, null, null, null, 
 null, null, null, null, null, null, null, null, null, null, null, null, null, null, 
-"\73", };
+null, "\73", };
 public static final String[] lexStateNames = {
    "DEFAULT", 
 };
 static final long[] jjtoToken = {
-   0xffffffffffffffe1L, 0xeL, 
+   0xffffffffffffffe1L, 0x1dL, 
 };
 static final long[] jjtoSkip = {
    0x1eL, 0x0L,