You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2008/01/15 06:14:37 UTC

svn commit: r612016 [1/4] - in /lucene/hadoop/trunk/src/contrib/hbase: ./ conf/ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/generated/master/ src/java/org/apache/hadoop/hbase/hql/ src/java/org/apache/hadoop/hbase/hql/formatter/ s...

Author: stack
Date: Mon Jan 14 21:14:34 2008
New Revision: 612016

URL: http://svn.apache.org/viewvc?rev=612016&view=rev
Log:
HADOOP-2589 Change an classes/package name from shell to hql

Added:
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/AlterCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/BasicCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ClearCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/Command.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CommandFactory.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CreateCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DeleteCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DescCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DisableCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DropCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/EnableCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitException.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/FsCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLClient.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLParser.jj
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLSecurityManager.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HelpCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/InsertCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/JarCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ReturnMsg.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/SchemaModificationCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/SelectCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ShowCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/TableFormatter.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/TableFormatterFactory.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/TruncateCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/formatter/
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/formatter/AsciiTableFormatter.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/formatter/HtmlTableFormatter.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/HQLParser.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/HQLParserConstants.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/HQLParserTokenManager.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/ParseException.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/SimpleCharStream.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/Token.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/generated/TokenMgrError.java
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/hql/
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/hql/TestHQL.java
Removed:
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/
Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/build.xml
    lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-default.xml
    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/generated/master/hql_jsp.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
    lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/hql.jsp
    lucene/hadoop/trunk/src/contrib/hbase/src/webapps/master/master.jsp

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=612016&r1=612015&r2=612016&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Mon Jan 14 21:14:34 2008
@@ -179,6 +179,8 @@
    HADOOP-2548 Make TableMap and TableReduce generic
                (Frederik Hedberg via Stack)
    HADOOP-2557 Shell count function (Edward Yoon via Stack)
+   HADOOP-2589 Change an classes/package name from Shell to hql
+               (Edward Yoon via Stack)
 
 Release 0.15.1
 Branch 0.15

Modified: lucene/hadoop/trunk/src/contrib/hbase/build.xml
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/build.xml?rev=612016&r1=612015&r2=612016&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/build.xml (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/build.xml Mon Jan 14 21:14:34 2008
@@ -66,12 +66,12 @@
 
   <target name="javacc" if="javacc.home">
   <echo message="javacc.home: ${javacc.home}"/>
-  <property name="hbaseshell.src.dir" 
-       value="${src.dir}/org/apache/hadoop/hbase/shell" /> 
-     <mkdir dir="${hbaseshell.src.dir}/generated" />
+  <property name="hql.src.dir" 
+       value="${src.dir}/org/apache/hadoop/hbase/hql" /> 
+     <mkdir dir="${hql.src.dir}/generated" />
      <javacc
-       target="${hbaseshell.src.dir}/HBaseShell.jj"
-       outputdirectory="${hbaseshell.src.dir}/generated"
+       target="${hql.src.dir}/HQLParser.jj"
+       outputdirectory="${hql.src.dir}/generated"
        javacchome="${javacc.home}"
      />
   </target>

Modified: lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-default.xml
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-default.xml?rev=612016&r1=612015&r2=612016&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-default.xml (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/conf/hbase-default.xml Mon Jan 14 21:14:34 2008
@@ -229,7 +229,7 @@
   </property>  
   <property>
  	<name>hbaseshell.formatter</name>
-  	<value>org.apache.hadoop.hbase.shell.formatter.AsciiTableFormatter</value>
+  	<value>org.apache.hadoop.hbase.hql.formatter.AsciiTableFormatter</value>
   	<description>TableFormatter to use outputting HQL result sets.
   	</description>
   </property>  

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=612016&r1=612015&r2=612016&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 Mon Jan 14 21:14:34 2008
@@ -25,16 +25,13 @@
 
 import jline.ConsoleReader;
 
-import org.apache.hadoop.hbase.shell.Command;
-import org.apache.hadoop.hbase.shell.HelpCommand;
-import org.apache.hadoop.hbase.shell.ReturnMsg;
-import org.apache.hadoop.hbase.shell.ShellSecurityManager;
-import org.apache.hadoop.hbase.shell.TableFormatter;
-import org.apache.hadoop.hbase.shell.TableFormatterFactory;
-import org.apache.hadoop.hbase.shell.formatter.HtmlTableFormatter;
-import org.apache.hadoop.hbase.shell.generated.ParseException;
-import org.apache.hadoop.hbase.shell.generated.Parser;
-import org.apache.hadoop.hbase.shell.generated.TokenMgrError;
+import org.apache.hadoop.hbase.hql.HQLClient;
+import org.apache.hadoop.hbase.hql.HelpCommand;
+import org.apache.hadoop.hbase.hql.ReturnMsg;
+import org.apache.hadoop.hbase.hql.HQLSecurityManager;
+import org.apache.hadoop.hbase.hql.TableFormatter;
+import org.apache.hadoop.hbase.hql.TableFormatterFactory;
+import org.apache.hadoop.hbase.hql.formatter.HtmlTableFormatter;
 
 /**
  * An hbase shell.
@@ -90,7 +87,7 @@
     
     HBaseConfiguration conf = new HBaseConfiguration();
     ConsoleReader reader = new ConsoleReader();
-    System.setSecurityManager(new ShellSecurityManager());
+    System.setSecurityManager(new HQLSecurityManager());
     reader.setBellEnabled(conf.getBoolean("hbaseshell.jline.bell.enabled",
         DEFAULT_BELL_ENABLED));
     Writer out = new OutputStreamWriter(System.out, "UTF-8");
@@ -112,22 +109,9 @@
       if (isEndOfCommand(extendedLine)) {
         queryStr.append(" " + extendedLine);
         long start = System.currentTimeMillis();
-        Parser parser = new Parser(queryStr.toString(), out, tableFormater);
-        ReturnMsg rs = null;
-        try {
-          Command cmd = parser.terminatedCommand();
-          if (cmd != null) {
-            rs = cmd.execute(conf);
-          }
-        } catch (ParseException pe) {
-          String[] msg = pe.getMessage().split("[\n]");
-          System.out.println("Syntax error : Type 'help;' for usage.\nMessage : "
-              + msg[0]);
-        } catch (TokenMgrError te) {
-          String[] msg = te.getMessage().split("[\n]");
-          System.out.println("Lexical error : Type 'help;' for usage.\nMessage : "
-              + msg[0]);
-        }
+
+        HQLClient hql = new HQLClient(conf, MASTER_ADDRESS, out, tableFormater);
+        ReturnMsg rs = hql.executeQuery(queryStr.toString());
 
         long end = System.currentTimeMillis();
         if (rs != null && rs.getType() > -1)

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/hql_jsp.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/hql_jsp.java?rev=612016&r1=612015&r2=612016&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/hql_jsp.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/hql_jsp.java Mon Jan 14 21:14:34 2008
@@ -5,11 +5,11 @@
 import javax.servlet.jsp.*;
 import java.util.*;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.shell.TableFormatter;
-import org.apache.hadoop.hbase.shell.ReturnMsg;
-import org.apache.hadoop.hbase.shell.generated.Parser;
-import org.apache.hadoop.hbase.shell.Command;
-import org.apache.hadoop.hbase.shell.formatter.HtmlTableFormatter;
+import org.apache.hadoop.hbase.hql.TableFormatter;
+import org.apache.hadoop.hbase.hql.ReturnMsg;
+import org.apache.hadoop.hbase.hql.generated.HQLParser;
+import org.apache.hadoop.hbase.hql.Command;
+import org.apache.hadoop.hbase.hql.formatter.HtmlTableFormatter;
 
 public final class hql_jsp extends org.apache.jasper.runtime.HttpJspBase
     implements org.apache.jasper.runtime.JspSourceDependent {
@@ -60,7 +60,7 @@
  
       out.write("\n <hr/>\n ");
 
-    Parser parser = new Parser(query, out, new HtmlTableFormatter(out));
+    HQLParser parser = new HQLParser(query, out, new HtmlTableFormatter(out));
     Command cmd = parser.terminatedCommand();
     if (cmd.getCommandType() != Command.CommandType.SELECT) {
  

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java?rev=612016&r1=612015&r2=612016&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java Mon Jan 14 21:14:34 2008
@@ -14,10 +14,10 @@
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.shell.ShowCommand;
-import org.apache.hadoop.hbase.shell.TableFormatter;
-import org.apache.hadoop.hbase.shell.ReturnMsg;
-import org.apache.hadoop.hbase.shell.formatter.HtmlTableFormatter;
+import org.apache.hadoop.hbase.hql.ShowCommand;
+import org.apache.hadoop.hbase.hql.TableFormatter;
+import org.apache.hadoop.hbase.hql.ReturnMsg;
+import org.apache.hadoop.hbase.hql.formatter.HtmlTableFormatter;
 import org.apache.hadoop.hbase.HTableDescriptor;
 
 public final class master_jsp extends org.apache.jasper.runtime.HttpJspBase

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/AlterCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/AlterCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/AlterCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/AlterCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,248 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.io.Text;
+
+import org.apache.hadoop.hbase.BloomFilterDescriptor;
+import org.apache.hadoop.hbase.BloomFilterDescriptor.BloomFilterType;
+
+/**
+ * Alters tables.
+ */
+public class AlterCommand extends SchemaModificationCommand {
+  public enum OperationType {
+    ADD, DROP, CHANGE, NOOP
+  }
+
+  private OperationType operationType = OperationType.NOOP;
+  private Map<String, Map<String, Object>> columnSpecMap = new HashMap<String, Map<String, Object>>();
+  private String tableName;
+  private String column; // column to be dropped
+
+  public AlterCommand(Writer o) {
+    super(o);
+  }
+
+  @SuppressWarnings("unchecked")
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(this.tableName))) {
+        return new ReturnMsg(0, "'" + this.tableName + "'" + TABLE_NOT_FOUND);
+      }
+
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      Set<String> columns = null;
+      HColumnDescriptor columnDesc = null;
+      switch (operationType) {
+        case ADD:
+          disableTable(admin, tableName);
+          columns = columnSpecMap.keySet();
+          for (String c : columns) {
+            columnDesc = getColumnDescriptor(c, columnSpecMap.get(c));
+            println("Adding " + c + " to " + tableName + "... Please wait.");
+            admin.addColumn(new Text(tableName), columnDesc);
+          }
+          enableTable(admin, tableName);
+          break;
+        case DROP:
+          disableTable(admin, tableName);
+          println("Dropping " + column + " from " + tableName + "... Please wait.");
+          column = appendDelimiter(column);
+          admin.deleteColumn(new Text(tableName), new Text(column));
+          enableTable(admin, tableName);
+          break;
+        case CHANGE:
+          disableTable(admin, tableName);
+
+          Map.Entry<String, Map<String, Object>> columnEntry = (Map.Entry<String, Map<String, Object>>) columnSpecMap
+              .entrySet().toArray()[0];
+
+          // add the : if there isn't one
+          Text columnName = new Text(
+              columnEntry.getKey().endsWith(":") ? columnEntry.getKey()
+                  : columnEntry.getKey() + ":");
+
+          // get the table descriptor so we can get the old column descriptor
+          HTableDescriptor tDesc = getTableDescByName(admin, tableName);
+          HColumnDescriptor oldColumnDesc = tDesc.families().get(columnName);
+
+          // combine the options specified in the shell with the options
+          // from the exiting descriptor to produce the new descriptor
+          columnDesc = getColumnDescriptor(columnName.toString(), columnEntry
+              .getValue(), oldColumnDesc);
+
+          // send the changes out to the master
+          admin.modifyColumn(new Text(tableName), columnName, columnDesc);
+
+          enableTable(admin, tableName);
+          break;
+        case NOOP:
+          return new ReturnMsg(0, "Invalid operation type.");
+      }
+      return new ReturnMsg(0, "Table altered successfully.");
+    } catch (Exception e) {
+      return new ReturnMsg(0, extractErrMsg(e));
+    }
+  }
+
+  private void disableTable(HBaseAdmin admin, String t) throws IOException {
+    println("Disabling " + t + "... Please wait.");
+    admin.disableTable(new Text(t));
+  }
+
+  private void enableTable(HBaseAdmin admin, String t) throws IOException {
+    println("Enabling " + t + "... Please wait.");
+    admin.enableTable(new Text(t));
+  }
+
+  /**
+   * Sets the table to be altered.
+   * 
+   * @param t Table to be altered.
+   */
+  public void setTable(String t) {
+    this.tableName = t;
+  }
+
+  /**
+   * Adds a column specification.
+   * 
+   * @param columnSpec Column specification
+   */
+  public void addColumnSpec(String c, Map<String, Object> columnSpec) {
+    columnSpecMap.put(c, columnSpec);
+  }
+
+  /**
+   * Sets the column to be dropped. Only applicable to the DROP operation.
+   * 
+   * @param c Column to be dropped.
+   */
+  public void setColumn(String c) {
+    this.column = c;
+  }
+
+  /**
+   * Sets the operation type of this alteration.
+   * 
+   * @param operationType Operation type
+   * @see OperationType
+   */
+  public void setOperationType(OperationType operationType) {
+    this.operationType = operationType;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DDL;
+  }
+
+  private HTableDescriptor getTableDescByName(HBaseAdmin admin, String tableName)
+      throws IOException {
+    HTableDescriptor[] tables = admin.listTables();
+    for (HTableDescriptor tDesc : tables) {
+      if (tDesc.getName().toString().equals(tableName)) {
+        return tDesc;
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Given a column name, column spec, and original descriptor, returns an
+   * instance of HColumnDescriptor representing the column spec, with empty
+   * values drawn from the original as defaults
+   */
+  protected HColumnDescriptor getColumnDescriptor(String column,
+      Map<String, Object> columnSpec, HColumnDescriptor original)
+      throws IllegalArgumentException {
+    initOptions(original);
+
+    Set<String> specs = columnSpec.keySet();
+    for (String spec : specs) {
+      spec = spec.toUpperCase();
+
+      if (spec.equals("MAX_VERSIONS")) {
+        maxVersions = (Integer) columnSpec.get(spec);
+      } else if (spec.equals("MAX_LENGTH")) {
+        maxLength = (Integer) columnSpec.get(spec);
+      } else if (spec.equals("COMPRESSION")) {
+        compression = HColumnDescriptor.CompressionType.valueOf(((String) columnSpec
+            .get(spec)).toUpperCase());
+      } else if (spec.equals("IN_MEMORY")) {
+        inMemory = (Boolean) columnSpec.get(spec);
+      } else if (spec.equals("BLOOMFILTER")) {
+        bloomFilterType = BloomFilterType.valueOf(((String) columnSpec.get(spec))
+            .toUpperCase());
+      } else if (spec.equals("VECTOR_SIZE")) {
+        vectorSize = (Integer) columnSpec.get(spec);
+      } else if (spec.equals("NUM_HASH")) {
+        numHash = (Integer) columnSpec.get(spec);
+      } else if (spec.equals("NUM_ENTRIES")) {
+        numEntries = (Integer) columnSpec.get(spec);
+      } else {
+        throw new IllegalArgumentException("Invalid option: " + spec);
+      }
+    }
+
+    // Now we gather all the specified options for this column.
+    if (bloomFilterType != null) {
+      if (specs.contains("NUM_ENTRIES")) {
+        bloomFilterDesc = new BloomFilterDescriptor(bloomFilterType, numEntries);
+      } else {
+        bloomFilterDesc = new BloomFilterDescriptor(bloomFilterType, vectorSize,
+            numHash);
+      }
+    }
+
+    column = appendDelimiter(column);
+
+    HColumnDescriptor columnDesc = new HColumnDescriptor(new Text(column),
+        maxVersions, compression, inMemory, maxLength, bloomFilterDesc);
+
+    return columnDesc;
+  }
+
+  private void initOptions(HColumnDescriptor original) {
+    if (original == null) {
+      initOptions();
+      return;
+    }
+    maxVersions = original.getMaxVersions();
+    maxLength = original.getMaxValueLength();
+    compression = original.getCompression();
+    inMemory = original.isInMemory();
+    bloomFilterDesc = original.getBloomFilter();
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/BasicCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/BasicCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/BasicCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/BasicCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,100 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Takes the lowest-common-denominator {@link Writer} doing its own printlns,
+ * etc.
+ * 
+ * @see <a
+ *      href="http://wiki.apache.org/lucene-hadoop/Hbase/HbaseShell">HBaseShell</a>
+ */
+public abstract class BasicCommand implements Command, CommandFactory {
+  private final Writer out;
+  public final String LINE_SEPARATOR = System.getProperty("line.separator");
+  public final String TABLE_NOT_FOUND = " is non-existant table.";
+
+  // Shutdown constructor.
+  @SuppressWarnings("unused")
+  private BasicCommand() {
+    this(null);
+  }
+
+  /**
+   * Constructor
+   * 
+   * @param o A Writer.
+   */
+  public BasicCommand(final Writer o) {
+    this.out = o;
+  }
+
+  public BasicCommand getBasicCommand() {
+    return this;
+  }
+
+  /** basic commands are their own factories. */
+  public Command getCommand() {
+    return this;
+  }
+
+  protected String extractErrMsg(String msg) {
+    int index = msg.indexOf(":");
+    int eofIndex = msg.indexOf("\n");
+    return msg.substring(index + 1, eofIndex);
+  }
+
+  protected String extractErrMsg(Exception e) {
+    return extractErrMsg(e.getMessage());
+  }
+
+  /**
+   * Appends, if it does not exist, a delimiter (colon) at the end of the column
+   * name.
+   */
+  protected String appendDelimiter(String column) {
+    return (!column.endsWith(FAMILY_INDICATOR) && column
+        .indexOf(FAMILY_INDICATOR) == -1) ? column + FAMILY_INDICATOR : column;
+  }
+
+  /**
+   * @return Writer to use outputting.
+   */
+  public Writer getOut() {
+    return this.out;
+  }
+
+  public void print(final String msg) throws IOException {
+    this.out.write(msg);
+  }
+
+  public void println(final String msg) throws IOException {
+    print(msg);
+    print(LINE_SEPARATOR);
+    this.out.flush();
+  }
+
+  public CommandType getCommandType() {
+    return CommandType.SELECT;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ClearCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ClearCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ClearCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ClearCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+
+/**
+ * Clears the console screen.
+ */
+public class ClearCommand extends BasicCommand {
+  public ClearCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(@SuppressWarnings("unused")
+  HBaseConfiguration conf) {
+    clear();
+    return null;
+  }
+
+  private void clear() {
+    String osName = System.getProperty("os.name");
+    if (osName.length() > 7 && osName.subSequence(0, 7).equals("Windows")) {
+      try {
+        Runtime.getRuntime().exec("cmd /C cls");
+      } catch (IOException e) {
+        try {
+          println("Can't clear." + e.toString());
+        } catch (IOException e1) {
+          e1.printStackTrace();
+        }
+      }
+    } else {
+      try {
+        print("\033c");
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.SHELL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/Command.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/Command.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/Command.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/Command.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+
+public interface Command {
+  /** family indicator */
+  public static final String FAMILY_INDICATOR = ":";
+
+  public enum CommandType {
+    DDL, UPDATE, SELECT, INSERT, DELETE, SHELL
+  }
+
+  /**
+   * Execute a command
+   * 
+   * @param conf Configuration
+   * @return Result of command execution
+   */
+  public ReturnMsg execute(final HBaseConfiguration conf);
+
+  /**
+   * @return Type of this command whether DDL, SELECT, INSERT, UPDATE, DELETE,
+   *         or SHELL.
+   */
+  public CommandType getCommandType();
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CommandFactory.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CommandFactory.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CommandFactory.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CommandFactory.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+/**
+ * Parser uses command factories to create command.
+ */
+public interface CommandFactory {
+  Command getCommand();
+}
\ No newline at end of file

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CreateCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CreateCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CreateCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/CreateCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Creates tables.
+ */
+public class CreateCommand extends SchemaModificationCommand {
+  private Text tableName;
+  private Map<String, Map<String, Object>> columnSpecMap = new HashMap<String, Map<String, Object>>();
+
+  public CreateCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (conn.tableExists(tableName)) {
+        return new ReturnMsg(0, "'" + tableName + "' table already exist.");
+      }
+
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      HTableDescriptor tableDesc = new HTableDescriptor(tableName.toString());
+      HColumnDescriptor columnDesc = null;
+      Set<String> columns = columnSpecMap.keySet();
+      for (String column : columns) {
+        columnDesc = getColumnDescriptor(column, columnSpecMap.get(column));
+        tableDesc.addFamily(columnDesc);
+      }
+
+      println("Creating table... Please wait.");
+
+      admin.createTable(tableDesc);
+      return new ReturnMsg(0, "Table created successfully.");
+    } catch (Exception e) {
+      return new ReturnMsg(0, extractErrMsg(e));
+    }
+  }
+
+  /**
+   * Sets the table to be created.
+   * 
+   * @param tableName Table to be created
+   */
+  public void setTable(String tableName) {
+    this.tableName = new Text(tableName);
+  }
+
+  /**
+   * Adds a column specification.
+   * 
+   * @param columnSpec Column specification
+   */
+  public void addColumnSpec(String column, Map<String, Object> columnSpec) {
+    columnSpecMap.put(column, columnSpec);
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DDL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DeleteCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DeleteCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DeleteCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DeleteCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,131 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.hbase.HTable;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Deletes values from tables.
+ */
+public class DeleteCommand extends BasicCommand {
+  public DeleteCommand(Writer o) {
+    super(o);
+  }
+
+  private Text tableName;
+  private Text rowKey;
+  private List<String> columnList;
+
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    if (columnList == null) {
+      throw new IllegalArgumentException("Column list is null");
+    }
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(tableName)) {
+        return new ReturnMsg(0, "'" + tableName + "'" + TABLE_NOT_FOUND);
+      }
+
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      HTable hTable = new HTable(conf, tableName);
+
+      if (rowKey != null) {
+        long lockID = hTable.startUpdate(rowKey);
+        for (Text column : getColumnList(admin, hTable)) {
+          hTable.delete(lockID, new Text(column));
+        }
+        hTable.commit(lockID);
+      } else {
+        admin.disableTable(tableName);
+        for (Text column : getColumnList(admin, hTable)) {
+          admin.deleteColumn(tableName, new Text(column));
+        }
+        admin.enableTable(tableName);
+      }
+
+      return new ReturnMsg(1, "Column(s) deleted successfully.");
+    } catch (IOException e) {
+      String[] msg = e.getMessage().split("[\n]");
+      return new ReturnMsg(0, msg[0]);
+    }
+  }
+
+  public void setTable(String tableName) {
+    this.tableName = new Text(tableName);
+  }
+
+  public void setRow(String row) {
+    this.rowKey = new Text(row);
+  }
+
+  /**
+   * Sets the column list.
+   * 
+   * @param columnList
+   */
+  public void setColumnList(List<String> columnList) {
+    this.columnList = columnList;
+  }
+
+  /**
+   * @param admin
+   * @param hTable
+   * @return return the column list.
+   */
+  public Text[] getColumnList(HBaseAdmin admin, HTable hTable) {
+    Text[] columns = null;
+    try {
+      if (columnList.contains("*")) {
+        columns = hTable.getRow(new Text(this.rowKey)).keySet().toArray(
+            new Text[] {});
+      } else {
+        List<Text> tmpList = new ArrayList<Text>();
+        for (int i = 0; i < columnList.size(); i++) {
+          Text column = null;
+          if (columnList.get(i).contains(":"))
+            column = new Text(columnList.get(i));
+          else
+            column = new Text(columnList.get(i) + ":");
+
+          tmpList.add(column);
+        }
+        columns = tmpList.toArray(new Text[] {});
+      }
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    return columns;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DELETE;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DescCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DescCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DescCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DescCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Prints information about tables.
+ */
+public class DescCommand extends BasicCommand {
+  private static final String[] HEADER = new String[] { "Column Family Descriptor" };
+  private Text tableName;
+  private final TableFormatter formatter;
+
+  // Not instantiable
+  @SuppressWarnings("unused")
+  private DescCommand() {
+    this(null, null);
+  }
+
+  public DescCommand(final Writer o, final TableFormatter f) {
+    super(o);
+    this.formatter = f;
+  }
+
+  public ReturnMsg execute(final HBaseConfiguration conf) {
+    if (tableName == null)
+      return new ReturnMsg(0, "Syntax error : Please check 'Describe' syntax.");
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(tableName)) {
+        return new ReturnMsg(0, "Table not found.");
+      }
+      HTableDescriptor[] tables = conn.listTables();
+      HColumnDescriptor[] columns = null;
+      for (int i = 0; i < tables.length; i++) {
+        if (tables[i].getName().equals(tableName)) {
+          columns = tables[i].getFamilies().values().toArray(
+              new HColumnDescriptor[] {});
+          break;
+        }
+      }
+      formatter.header(HEADER);
+      // Do a toString on the HColumnDescriptors
+      String[] columnStrs = new String[columns.length];
+      for (int i = 0; i < columns.length; i++) {
+        String tmp = columns[i].toString();
+        // Strip the curly-brackets if present.
+        if (tmp.length() > 2 && tmp.startsWith("{") && tmp.endsWith("}")) {
+          tmp = tmp.substring(1, tmp.length() - 1);
+        }
+        columnStrs[i] = tmp;
+        formatter.row(new String[] { columnStrs[i] });
+      }
+      formatter.footer();
+      return new ReturnMsg(1, columns.length + " columnfamily(s) in set.");
+    } catch (IOException e) {
+      return new ReturnMsg(0, "error msg : " + e.toString());
+    }
+  }
+
+  public void setArgument(String table) {
+    this.tableName = new Text(table);
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DisableCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DisableCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DisableCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DisableCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Disables tables.
+ */
+public class DisableCommand extends BasicCommand {
+  private String tableName;
+
+  public DisableCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    assert tableName != null;
+
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(tableName))) {
+        return new ReturnMsg(0, "'" + tableName + "'" + TABLE_NOT_FOUND);
+      }
+
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      admin.disableTable(new Text(tableName));
+
+      return new ReturnMsg(1, "Table disabled successfully.");
+    } catch (IOException e) {
+      String[] msg = e.getMessage().split("[\n]");
+      return new ReturnMsg(0, msg[0]);
+    }
+  }
+
+  public void setTable(String table) {
+    this.tableName = table;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DDL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DropCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DropCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DropCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/DropCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Drops tables.
+ */
+public class DropCommand extends BasicCommand {
+  private List<String> tableList;
+
+  public DropCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    if (tableList == null) {
+      throw new IllegalArgumentException("List of tables is null.");
+    }
+
+    try {
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      HConnection conn = HConnectionManager.getConnection(conf);
+
+      int count = 0;
+      for (String table : tableList) {
+        if (!conn.tableExists(new Text(table))) {
+          println("'" + table + "' table not found.");
+        } else {
+          println("Dropping " + table + "... Please wait.");
+          admin.deleteTable(new Text(table));
+          count++;
+        }
+      }
+
+      if (count > 0) {
+        return new ReturnMsg(1, count + " table(s) dropped successfully.");
+      } else {
+        return new ReturnMsg(0, count + " table(s) dropped.");
+      }
+    } catch (IOException e) {
+      return new ReturnMsg(0, extractErrMsg(e));
+    }
+  }
+
+  public void setTableList(List<String> tableList) {
+    this.tableList = tableList;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DDL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/EnableCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/EnableCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/EnableCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/EnableCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseAdmin;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
+import org.apache.hadoop.io.Text;
+
+/**
+ * Enables tables.
+ */
+public class EnableCommand extends BasicCommand {
+  private String tableName;
+
+  public EnableCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(HBaseConfiguration conf) {
+    assert tableName != null;
+    try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(tableName))) {
+        return new ReturnMsg(0, "'" + tableName + "'" + TABLE_NOT_FOUND);
+      }
+
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      admin.enableTable(new Text(tableName));
+      return new ReturnMsg(1, "Table enabled successfully.");
+    } catch (IOException e) {
+      String[] msg = e.getMessage().split("[\n]");
+      return new ReturnMsg(0, msg[0]);
+    }
+  }
+
+  public void setTable(String table) {
+    this.tableName = table;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.DDL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.Shell;
+
+public class ExitCommand extends BasicCommand {
+  public ExitCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(@SuppressWarnings("unused")
+  HBaseConfiguration conf) {
+    // TOD: Is this the best way to exit? Would be a problem if shell is run
+    // inside another program -- St.Ack 09/11/2007
+    System.exit(Shell.EXIT_FLAG);
+    return null;
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.SHELL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitException.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitException.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitException.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/ExitException.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+public class ExitException extends SecurityException {
+  private static final long serialVersionUID = -8085525076856622991L;
+  /** Status code */
+  private int status;
+
+  /**
+   * Constructs an exit exception.
+   * 
+   * @param status the status code returned via System.exit()
+   */
+  public ExitException(int status) {
+    this.status = status;
+  }
+
+  /**
+   * The status code returned by System.exit()
+   * 
+   * @return the status code returned by System.exit()
+   */
+  public int getStatus() {
+    return status;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/FsCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/FsCommand.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/FsCommand.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/FsCommand.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.Writer;
+import java.util.List;
+
+import org.apache.hadoop.fs.FsShell;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.util.ToolRunner;
+
+/**
+ * Run hadoop filesystem commands.
+ */
+public class FsCommand extends BasicCommand {
+  private List<String> query;
+
+  public FsCommand(Writer o) {
+    super(o);
+  }
+
+  public ReturnMsg execute(@SuppressWarnings("unused")
+  HBaseConfiguration conf) {
+    // This commmand will write the
+    FsShell shell = new FsShell();
+    try {
+      ToolRunner.run(shell, getQuery());
+      shell.close();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return null;
+  }
+
+  public void setQuery(List<String> query) {
+    this.query = query;
+  }
+
+  private String[] getQuery() {
+    return query.toArray(new String[] {});
+  }
+
+  @Override
+  public CommandType getCommandType() {
+    return CommandType.SHELL;
+  }
+}

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLClient.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLClient.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLClient.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLClient.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,62 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.Writer;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.hql.generated.HQLParser;
+import org.apache.hadoop.hbase.hql.generated.ParseException;
+import org.apache.hadoop.hbase.hql.generated.TokenMgrError;
+
+public class HQLClient {
+  public static String MASTER_ADDRESS = null;
+  static HBaseConfiguration conf;
+  static TableFormatter tableFormater;
+  static Writer out;
+
+  public HQLClient(HBaseConfiguration config, String master, Writer output,
+      TableFormatter formatter) {
+    conf = config;
+    out = output;
+    tableFormater = formatter;
+    MASTER_ADDRESS = master;
+  }
+
+  public ReturnMsg executeQuery(String query) {
+    HQLParser parser = new HQLParser(query, out, tableFormater);
+    ReturnMsg rs = null;
+
+    try {
+      Command cmd = parser.terminatedCommand();
+      if (cmd != null) {
+        rs = cmd.execute(conf);
+      }
+    } catch (ParseException pe) {
+      String[] msg = pe.getMessage().split("[\n]");
+      rs = new ReturnMsg(-9, "Syntax error : Type 'help;' for usage.\nMessage : " + msg[0]);
+    } catch (TokenMgrError te) {
+      String[] msg = te.getMessage().split("[\n]");
+      rs = new ReturnMsg(-9, "Lexical error : Type 'help;' for usage.\nMessage : " + msg[0]);
+    }
+
+    return rs;
+  }
+}
\ No newline at end of file

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLParser.jj
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLParser.jj?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLParser.jj (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLParser.jj Mon Jan 14 21:14:34 2008
@@ -0,0 +1,823 @@
+options {
+  STATIC = false;
+  IGNORE_CASE = true;
+}
+
+PARSER_BEGIN(HQLParser)
+package org.apache.hadoop.hbase.hql.generated;
+
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.StringReader;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URLEncoder;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.hadoop.hbase.hql.*;
+
+/**
+ * Parsing command line.
+ */
+public class HQLParser {
+  private String QueryString;
+  private TableFormatter formatter;
+  private Writer out;
+  
+  public HQLParser(final String query, final Writer o, final TableFormatter f) {
+    this((Reader)(new StringReader(query)));
+    this.QueryString = query;
+    this.formatter = f;
+    this.out = o;
+  }
+  
+  public String getQueryStr() {
+    return this.QueryString;
+  }
+}
+
+PARSER_END(HQLParser)
+
+SKIP :                             
+{
+    " "
+ | "\t"
+ | "\r"
+ | "\n"
+}
+
+TOKEN: /** for HQL statements */
+{
+   <HELP: "help">
+   | <ALTER: "alter">
+   | <CLEAR: "clear">
+   | <SHOW: "show">
+   | <DESCRIBE: "describe">
+   | <DESC: "desc">
+   | <CREATE: "create">   
+   | <DROP: "drop">
+   | <TRUNCATE: "truncate">
+   | <FS: "fs">
+   | <JAR: "jar">
+   | <EXIT: "exit">
+   | <INSERT: "insert">
+   | <INTO: "into">
+   | <TABLE: "table">
+   | <DELETE: "delete">
+   | <SELECT: "select">
+   | <ENABLE: "enable">
+   | <DISABLE: "disable">
+   | <STARTING: "starting">
+   | <WHERE: "where">
+   | <FROM: "from">
+   | <UNTIL: "until">
+   | <ROW: "row">
+   | <VALUES: "values">
+   | <COLUMNFAMILIES: "columnfamilies">
+   | <TIMESTAMP: "timestamp">
+   | <NUM_VERSIONS: "num_versions">
+   | <LIMIT: "limit">
+   | <AND: "and">
+   | <OR:  "or">
+   | <COMMA: ",">
+   | <LPAREN: "(">
+   | <RPAREN: ")">
+   | <EQUALS: "=">
+   | <LCOMP: ">">
+   | <RCOMP: "<">
+   | <NOT: "not">
+   | <IN: "in">
+   | <NOTEQUAL: "!=">
+   | <ASTERISK: "*">
+   | <MAX_VERSIONS: "max_versions">
+   | <MAX_LENGTH: "max_length">
+   | <COMPRESSION: "compression">
+   | <NONE: "none">
+   | <BLOCK: "block">
+   | <RECORD: "record">
+   | <IN_MEMORY: "in_memory">
+   | <BLOOMFILTER: "bloomfilter">
+   | <COUNTING_BLOOMFILTER: "counting_bloomfilter">
+   | <RETOUCHED_BLOOMFILTER: "retouched_bloomfilter">
+   | <VECTOR_SIZE: "vector_size">
+   | <NUM_HASH: "num_hash">
+   | <NUM_ENTRIES: "num_entries">
+   | <ADD: "add">
+   | <CHANGE: "change">
+}
+
+TOKEN : /** Functions */
+{
+   <COUNT: "count">
+}
+ 
+TOKEN : /** Literals */
+{
+   <ID: ["A"-"Z","a"-"z","_","-",":","/","~","."] (["A"-"Z","a"-"z","0"-"9","_","-",":","/","~","."])* >
+ | <INTEGER_LITERAL: (["0"-"9"])+ >
+ | <FLOATING_POINT_LITERAL:
+   (["0"-"9"])+ "." (["0"-"9"])+ (<EXPONENT>)?
+  | "." (["0"-"9"])+ (<EXPONENT>)?
+  | (["0"-"9"])+ <EXPONENT>
+  | (["0"-"9"])+ (<EXPONENT>)?
+   >
+ | <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+ | <QUOTED_IDENTIFIER: "\"" (~["\""])+ "\"" >
+ | <STRING_LITERAL: "'" (~["'"])* ( "''" (~["'"])* )* "'" >
+}
+
+/**
+ * Parses the given array of command line arguments.
+ */
+Command terminatedCommand() :
+{
+    Command statement = null;
+}
+{
+    (
+      [statement = cmdStatement()] ";" | <EOF>
+    )
+  
+    {
+        return statement;
+    }
+}
+
+Command cmdStatement() :
+{
+    Command cmd = null;
+}
+{
+  (
+      cmd = exitCommand()
+      | cmd = helpCommand()
+      | cmd = showCommand()
+      | cmd = descCommand()
+      | cmd = createCommand()
+      | cmd = dropCommand()
+      | cmd = truncateCommand()
+      | cmd = alterCommand()
+      | cmd = insertCommand()
+      | cmd = deleteCommand()
+      | cmd = selectCommand()
+      | cmd = enableCommand()
+      | cmd = disableCommand()
+      | cmd = clearCommand()
+      | cmd = fsCommand()
+      | cmd = jarCommand()
+  )
+   {
+       return cmd;
+   }
+}
+
+ExitCommand exitCommand() :
+{
+  ExitCommand exit = new ExitCommand(this.out);
+}
+{
+   <EXIT>  { return exit; }
+}
+
+FsCommand fsCommand() :
+{
+  Token t = null;
+  FsCommand fs = new FsCommand(this.out);
+  List<String> query = new ArrayList<String>();
+}
+{
+  <FS>
+  (
+      t = <ID>
+      { query.add(t.image.toString()); }
+  )*
+  
+  {
+    fs.setQuery(query);
+    return fs;
+  }
+}
+
+JarCommand jarCommand() :
+{
+  Token t = null;
+  JarCommand jar = new JarCommand(this.out);
+  List<String> query = new ArrayList<String>();
+}
+{
+  <JAR>
+  (
+      ( t=<ID> | t=<INTEGER_LITERAL> | t=<FLOATING_POINT_LITERAL> )
+      { query.add(t.image.toString()); }
+  )*
+  
+  {
+    jar.setQuery(query);
+    return jar;
+  }
+}
+
+TruncateCommand truncateCommand() :
+{
+  TruncateCommand truncate = new TruncateCommand(this.out);
+  String tableName = null;
+}
+{
+  <TRUNCATE><TABLE>
+  [
+    tableName = identifier()
+  ]
+  {
+    truncate.setTableName(tableName);
+    return truncate;
+  }
+}
+
+HelpCommand helpCommand() :
+{
+  Token t = null;
+  HelpCommand help = new HelpCommand(this.out, this.formatter);
+  String argument = "";
+}
+{
+   <HELP>
+   [
+     (
+         t=<SHOW>
+       | t=<DESCRIBE>
+       | t=<CREATE>
+       | t=<DROP>
+       | t=<EXIT>
+       | t=<INSERT>
+       | t=<DELETE>
+       | t=<SELECT>
+       | t=<ALTER>
+       | t=<CLEAR>
+       | t=<FS>
+       | t=<JAR>
+       | t=<ID>
+     ) { argument = t.image.toString(); }
+   ]
+   
+  { 
+      help.setArgument(argument);
+      return help;  
+  }
+}
+
+ShowCommand showCommand() :
+{
+  ShowCommand show = new ShowCommand(this.out, this.formatter);
+  String argument = null;
+}
+{
+   <SHOW>
+   [
+       argument = identifier()
+   ]
+  { 
+      show.setArgument(argument);
+      return show;
+  }
+}
+
+DescCommand descCommand() :
+{
+  DescCommand desc = new DescCommand(this.out, this.formatter);
+  String argument = null;
+}
+{
+  ( <DESCRIBE> | <DESC> )
+  argument = identifier()
+  { 
+    desc.setArgument(argument);
+    return desc;
+  }
+}
+
+Map<String, Object> ColumnSpec() :
+{
+  Map<String, Object> columnSpec = new HashMap<String, Object>();
+  int n = -1;
+  Token t = null;
+}
+{
+  (
+    <MAX_VERSIONS> 
+     <EQUALS> n = number() 
+    { 
+       if(n < 0) {
+         n = Integer.MAX_VALUE;
+       }
+      columnSpec.put("MAX_VERSIONS", n); 
+    }
+   |
+    <MAX_LENGTH>
+     <EQUALS> n = number()
+    {  
+      columnSpec.put("MAX_LENGTH", n); 
+    }
+   |
+    <COMPRESSION>
+     <EQUALS> 
+    (  t=<NONE>
+     | t=<BLOCK>
+     | t=<RECORD> )
+    { 
+      columnSpec.put("COMPRESSION", t.image.toString()); 
+    }
+   |
+    <IN_MEMORY> 
+    { 
+      columnSpec.put("IN_MEMORY", true); 
+    } 
+   |  
+    <BLOOMFILTER>
+    <EQUALS> 
+    (  t=<BLOOMFILTER> 
+     | t=<COUNTING_BLOOMFILTER> 
+     | t=<RETOUCHED_BLOOMFILTER> 
+    )
+    { 
+      columnSpec.put("BLOOMFILTER", t.image.toString()); 
+    }
+   |  
+    <VECTOR_SIZE> 
+    <EQUALS> n = number() 
+    { 
+      columnSpec.put("VECTOR_SIZE", n); 
+    }
+   |
+    <NUM_HASH>
+    <EQUALS> n = number()
+    { 
+      columnSpec.put("NUM_HASH", n); 
+    }  
+   |
+    <NUM_ENTRIES> <EQUALS> n = number()
+    { 
+      columnSpec.put("NUM_ENTRIES", n); 
+    }
+  )*
+
+  { return columnSpec; }  
+}
+
+CreateCommand createCommand() :
+{
+  CreateCommand createCommand = new CreateCommand(this.out);
+  String table = null;
+  Map<String, Object> columnSpec = null;
+  String column = null;
+}
+{
+  <CREATE> 
+  <TABLE> 
+  table = identifier() 
+  { 
+    createCommand.setTable(table); 
+  }
+  
+  <LPAREN>
+  
+  column = identifier() 
+  columnSpec = ColumnSpec()
+  { 
+    createCommand.addColumnSpec(column, columnSpec); 
+  }
+  
+  (
+     <COMMA> 
+      column = identifier() 
+      columnSpec = ColumnSpec() 
+      { 
+        createCommand.addColumnSpec(column, columnSpec); 
+      }
+  )*
+  
+  <RPAREN> 
+  { return createCommand; }
+}
+
+AlterCommand alterCommand() :
+{
+  AlterCommand alterCommand = new AlterCommand(this.out);
+  String table = null;
+  String column = null;
+  Map<String, Object> columnSpec = null;
+}
+{
+  <ALTER> 
+  <TABLE> table = identifier() 
+  { alterCommand.setTable(table); }
+
+  (
+    LOOKAHEAD(2)
+      <ADD> column = identifier() columnSpec = ColumnSpec() 
+      { 
+         alterCommand.setOperationType(AlterCommand.OperationType.ADD);
+         alterCommand.addColumnSpec(column, columnSpec); 
+      }
+  |
+    <ADD>
+    <LPAREN> 
+    { 
+      alterCommand.setOperationType(AlterCommand.OperationType.ADD); 
+    }
+      
+    column = identifier() columnSpec = ColumnSpec() 
+    { 
+      alterCommand.addColumnSpec(column, columnSpec); 
+    }
+      
+    ( 
+        <COMMA> 
+        column = identifier()
+        columnSpec = ColumnSpec() 
+        { 
+          alterCommand.addColumnSpec(column, columnSpec); 
+        }
+    )*
+    <RPAREN>
+  |
+    <DROP> column = identifier()
+    { 
+      alterCommand.setOperationType(AlterCommand.OperationType.DROP);
+      alterCommand.setColumn(column); 
+    }
+  |
+    <CHANGE> column = identifier() columnSpec = ColumnSpec()  
+    { 
+      alterCommand.setOperationType(AlterCommand.OperationType.CHANGE);
+      alterCommand.addColumnSpec(column, columnSpec);
+    }
+  )
+  { return alterCommand; }
+}
+
+DropCommand dropCommand() :
+{
+  DropCommand drop = new DropCommand(this.out);
+  List<String> tableList = null;
+}
+{
+   <DROP>
+   <TABLE>
+   tableList = tableList()
+   { 
+     drop.setTableList(tableList);
+     return drop;
+   }
+}
+
+InsertCommand insertCommand() :
+{
+  InsertCommand in = new InsertCommand(this.out);
+  List<String> columnfamilies = null;
+  List<String> values = null;
+  String table = null;
+  String timestamp = null;
+  Token t = null;       
+}
+{
+  <INSERT>
+  <INTO>
+  table = identifier()
+  { 
+     in.setTable(table); 
+  }
+  columnfamilies = getColumns()
+  {
+     in.setColumnfamilies(columnfamilies);
+  }
+  
+  <VALUES> values = getLiteralValues()
+  {
+     in.setValues(values);
+  }
+      
+  <WHERE> 
+  <ROW> <EQUALS> ( t=<STRING_LITERAL> | t=<QUOTED_IDENTIFIER> )
+  { 
+     in.setRow(t.image.substring(1, t.image.length()-1)); 
+  }
+
+  [ <TIMESTAMP> 
+    timestamp = getStringLiteral()
+    {
+       in.setTimestamp(timestamp);
+    }
+  ]
+
+  {
+    return in;
+  }
+}
+
+DeleteCommand deleteCommand() :
+{
+  DeleteCommand deleteCommand = new DeleteCommand(this.out);
+  List<String> columnList = null;
+  Token t = null;
+  String table = null;
+}
+{
+  <DELETE>
+  columnList = columnList()
+  { 
+    deleteCommand.setColumnList(columnList); 
+  }
+
+  <FROM>
+  table = identifier()
+  { 
+    deleteCommand.setTable(table); 
+  }
+
+  [
+   <WHERE> 
+   <ROW> <EQUALS> ( t=<STRING_LITERAL> | t=<QUOTED_IDENTIFIER> )
+   { 
+     deleteCommand.setRow(t.image.substring(1, t.image.length()-1)); 
+   }
+  ]
+  { return deleteCommand; }
+}
+
+SelectCommand selectCommand() :
+{
+  SelectCommand select = new SelectCommand(this.out, this.formatter);
+  List<String> columns = null;
+  String rowKey = "";
+  String stopRow = "";
+  String timestamp = null;
+  int numVersion = 0;
+  String tableName = null;
+  int limit;
+}
+{
+  <SELECT>
+  (
+      <COUNT>  columns = getLiteralValues()
+      { select.setCountFunction(true); }
+    | columns = columnList()
+  )
+  <FROM>
+  tableName = identifier()
+  { 
+     select.setColumns(columns);
+     select.setTable(tableName);
+  }
+
+  [ ( <WHERE> <ROW> <EQUALS>
+     { select.setWhere(true); }
+     | <STARTING> <FROM> )
+    
+     rowKey = getStringLiteral()
+     {
+       select.setRowKey(rowKey); 
+     }
+     [<UNTIL>
+      stopRow = getStringLiteral()
+     {select.setStopRow(stopRow);} ]
+  ]
+
+  [ <TIMESTAMP> 
+    timestamp = getStringLiteral()
+    {
+       select.setTimestamp(timestamp);
+    }
+  ]
+   
+  [
+     <NUM_VERSIONS><EQUALS> numVersion = number()
+      {
+        select.setVersion(numVersion);
+      }
+  ]
+
+  [ <LIMIT><EQUALS> limit = number() {
+      try{
+        select.setLimit(limit);
+      }catch(ClassCastException ce) {
+        throw generateParseException();
+      }
+   } ]
+  { return select; }
+}
+
+EnableCommand enableCommand() :
+{
+  EnableCommand enableCommand = new EnableCommand(this.out);
+  String table = null;
+}
+{
+  <ENABLE> 
+  table = identifier()
+  { 
+    enableCommand.setTable(table);
+    return enableCommand;
+  }
+}
+
+DisableCommand disableCommand() :
+{
+  DisableCommand disableCommand = new DisableCommand(this.out);
+  String table = null;
+}
+{
+  <DISABLE> 
+  table = identifier()
+  { 
+    disableCommand.setTable(table); 
+    return disableCommand;
+  }
+}
+
+ClearCommand clearCommand() :
+{
+  ClearCommand clear = new ClearCommand(this.out);
+}
+{
+   <CLEAR>
+   { 
+     return clear; 
+   }
+}
+
+List<String> getLiteralValues() :
+{
+  List<String> values = new ArrayList<String>();
+  String literal = null;
+}
+{    
+<LPAREN>
+ {
+    literal = getStringLiteral();
+    if(literal != null) values.add(literal); 
+ }
+
+    (
+        <COMMA> { 
+           literal = getStringLiteral(); 
+           if(literal != null) values.add(literal); 
+        }
+    )*
+<RPAREN>
+   { 
+     return values;
+    }
+}
+
+String getStringLiteral() :
+{
+  Token s;
+  String value = null;
+}
+{
+  (
+    ( 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() :
+{
+  Token col;
+}
+{
+  (
+    ( col=<ID> | col=<INTEGER_LITERAL> | col=<ASTERISK> )
+      { return col.image.toString(); }
+    | (col=<QUOTED_IDENTIFIER> | col=<STRING_LITERAL> )
+      { return col.image.substring(1,col.image.toString().length() - 1); }
+  )
+}
+
+List<String> getColumns() : // return parenthesized column list
+{
+  List<String> values = new ArrayList<String>();
+  String literal = null;
+}
+{    
+<LPAREN>
+ { literal = getColumn();
+ if(literal != null) values.add(literal); 
+ }
+    (
+        <COMMA> 
+      { 
+        literal = getColumn(); 
+        if(literal != null) values.add(literal); 
+      }
+    )*
+<RPAREN>
+   { 
+     return values;
+    }
+}
+
+List<String> tableList() :
+{
+  List<String> tableList = new ArrayList<String>();
+  String table = null;
+}
+{
+  table = identifier() { tableList.add(table); }
+  ( <COMMA> table = identifier()
+    { tableList.add(table); } 
+  )*
+  
+  { return tableList; }
+}
+
+List<String> columnList() :
+{
+  List<String> columnList = new ArrayList<String>();  
+  String column = null;
+}
+{ 
+    column = getColumn() 
+    { 
+      if(column != null) {
+        columnList.add(column);
+      } else {
+        return columnList;
+      }
+    }
+  ( <COMMA> column = getColumn()  
+    { columnList.add(column); }
+  )*
+  
+  { return columnList; }
+}
+
+int number() :
+{
+  Token t = null;
+  Token minusSignedInt = null;
+}
+{
+  ( minusSignedInt=<ID> |  t=<INTEGER_LITERAL> )
+  {
+    if(minusSignedInt != null) {
+      return Integer.parseInt(minusSignedInt.image.toString()); 
+    } else {
+      return Integer.parseInt(t.image.toString());
+    }
+    }
+}
+
+String identifier() :
+{
+  Token t = null;
+}
+{
+  (
+     t=<ID>
+     { return t.image.toString(); }
+   | ( t=<QUOTED_IDENTIFIER> | t=<STRING_LITERAL> )
+     { return t.image.substring(1,t.image.toString().length() - 1); }
+  )
+}
+
+String appendIndicator(String columnName) :
+{
+  String column = columnName;
+}
+{
+  {
+     return (!column.endsWith(":") && column.indexOf(":") == -1) 
+     ? column + ":" : column;
+  }
+}
\ No newline at end of file

Added: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLSecurityManager.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLSecurityManager.java?rev=612016&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLSecurityManager.java (added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/hql/HQLSecurityManager.java Mon Jan 14 21:14:34 2008
@@ -0,0 +1,75 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hadoop.hbase.hql;
+
+import java.io.IOException;
+import java.security.Permission;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.Shell;
+
+/**
+ * This is intended as a replacement for the default system manager. The goal is
+ * to intercept System.exit calls and make it throw an exception instead so that
+ * a System.exit in a jar command program does not fully terminate Shell.
+ * 
+ * @see ExitException
+ */
+public class HQLSecurityManager extends SecurityManager {
+
+  /**
+   * Override SecurityManager#checkExit. This throws an ExitException(status)
+   * exception.
+   * 
+   * @param status the exit status
+   */
+  @SuppressWarnings("static-access")
+  public void checkExit(int status) {
+    if (status != Shell.EXIT_FLAG) {
+      // throw new ExitException(status);
+
+      // I didn't figure out How can catch the ExitException in shell main.
+      // So, I just Re-launching the shell.
+      Shell shell = new Shell();
+
+      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(argList.toArray(new String[] {}));
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  /**
+   * Override SecurityManager#checkPermission. This does nothing.
+   * 
+   * @param perm the requested permission.
+   */
+  public void checkPermission(Permission perm) {
+  }
+}