HADOOP-2589 Change an classes/package name from shell to hql
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@612016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a8ebbcefb
commit
ff4aac71c3
|
@ -179,6 +179,8 @@ Trunk (unreleased changes)
|
|||
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
|
||||
|
|
10
build.xml
10
build.xml
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -25,16 +25,13 @@ import java.io.Writer;
|
|||
|
||||
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 @@ public class Shell {
|
|||
|
||||
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 @@ public class Shell {
|
|||
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)
|
||||
|
|
|
@ -5,11 +5,11 @@ import javax.servlet.http.*;
|
|||
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 @@ public final class hql_jsp extends org.apache.jasper.runtime.HttpJspBase
|
|||
|
||||
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) {
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ import org.apache.hadoop.hbase.HServerInfo;
|
|||
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
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
/**
|
||||
* Parser uses command factories to create command.
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.Writer;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
public class ExitException extends SecurityException {
|
||||
private static final long serialVersionUID = -8085525076856622991L;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ options {
|
|||
IGNORE_CASE = true;
|
||||
}
|
||||
|
||||
PARSER_BEGIN(Parser)
|
||||
package org.apache.hadoop.hbase.shell.generated;
|
||||
PARSER_BEGIN(HQLParser)
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
/**
|
||||
* Copyright 2007 The Apache Software Foundation
|
||||
|
@ -36,18 +36,17 @@ import java.io.Writer;
|
|||
import java.net.URLEncoder;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.hadoop.hbase.shell.*;
|
||||
import org.apache.hadoop.hbase.hql.*;
|
||||
|
||||
/**
|
||||
* Parsing command line.
|
||||
*/
|
||||
public class Parser {
|
||||
public class HQLParser {
|
||||
private String QueryString;
|
||||
private TableFormatter formatter;
|
||||
private Writer out;
|
||||
private String secondR;
|
||||
|
||||
public Parser(final String query, final Writer o, final TableFormatter f) {
|
||||
public HQLParser(final String query, final Writer o, final TableFormatter f) {
|
||||
this((Reader)(new StringReader(query)));
|
||||
this.QueryString = query;
|
||||
this.formatter = f;
|
||||
|
@ -59,7 +58,7 @@ public class Parser {
|
|||
}
|
||||
}
|
||||
|
||||
PARSER_END(Parser)
|
||||
PARSER_END(HQLParser)
|
||||
|
||||
SKIP :
|
||||
{
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.Permission;
|
||||
|
@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.Shell;
|
|||
*
|
||||
* @see ExitException
|
||||
*/
|
||||
public class ShellSecurityManager extends SecurityManager {
|
||||
public class HQLSecurityManager extends SecurityManager {
|
||||
|
||||
/**
|
||||
* Override SecurityManager#checkExit. This throws an ExitException(status)
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
@ -41,7 +41,7 @@ import org.apache.hadoop.hbase.Shell;
|
|||
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
||||
import org.apache.hadoop.hbase.filter.StopRowFilter;
|
||||
import org.apache.hadoop.hbase.filter.WhileMatchRowFilter;
|
||||
import org.apache.hadoop.hbase.shell.generated.Parser;
|
||||
import org.apache.hadoop.hbase.hql.generated.HQLParser;
|
||||
import org.apache.hadoop.hbase.util.Writables;
|
||||
import org.apache.hadoop.io.Text;
|
||||
|
||||
|
@ -375,7 +375,7 @@ public class SelectCommand extends BasicCommand {
|
|||
HBaseConfiguration c = new HBaseConfiguration();
|
||||
// For debugging
|
||||
TableFormatterFactory tff = new TableFormatterFactory(out, c);
|
||||
Parser parser = new Parser("select * from 'x' where row='x';", out, tff.get());
|
||||
HQLParser parser = new HQLParser("select * from 'x' where row='x';", out, tff.get());
|
||||
Command cmd = parser.terminatedCommand();
|
||||
|
||||
ReturnMsg rm = cmd.execute(c);
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -17,12 +17,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.hadoop.hbase.shell.formatter.AsciiTableFormatter;
|
||||
import org.apache.hadoop.hbase.hql.formatter.AsciiTableFormatter;
|
||||
|
||||
/**
|
||||
* Interface implemented by table formatters outputting select results.
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -25,7 +25,7 @@ import java.lang.reflect.Constructor;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.shell.formatter.AsciiTableFormatter;
|
||||
import org.apache.hadoop.hbase.hql.formatter.AsciiTableFormatter;
|
||||
|
||||
/**
|
||||
* Table formatter. Specify formatter by setting "hbaseshell.formatter" property
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -15,12 +15,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell.formatter;
|
||||
package org.apache.hadoop.hbase.hql.formatter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.hadoop.hbase.shell.TableFormatter;
|
||||
import org.apache.hadoop.hbase.hql.TableFormatter;
|
||||
|
||||
|
||||
/**
|
|
@ -15,14 +15,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell.formatter;
|
||||
package org.apache.hadoop.hbase.hql.formatter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.hadoop.hbase.shell.TableFormatter;
|
||||
import org.apache.hadoop.hbase.hql.TableFormatter;
|
||||
import org.znerd.xmlenc.LineBreak;
|
||||
import org.znerd.xmlenc.XMLOutputter;
|
||||
import org.znerd.xmlenc.XMLEncoder;
|
|
@ -1,5 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. Parser.java */
|
||||
package org.apache.hadoop.hbase.shell.generated;
|
||||
/* Generated By:JavaCC: Do not edit this line. HQLParser.java */
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
/**
|
||||
* Copyright 2007 The Apache Software Foundation
|
||||
|
@ -31,18 +31,17 @@ import java.io.Writer;
|
|||
import java.net.URLEncoder;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.hadoop.hbase.shell.*;
|
||||
import org.apache.hadoop.hbase.hql.*;
|
||||
|
||||
/**
|
||||
* Parsing command line.
|
||||
*/
|
||||
public class Parser implements ParserConstants {
|
||||
public class HQLParser implements HQLParserConstants {
|
||||
private String QueryString;
|
||||
private TableFormatter formatter;
|
||||
private Writer out;
|
||||
private String secondR;
|
||||
|
||||
public Parser(final String query, final Writer o, final TableFormatter f) {
|
||||
public HQLParser(final String query, final Writer o, final TableFormatter f) {
|
||||
this((Reader)(new StringReader(query)));
|
||||
this.QueryString = query;
|
||||
this.formatter = f;
|
||||
|
@ -1081,6 +1080,11 @@ public class Parser implements ParserConstants {
|
|||
finally { jj_save(0, xla); }
|
||||
}
|
||||
|
||||
final private boolean jj_3R_11() {
|
||||
if (jj_scan_token(ID)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
final private boolean jj_3R_10() {
|
||||
Token xsp;
|
||||
xsp = jj_scanpos;
|
||||
|
@ -1107,12 +1111,7 @@ public class Parser implements ParserConstants {
|
|||
return false;
|
||||
}
|
||||
|
||||
final private boolean jj_3R_11() {
|
||||
if (jj_scan_token(ID)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ParserTokenManager token_source;
|
||||
public HQLParserTokenManager token_source;
|
||||
SimpleCharStream jj_input_stream;
|
||||
public Token token, jj_nt;
|
||||
private int jj_ntk;
|
||||
|
@ -1143,12 +1142,12 @@ public class Parser implements ParserConstants {
|
|||
private boolean jj_rescan = false;
|
||||
private int jj_gc = 0;
|
||||
|
||||
public Parser(java.io.InputStream stream) {
|
||||
public HQLParser(java.io.InputStream stream) {
|
||||
this(stream, null);
|
||||
}
|
||||
public Parser(java.io.InputStream stream, String encoding) {
|
||||
public HQLParser(java.io.InputStream stream, String encoding) {
|
||||
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
|
||||
token_source = new ParserTokenManager(jj_input_stream);
|
||||
token_source = new HQLParserTokenManager(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
|
@ -1169,9 +1168,9 @@ public class Parser implements ParserConstants {
|
|||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
public Parser(java.io.Reader stream) {
|
||||
public HQLParser(java.io.Reader stream) {
|
||||
jj_input_stream = new SimpleCharStream(stream, 1, 1);
|
||||
token_source = new ParserTokenManager(jj_input_stream);
|
||||
token_source = new HQLParserTokenManager(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
|
@ -1189,7 +1188,7 @@ public class Parser implements ParserConstants {
|
|||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
public Parser(ParserTokenManager tm) {
|
||||
public HQLParser(HQLParserTokenManager tm) {
|
||||
token_source = tm;
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
|
@ -1198,7 +1197,7 @@ public class Parser implements ParserConstants {
|
|||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
public void ReInit(ParserTokenManager tm) {
|
||||
public void ReInit(HQLParserTokenManager tm) {
|
||||
token_source = tm;
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
|
@ -1,7 +1,7 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. ParserConstants.java */
|
||||
package org.apache.hadoop.hbase.shell.generated;
|
||||
/* Generated By:JavaCC: Do not edit this line. HQLParserConstants.java */
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
public interface ParserConstants {
|
||||
public interface HQLParserConstants {
|
||||
|
||||
int EOF = 0;
|
||||
int HELP = 5;
|
|
@ -1,5 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. ParserTokenManager.java */
|
||||
package org.apache.hadoop.hbase.shell.generated;
|
||||
/* Generated By:JavaCC: Do not edit this line. HQLParserTokenManager.java */
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
/**
|
||||
* Copyright 2007 The Apache Software Foundation
|
||||
*
|
||||
|
@ -29,9 +29,9 @@ import java.io.Reader;
|
|||
import java.io.Writer;
|
||||
import java.net.URLEncoder;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import org.apache.hadoop.hbase.shell.*;
|
||||
import org.apache.hadoop.hbase.hql.*;
|
||||
|
||||
public class ParserTokenManager implements ParserConstants
|
||||
public class HQLParserTokenManager implements HQLParserConstants
|
||||
{
|
||||
public java.io.PrintStream debugStream = System.out;
|
||||
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
|
||||
|
@ -1480,12 +1480,12 @@ protected SimpleCharStream input_stream;
|
|||
private final int[] jjrounds = new int[32];
|
||||
private final int[] jjstateSet = new int[64];
|
||||
protected char curChar;
|
||||
public ParserTokenManager(SimpleCharStream stream){
|
||||
public HQLParserTokenManager(SimpleCharStream stream){
|
||||
if (SimpleCharStream.staticFlag)
|
||||
throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
|
||||
input_stream = stream;
|
||||
}
|
||||
public ParserTokenManager(SimpleCharStream stream, int lexState){
|
||||
public HQLParserTokenManager(SimpleCharStream stream, int lexState){
|
||||
this(stream);
|
||||
SwitchTo(lexState);
|
||||
}
|
|
@ -1,24 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
|
||||
/**
|
||||
* 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.shell.generated;
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
/**
|
||||
* This exception is thrown when parse errors are encountered.
|
|
@ -1,24 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
|
||||
/**
|
||||
* 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.shell.generated;
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
/**
|
||||
* An implementation of interface CharStream, where the stream is assumed to
|
|
@ -1,24 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
|
||||
/**
|
||||
* 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.shell.generated;
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
/**
|
||||
* Describes the input token stream.
|
|
@ -1,24 +1,5 @@
|
|||
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
|
||||
/**
|
||||
* 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.shell.generated;
|
||||
package org.apache.hadoop.hbase.hql.generated;
|
||||
|
||||
public class TokenMgrError extends Error
|
||||
{
|
|
@ -17,7 +17,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.shell;
|
||||
package org.apache.hadoop.hbase.hql;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -32,21 +32,21 @@ import org.apache.hadoop.hbase.HBaseAdmin;
|
|||
import org.apache.hadoop.hbase.HBaseClusterTestCase;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.shell.generated.ParseException;
|
||||
import org.apache.hadoop.hbase.shell.generated.Parser;
|
||||
import org.apache.hadoop.hbase.hql.generated.ParseException;
|
||||
import org.apache.hadoop.hbase.hql.generated.HQLParser;
|
||||
import org.apache.hadoop.io.Text;
|
||||
|
||||
/**
|
||||
* Tests for Hbase shell
|
||||
* Tests for HQL
|
||||
*/
|
||||
public class TestHBaseShell extends HBaseClusterTestCase {
|
||||
public class TestHQL extends HBaseClusterTestCase {
|
||||
|
||||
protected final Log LOG = LogFactory.getLog(this.getClass().getName());
|
||||
private ByteArrayOutputStream baos;
|
||||
private HBaseAdmin admin;
|
||||
|
||||
/** constructor */
|
||||
public TestHBaseShell() {
|
||||
public TestHQL() {
|
||||
super(1 /*One region server only*/);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class TestHBaseShell extends HBaseClusterTestCase {
|
|||
LOG.info("Running command: " + cmdStr);
|
||||
Writer out = new OutputStreamWriter(System.out, "UTF-8");
|
||||
TableFormatterFactory tff = new TableFormatterFactory(out, this.conf);
|
||||
Parser parser = new Parser(cmdStr, out, tff.get());
|
||||
HQLParser parser = new HQLParser(cmdStr, out, tff.get());
|
||||
Command cmd = parser.terminatedCommand();
|
||||
ReturnMsg rm = cmd.execute(this.conf);
|
||||
dumpStdout();
|
|
@ -1,11 +1,11 @@
|
|||
<%@ page contentType="text/html;charset=UTF-8"
|
||||
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.Parser"
|
||||
import="org.apache.hadoop.hbase.hql.Command"
|
||||
import="org.apache.hadoop.hbase.hql.formatter.HtmlTableFormatter"
|
||||
%><?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
@ -41,7 +41,7 @@
|
|||
%>
|
||||
<hr/>
|
||||
<%
|
||||
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) {
|
||||
%>
|
||||
|
|
|
@ -10,10 +10,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" %><%
|
||||
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
|
||||
HBaseConfiguration conf = new HBaseConfiguration();
|
||||
|
|
Loading…
Reference in New Issue