Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConfigurationGenerator.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConfigurationGenerator.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConfigurationGenerator.java (revision 0) @@ -0,0 +1,86 @@ +/** + * 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; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.shell.query.ConfigurationFactory; +import org.apache.hadoop.hbase.shell.query.InsertOneTableToAnother; +import org.apache.hadoop.hbase.shell.query.Projection; +import org.apache.hadoop.hbase.shell.query.Selection; +import org.apache.hadoop.mapred.JobConf; + +/** + * This is the MapReduce Job Configuration Generator. + */ +public class ConfigurationGenerator { + + private Configuration conf; + private String input; + private String output; + Map statements = new HashMap(); + + /** Constructor */ + public ConfigurationGenerator(Configuration conf, String statement, String output) { + this.conf = conf; + this.output = output; + String chainedIndex = statement; + while (chainedIndex != null) { + for (Map.Entry entry : VariablesPool + .get(chainedIndex).entrySet()) { + if (entry.getKey() == null) { + this.input = entry.getValue().getArguments(); + } else { + statements + .put(entry.getValue().getOperation(), entry.getValue().getArguments()); + } + chainedIndex = entry.getKey(); + } + } + } + + public JobConf getJobConf() { + return getOperationObject().getConf(conf, input, output, statements); + } + + /** + * Returns the job configuration object for statements type + * @return ConfigurationFactory + */ + private ConfigurationFactory getOperationObject() { + if (statements.containsKey(OperationConstants.RELATIONAL_ALGEBRA_SELECTION)) { + return new Selection(); + } else if (statements.containsKey(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION)) { + return new Projection(); + } else { + return new InsertOneTableToAnother() ; + } + } + + public void setOutput(String output) { + this.output = output; + } + + public Map getStatements() { + return statements; + } +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/BooleanExpression.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/BooleanExpression.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/BooleanExpression.java (revision 0) @@ -0,0 +1,150 @@ +/** + * 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.expression; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.io.MapWritable; +import org.apache.hadoop.io.Writable; + +/** + * Boolean expression: truth values combined using AND or OR. + */ +public class BooleanExpression { + + private String expression; + private Map> unionMap = new HashMap>(); + private Map> intersectionMap = new HashMap>(); + private String UNION = " OR "; + private String INTERSECTION = " AND "; + private String LEFT_PARENTHESIS = "("; + private String RIGHT_PARENTHESIS = ")"; + + public void setExpression(String string) { + this.expression = string; + + String[] or = expression.split(UNION); + String[] and = null; + for (int i = 0; i < or.length; i++) { + if (or[i].split(INTERSECTION).length == 1) { + List valueList = new ArrayList(); + String[] parse = or[i].split(" "); + if (unionMap.containsKey(parse[0].trim())) { + valueList = unionMap.get(parse[0].trim()); + } + valueList.add(parse[1] + " " + parse[2]); + + unionMap.put(parse[0].trim(), valueList); + } else { + and = new String[or[i].split(INTERSECTION).length]; + and = or[i].split(INTERSECTION); + } + } + + if (and != null) { + for (int ii = 0; ii < and.length; ii++) { + List valueList = new ArrayList(); + String[] parse = and[ii].split(" "); + if (intersectionMap.containsKey(parse[0].trim())) { + valueList = intersectionMap.get(parse[0].trim()); + } + valueList.add(parse[1] + " " + parse[2]); + + intersectionMap.put(parse[0].trim(), valueList); + } + } + } + + public boolean checkConstraints(MapWritable data) { + if (data == null) { + return false; // return false if data is null. + } + + boolean result = false; + Map record = new HashMap(); + + for (Map.Entry e : data.entrySet()) { + String cKey = e.getKey().toString(); + cKey = cKey.substring(0, cKey.length() - 1); + String val = new String(((ImmutableBytesWritable) e.getValue()).get()); + + if (intersectionMap.containsKey(cKey) || unionMap.containsKey(cKey)) { + record.put(cKey, val); + } + } + + if (intersectionMap.size() == record.size()) { + result = Comparater.booleanCompare(intersectionMap, record, true); + } else if (unionMap.size() == record.size()) { + result = Comparater.booleanCompare(unionMap, record, false); + } else { + if (Comparater.booleanCompare(intersectionMap, record, true) + && Comparater.booleanCompare(unionMap, record, false)) + result = true; + else + result = false; + } + + return result; + } + + /** + * return to boolean expression string. + */ + public String toString() { + String and = getString(intersectionMap, INTERSECTION); + String or = getString(unionMap, UNION); + + if (or.equals("")) { + return and; + } else if (and.equals("")) { + return or; + } else { + return LEFT_PARENTHESIS + LEFT_PARENTHESIS + or + RIGHT_PARENTHESIS + + UNION + LEFT_PARENTHESIS + and + RIGHT_PARENTHESIS + RIGHT_PARENTHESIS; + } + } + + private String getString(Map> setMap, String symbol) { + String result = ""; + int i = 1; + for (Map.Entry> entry : setMap.entrySet()) { + if (entry.getValue().size() > 1) result += LEFT_PARENTHESIS; + + for (int ii = 0; ii < entry.getValue().size(); ii++) { + result += entry.getKey() + " " + entry.getValue().get(ii); + if (entry.getValue().size() != ii + 1) { + result += symbol; + } + } + + if (entry.getValue().size() > 1) result += RIGHT_PARENTHESIS; + if (intersectionMap.keySet().size() != i) result += symbol; + + i++; + } + + return result; + } +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/Comparater.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/Comparater.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/expression/Comparater.java (revision 0) @@ -0,0 +1,97 @@ +/** + * 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.expression; + +import java.util.List; +import java.util.Map; + +/** + * Comparison class + */ +public class Comparater { + + public static boolean booleanCompare(Map> expression, + Map record, boolean isIntersection) { + + boolean negative = true; + boolean positive = false; + + for (Map.Entry> e : expression.entrySet()) { + String key = e.getKey(); + List valueList = e.getValue(); + String recordValueList = record.get(key); + + for (int i = 0; i < valueList.size(); i++) { + String[] term = valueList.get(i).split(" "); + String comparator = term[0]; + String comparand = term[1]; + + switch (comparator.charAt(0)) { + case '>': + if (comparator.length() == 2 && "=".charAt(0) == comparator.charAt(1)) { + if (Integer.parseInt(comparand) > Integer.parseInt(recordValueList)) { + negative = false; + } else { + positive = true; + } + } else { + if (Integer.parseInt(comparand) > Integer.parseInt(recordValueList) + || comparand.equals(recordValueList)) { + negative = false; + } else { + positive = true; + } + } + break; + case '<': + if (comparator.length() == 2 && "=".charAt(0) == comparator.charAt(1)) { + if (Integer.parseInt(comparand) < Integer.parseInt(recordValueList)) + negative = false; + else + positive = true; + } else { + if (Integer.parseInt(comparand) < Integer.parseInt(recordValueList) + || comparand.equals(recordValueList)) + negative = false; + else + positive = true; + } + break; + case '=': + if (!comparand.equals(recordValueList)) + negative = false; + else + positive = true; + break; + } + } + } + + boolean result = false; + if (isIntersection) { + result = negative; + } else { + result = positive; + } + + return result; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java (revision 582453) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java (working copy) @@ -72,7 +72,9 @@ case SELECT: case ENABLE: case DISABLE: - case 62: + case SAVE: + case ID: + case 67: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case HELP: case ALTER: @@ -90,6 +92,8 @@ case SELECT: case ENABLE: case DISABLE: + case SAVE: + case ID: statement = cmdStatement(); break; default: @@ -96,7 +100,7 @@ jj_la1[0] = jj_gen; ; } - jj_consume_token(62); + jj_consume_token(67); break; case 0: jj_consume_token(0); @@ -159,6 +163,12 @@ case JAR: cmd = jarCommand(); break; + case ID: + cmd = substituteCommand(); + break; + case SAVE: + cmd = saveCommand(); + break; default: jj_la1[2] = jj_gen; jj_consume_token(-1); @@ -251,6 +261,8 @@ case INSERT: case DELETE: case SELECT: + case SAVE: + case SORT: case ID: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SHOW: @@ -289,6 +301,12 @@ case JAR: t = jj_consume_token(JAR); break; + case SORT: + t = jj_consume_token(SORT); + break; + case SAVE: + t = jj_consume_token(SAVE); + break; case ID: t = jj_consume_token(ID); break; @@ -316,7 +334,7 @@ case ID: case QUOTED_IDENTIFIER: case STRING_LITERAL: - argument = Identifier(); + argument = identifier(); break; default: jj_la1[8] = jj_gen; @@ -342,7 +360,7 @@ jj_consume_token(-1); throw new ParseException(); } - argument = Identifier(); + argument = identifier(); desc.setArgument(argument); {if (true) return desc;} throw new Error("Missing return statement in function"); @@ -461,10 +479,10 @@ String column = null; jj_consume_token(CREATE); jj_consume_token(TABLE); - table = Identifier(); + table = identifier(); createCommand.setTable(table); jj_consume_token(LPAREN); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); createCommand.addColumnSpec(column, columnSpec); label_4: @@ -478,7 +496,7 @@ break label_4; } jj_consume_token(COMMA); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); createCommand.addColumnSpec(column, columnSpec); } @@ -494,11 +512,11 @@ Map columnSpec = null; jj_consume_token(ALTER); jj_consume_token(TABLE); - table = Identifier(); + table = identifier(); alterCommand.setTable(table); if (jj_2_1(2)) { jj_consume_token(ADD); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); alterCommand.setOperationType(AlterCommand.OperationType.ADD); alterCommand.addColumnSpec(column, columnSpec); @@ -508,7 +526,7 @@ jj_consume_token(ADD); jj_consume_token(LPAREN); alterCommand.setOperationType(AlterCommand.OperationType.ADD); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); alterCommand.addColumnSpec(column, columnSpec); label_5: @@ -522,7 +540,7 @@ break label_5; } jj_consume_token(COMMA); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); alterCommand.addColumnSpec(column, columnSpec); } @@ -530,7 +548,7 @@ break; case DROP: jj_consume_token(DROP); - column = Identifier(); + column = identifier(); alterCommand.setOperationType(AlterCommand.OperationType.DROP); alterCommand.setColumn(column); break; @@ -536,7 +554,7 @@ break; case CHANGE: jj_consume_token(CHANGE); - column = Identifier(); + column = identifier(); columnSpec = ColumnSpec(); alterCommand.setOperationType(AlterCommand.OperationType.CHANGE); alterCommand.addColumnSpec(column, columnSpec); @@ -556,7 +574,7 @@ List tableList = null; jj_consume_token(DROP); jj_consume_token(TABLE); - tableList = TableList(); + tableList = tableList(); drop.setTableList(tableList); {if (true) return drop;} throw new Error("Missing return statement in function"); @@ -570,7 +588,7 @@ Token t = null; jj_consume_token(INSERT); jj_consume_token(INTO); - table = Identifier(); + table = identifier(); in.setTable(table); columnfamilies = getColumns(); in.setColumnfamilies(columnfamilies); @@ -603,10 +621,10 @@ Token t = null; String table = null; jj_consume_token(DELETE); - columnList = ColumnList(); + columnList = columnList(); deleteCommand.setColumnList(columnList); jj_consume_token(FROM); - table = Identifier(); + table = identifier(); deleteCommand.setTable(table); jj_consume_token(WHERE); jj_consume_token(ROW); @@ -637,9 +655,9 @@ String tableName = null; int limit; jj_consume_token(SELECT); - columns = ColumnList(); + columns = columnList(); jj_consume_token(FROM); - tableName = Identifier(); + tableName = identifier(); select.setColumns(columns); select.setTable(tableName); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -712,7 +730,7 @@ EnableCommand enableCommand = new EnableCommand(this.out); String table = null; jj_consume_token(ENABLE); - table = Identifier(); + table = identifier(); enableCommand.setTable(table); {if (true) return enableCommand;} throw new Error("Missing return statement in function"); @@ -722,7 +740,7 @@ DisableCommand disableCommand = new DisableCommand(this.out); String table = null; jj_consume_token(DISABLE); - table = Identifier(); + table = identifier(); disableCommand.setTable(table); {if (true) return disableCommand;} throw new Error("Missing return statement in function"); @@ -735,6 +753,77 @@ throw new Error("Missing return statement in function"); } + final public SubstituteCommand substituteCommand() throws ParseException { + Token key = null; + Token chainKey = null; + Token operation = null; + String tableName; + String booleanTerm; + List columnList = new ArrayList(); + SubstituteCommand substitute = new SubstituteCommand(this.out); + key = jj_consume_token(ID); + jj_consume_token(EQUALS); + substitute.setKey(key.image.toString()); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ID: + chainKey = jj_consume_token(ID); + jj_consume_token(DOT); + substitute.setChainKey(chainKey.image.toString()); + operation = jj_consume_token(ID); + substitute.setOperation(operation.image.toString()); + jj_consume_token(LPAREN); + if(operation.image.toLowerCase().equals(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION)) { + columnList = columnList(); + substitute.setColumnList(columnList); + } else if(operation.image.toLowerCase().equals(OperationConstants.RELATIONAL_ALGEBRA_SELECTION)) { + booleanTerm = booleanTerm(); + substitute.setBooleanTerm(booleanTerm); + } + jj_consume_token(RPAREN); + break; + case TABLE: + jj_consume_token(TABLE); + jj_consume_token(LPAREN); + tableName = identifier(); + substitute.setInput(tableName); + jj_consume_token(RPAREN); + break; + case SORT: + jj_consume_token(SORT); + chainKey = jj_consume_token(ID); + jj_consume_token(BY); + jj_consume_token(LPAREN); + columnList = columnList(); + jj_consume_token(RPAREN); + substitute.setChainKey(chainKey.image.toString()); + substitute.setColumnList(columnList); + break; + default: + jj_la1[24] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return substitute;} + throw new Error("Missing return statement in function"); + } + + final public SaveCommand saveCommand() throws ParseException { + Token t = null; + String tableName; + SaveCommand save = new SaveCommand(this.out); + jj_consume_token(SAVE); + t = jj_consume_token(ID); + save.setStatement(t.image.toString()); + jj_consume_token(INTO); + jj_consume_token(TABLE); + jj_consume_token(LPAREN); + tableName = identifier(); + save.setOutput(tableName); + jj_consume_token(RPAREN); + {if (true) return save;} + throw new Error("Missing return statement in function"); + } + //////////////////////////////////////////////// // Utility expansion units... final public List getLiteralValues() throws ParseException { @@ -753,7 +842,7 @@ ; break; default: - jj_la1[24] = jj_gen; + jj_la1[25] = jj_gen; break label_6; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -776,7 +865,7 @@ jj_consume_token(QUOTED_IDENTIFIER); break; default: - jj_la1[25] = jj_gen; + jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -783,7 +872,7 @@ values.removeAll(values); break; default: - jj_la1[26] = jj_gen; + jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -803,7 +892,7 @@ s = jj_consume_token(QUOTED_IDENTIFIER); break; default: - jj_la1[27] = jj_gen; + jj_la1[28] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -812,31 +901,6 @@ throw new Error("Missing return statement in function"); } - final public List getColumns() throws ParseException { - List values = new ArrayList(); - String literal = null; - jj_consume_token(LPAREN); - literal = getColumn(); - if(literal != null) values.add(literal); - label_7: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[28] = jj_gen; - break label_7; - } - jj_consume_token(COMMA); - literal = getColumn(); - if(literal != null) values.add(literal); - } - jj_consume_token(RPAREN); - {if (true) return values;} - throw new Error("Missing return statement in function"); - } - final public String getColumn() throws ParseException { Token col; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -880,12 +944,12 @@ throw new Error("Missing return statement in function"); } - final public List TableList() throws ParseException { + final public List tableList() throws ParseException { List tableList = new ArrayList(); String table = null; - table = Identifier(); + table = identifier(); tableList.add(table); - label_8: + label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: @@ -893,10 +957,10 @@ break; default: jj_la1[32] = jj_gen; - break label_8; + break label_7; } jj_consume_token(COMMA); - table = Identifier(); + table = identifier(); tableList.add(table); } {if (true) return tableList;} @@ -903,7 +967,32 @@ throw new Error("Missing return statement in function"); } - final public List ColumnList() throws ParseException { + final public List getColumns() throws ParseException { + List values = new ArrayList(); + String literal = null; + jj_consume_token(LPAREN); + literal = getColumn(); + if(literal != null) values.add(literal); + label_8: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[33] = jj_gen; + break label_8; + } + jj_consume_token(COMMA); + literal = getColumn(); + if(literal != null) values.add(literal); + } + jj_consume_token(RPAREN); + {if (true) return values;} + throw new Error("Missing return statement in function"); + } + + final public List columnList() throws ParseException { List columnList = new ArrayList(); String column = null; column = getColumn(); @@ -919,7 +1008,7 @@ ; break; default: - jj_la1[33] = jj_gen; + jj_la1[34] = jj_gen; break label_9; } jj_consume_token(COMMA); @@ -937,7 +1026,7 @@ throw new Error("Missing return statement in function"); } - final public String Identifier() throws ParseException { + final public String identifier() throws ParseException { Token t = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ID: @@ -954,7 +1043,7 @@ t = jj_consume_token(STRING_LITERAL); break; default: - jj_la1[34] = jj_gen; + jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -961,10 +1050,109 @@ {if (true) return t.image.substring(1,t.image.toString().length() - 1);} break; default: - jj_la1[35] = jj_gen; + jj_la1[36] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + final public String booleanTerm() throws ParseException { + String query = null; + String tmp = null; + query = booleanTerms(); + label_10: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AND: + case OR: + ; + break; + default: + jj_la1[37] = jj_gen; + break label_10; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AND: + jj_consume_token(AND); + query += " AND "; + break; + case OR: + jj_consume_token(OR); + query += " OR "; + break; + default: + jj_la1[38] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + tmp = booleanTerms(); + query += tmp; + } + {if (true) return query;} + throw new Error("Missing return statement in function"); + } + + final public String booleanTerms() throws ParseException { + Token tSearchName, tComparator, tComparand; + String searchName=null,comparator=null,comparand=null; + tSearchName = jj_consume_token(ID); + searchName = tSearchName.image.toString(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LCOMP: + tComparator = jj_consume_token(LCOMP); + comparator = tComparator.image.toString(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQUALS: + jj_consume_token(EQUALS); + comparator += "="; + break; + default: + jj_la1[39] = jj_gen; + ; + } + break; + case RCOMP: + tComparator = jj_consume_token(RCOMP); + comparator = tComparator.image.toString(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQUALS: + jj_consume_token(EQUALS); + comparator += "="; + break; + default: + jj_la1[40] = jj_gen; + ; + } + break; + case EQUALS: + tComparator = jj_consume_token(EQUALS); + comparator = tComparator.image.toString(); + break; + default: + jj_la1[41] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTEGER_LITERAL: + tComparand = jj_consume_token(INTEGER_LITERAL); + comparand = tComparand.image.toString(); + break; + case STRING_LITERAL: + tComparand = jj_consume_token(STRING_LITERAL); + comparand = tComparand.image.substring(1,tComparand.image.length() - 1); + break; + case ID: + tComparand = jj_consume_token(ID); + comparand = tComparand.image.toString(); + break; + default: + jj_la1[42] = jj_gen; jj_consume_token(-1); throw new ParseException(); } + {if (true) return searchName + " " + comparator + " " + comparand;} throw new Error("Missing return statement in function"); } @@ -975,12 +1163,12 @@ finally { jj_save(0, xla); } } - final private boolean jj_3R_12() { + final private boolean jj_3R_13() { Token xsp; xsp = jj_scanpos; - if (jj_scan_token(60)) { + if (jj_scan_token(65)) { jj_scanpos = xsp; - if (jj_scan_token(61)) return true; + if (jj_scan_token(66)) return true; } return false; } @@ -985,7 +1173,7 @@ return false; } - final private boolean jj_3R_11() { + final private boolean jj_3R_12() { if (jj_scan_token(ID)) return true; return false; } @@ -990,12 +1178,18 @@ return false; } - final private boolean jj_3R_10() { + final private boolean jj_3_1() { + if (jj_scan_token(ADD)) return true; + if (jj_3R_11()) return true; + return false; + } + + final private boolean jj_3R_11() { Token xsp; xsp = jj_scanpos; - if (jj_3R_11()) { + if (jj_3R_12()) { jj_scanpos = xsp; - if (jj_3R_12()) return true; + if (jj_3R_13()) return true; } return false; } @@ -1000,12 +1194,6 @@ return false; } - final private boolean jj_3_1() { - if (jj_scan_token(ADD)) return true; - if (jj_3R_10()) return true; - return false; - } - public ParserTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; @@ -1015,18 +1203,23 @@ public boolean lookingAhead = false; private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[36]; + final private int[] jj_la1 = new int[43]; static private int[] jj_la1_0; static private int[] jj_la1_1; + static private int[] jj_la1_2; static { jj_la1_0(); jj_la1_1(); + jj_la1_2(); } private static void jj_la1_0() { - jj_la1_0 = new int[] {0x79ffe0,0x79ffe1,0x79ffe0,0x0,0x0,0x0,0x19fbc0,0x19fbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x1800000,0x1800000,0x20000000,0x40000000,0x80000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_0 = new int[] {0x79ffe0,0x79ffe1,0x79ffe0,0x0,0x0,0x0,0x19fbc0,0x19fbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x1800000,0x1800000,0x20000000,0x40000000,0x80000000,0x40000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0x0,0x40000000,0x0,0x1000000,0x3000000,0x3000000,0x1000000,0x1000000,0x31000000,0x0,0x398e00,0x7000,0x70000,0x398e00,0x4,0x4,0xc00000,0x30000000,0x30000000,0x0,0x0,0x0,0x0,0x0,0x31000004,0x31000000,0x31000004,0x30000000,0x4,0x1000100,0x30000000,0x31000100,0x4,0x4,0x30000000,0x31000000,}; + jj_la1_1 = new int[] {0x24000000,0x24000000,0x24000000,0x20000000,0x60000000,0x60000000,0x2c000000,0x2c000000,0x20000000,0x0,0xe63800,0x1c000,0x1c0000,0xe63800,0x4,0x4,0x3000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x28000000,0x20000004,0x20000000,0x20000004,0x0,0x20000400,0x0,0x20000400,0x4,0x4,0x4,0x0,0x20000000,0x3,0x3,0x40,0x40,0x1c0,0x60000000,}; + } + private static void jj_la1_2() { + jj_la1_2 = new int[] {0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x6,0x6,0x6,0x0,0x6,0x6,0x0,0x0,0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x0,0x4,}; } final private JJCalls[] jj_2_rtns = new JJCalls[1]; private boolean jj_rescan = false; @@ -1041,7 +1234,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1054,7 +1247,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1064,7 +1257,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1074,7 +1267,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1083,7 +1276,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1092,7 +1285,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 36; i++) jj_la1[i] = -1; + for (int i = 0; i < 43; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1203,8 +1396,8 @@ public ParseException generateParseException() { jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[63]; - for (int i = 0; i < 63; i++) { + boolean[] la1tokens = new boolean[68]; + for (int i = 0; i < 68; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { @@ -1211,7 +1404,7 @@ la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 36; i++) { + for (int i = 0; i < 43; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<\"", + "\"<\"", "\"<>\"", "\"*\"", "\"max_versions\"", @@ -121,6 +128,9 @@ "\"num_entries\"", "\"add\"", "\"change\"", + "\"save\"", + "\"sort\"", + "\"by\"", "", "", "", Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/ParserTokenManager.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/ParserTokenManager.java (revision 582453) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/ParserTokenManager.java (working copy) @@ -33,7 +33,7 @@ { public java.io.PrintStream debugStream = System.out; public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopStringLiteralDfa_0(int pos, long active0) +private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { switch (pos) { @@ -39,10 +39,10 @@ { case 0: if ((active0 & 0x800000000L) != 0L) - return 32; - if ((active0 & 0xfffe03ffffffe0L) != 0L) + return 3; + if ((active0 & 0x1ffff803ffffffe0L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; return 1; } return -1; @@ -47,11 +47,11 @@ } return -1; case 1: - if ((active0 & 0x200002000L) != 0L) + if ((active0 & 0x1000000200002000L) != 0L) return 1; - if ((active0 & 0xfffe01ffffdfe0L) != 0L) + if ((active0 & 0xffff801ffffdfe0L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 1; return 1; } @@ -57,11 +57,11 @@ } return -1; case 2: - if ((active0 & 0x40000104004000L) != 0L) + if ((active0 & 0x100000104004000L) != 0L) return 1; - if ((active0 & 0xbffe00fbff9fe0L) != 0L) + if ((active0 & 0xefff800fbff9fe0L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 2; return 1; } @@ -67,13 +67,13 @@ } return -1; case 3: - if ((active0 & 0x100002029720L) != 0L) + if ((active0 & 0xc00400002029720L) != 0L) return 1; - if ((active0 & 0xbfee00f9fd08c0L) != 0L) + if ((active0 & 0x2ffb800f9fd08c0L) != 0L) { if (jjmatchedPos != 3) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 3; } return 1; @@ -80,29 +80,29 @@ } return -1; case 4: - if ((active0 & 0xbfce0078f90a00L) != 0L) + if ((active0 & 0x8000810400c0L) != 0L) + return 1; + if ((active0 & 0x2ff380078f90a00L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 4; return 1; } - if ((active0 & 0x2000810400c0L) != 0L) - return 1; return -1; case 5: - if ((active0 & 0x3f8e0070c00200L) != 0L) + if ((active0 & 0x201000008390800L) != 0L) + return 1; + if ((active0 & 0xfe380070c00200L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 5; return 1; } - if ((active0 & 0x80400008390800L) != 0L) - return 1; return -1; case 6: - if ((active0 & 0x3f8e0070800200L) != 0L) + if ((active0 & 0xfe380070800200L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 6; return 1; } @@ -110,41 +110,41 @@ return 1; return -1; case 7: - if ((active0 & 0x2f8e0070000000L) != 0L) + if ((active0 & 0xbe380070000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 7; return 1; } - if ((active0 & 0x10000000800200L) != 0L) + if ((active0 & 0x40000000800200L) != 0L) return 1; return -1; case 8: - if ((active0 & 0x2f0e0050000000L) != 0L) + if ((active0 & 0xbc380050000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 8; return 1; } - if ((active0 & 0x800020000000L) != 0L) + if ((active0 & 0x2000020000000L) != 0L) return 1; return -1; case 9: - if ((active0 & 0x2f0a0050000000L) != 0L) + if ((active0 & 0xbc280050000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 9; return 1; } - if ((active0 & 0x40000000000L) != 0L) + if ((active0 & 0x100000000000L) != 0L) return 1; return -1; case 10: - if ((active0 & 0x29080000000000L) != 0L) + if ((active0 & 0xa4200000000000L) != 0L) return 1; - if ((active0 & 0x6020050000000L) != 0L) + if ((active0 & 0x18080050000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 10; return 1; } @@ -150,19 +150,19 @@ } return -1; case 11: - if ((active0 & 0x6000010000000L) != 0L) + if ((active0 & 0x80040000000L) != 0L) + return 1; + if ((active0 & 0x18000010000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 11; return 1; } - if ((active0 & 0x20040000000L) != 0L) - return 1; return -1; case 12: - if ((active0 & 0x6000010000000L) != 0L) + if ((active0 & 0x18000010000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 12; return 1; } @@ -168,19 +168,19 @@ } return -1; case 13: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x10000000L) != 0L) + return 1; + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 13; return 1; } - if ((active0 & 0x10000000L) != 0L) - return 1; return -1; case 14: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 14; return 1; } @@ -186,9 +186,9 @@ } return -1; case 15: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 15; return 1; } @@ -194,9 +194,9 @@ } return -1; case 16: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 16; return 1; } @@ -202,9 +202,9 @@ } return -1; case 17: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 17; return 1; } @@ -210,9 +210,9 @@ } return -1; case 18: - if ((active0 & 0x6000000000000L) != 0L) + if ((active0 & 0x18000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 18; return 1; } @@ -218,13 +218,13 @@ } return -1; case 19: - if ((active0 & 0x4000000000000L) != 0L) + if ((active0 & 0x10000000000000L) != 0L) { - jjmatchedKind = 56; + jjmatchedKind = 61; jjmatchedPos = 19; return 1; } - if ((active0 & 0x2000000000000L) != 0L) + if ((active0 & 0x8000000000000L) != 0L) return 1; return -1; default : @@ -231,9 +231,9 @@ return -1; } } -private final int jjStartNfa_0(int pos, long active0) +private final int jjStartNfa_0(int pos, long active0, long active1) { - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); } private final int jjStopAtPos(int pos, int kind) { @@ -258,26 +258,29 @@ case 41: return jjStopAtPos(0, 37); case 42: - return jjStopAtPos(0, 40); + return jjStopAtPos(0, 42); case 44: return jjStopAtPos(0, 34); case 46: - return jjStartNfaWithStates_0(0, 35, 32); + return jjStartNfaWithStates_0(0, 35, 3); case 59: - return jjStopAtPos(0, 62); + return jjStopAtPos(0, 67); case 60: - return jjMoveStringLiteralDfa1_0(0x8000000000L); + jjmatchedKind = 40; + return jjMoveStringLiteralDfa1_0(0x20000000000L); case 61: return jjStopAtPos(0, 38); + case 62: + return jjStopAtPos(0, 39); case 65: case 97: - return jjMoveStringLiteralDfa1_0(0x40000100000040L); + return jjMoveStringLiteralDfa1_0(0x100000100000040L); case 66: case 98: - return jjMoveStringLiteralDfa1_0(0x1200000000000L); + return jjMoveStringLiteralDfa1_0(0x1004800000000000L); case 67: case 99: - return jjMoveStringLiteralDfa1_0(0x82080010000880L); + return jjMoveStringLiteralDfa1_0(0x208200010000880L); case 68: case 100: return jjMoveStringLiteralDfa1_0(0x481600L); @@ -292,7 +295,7 @@ return jjMoveStringLiteralDfa1_0(0x20L); case 73: case 105: - return jjMoveStringLiteralDfa1_0(0x800000030000L); + return jjMoveStringLiteralDfa1_0(0x2000000030000L); case 74: case 106: return jjMoveStringLiteralDfa1_0(0x4000L); @@ -301,10 +304,10 @@ return jjMoveStringLiteralDfa1_0(0x80000000L); case 77: case 109: - return jjMoveStringLiteralDfa1_0(0x60000000000L); + return jjMoveStringLiteralDfa1_0(0x180000000000L); case 78: case 110: - return jjMoveStringLiteralDfa1_0(0x30100040000000L); + return jjMoveStringLiteralDfa1_0(0xc0400040000000L); case 79: case 111: return jjMoveStringLiteralDfa1_0(0x200000000L); @@ -310,10 +313,10 @@ return jjMoveStringLiteralDfa1_0(0x200000000L); case 82: case 114: - return jjMoveStringLiteralDfa1_0(0x4400004000000L); + return jjMoveStringLiteralDfa1_0(0x11000004000000L); case 83: case 115: - return jjMoveStringLiteralDfa1_0(0x900100L); + return jjMoveStringLiteralDfa1_0(0xc00000000900100L); case 84: case 116: return jjMoveStringLiteralDfa1_0(0x20040000L); @@ -319,7 +322,7 @@ return jjMoveStringLiteralDfa1_0(0x20040000L); case 86: case 118: - return jjMoveStringLiteralDfa1_0(0x8000008000000L); + return jjMoveStringLiteralDfa1_0(0x20000008000000L); case 87: case 119: return jjMoveStringLiteralDfa1_0(0x1000000L); @@ -331,7 +334,7 @@ { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0); + jjStopStringLiteralDfa_0(0, active0, 0L); return 1; } switch(curChar) @@ -337,21 +340,21 @@ switch(curChar) { case 62: - if ((active0 & 0x8000000000L) != 0L) - return jjStopAtPos(1, 39); + if ((active0 & 0x20000000000L) != 0L) + return jjStopAtPos(1, 41); break; case 65: case 97: - return jjMoveStringLiteralDfa2_0(active0, 0x60008044000L); + return jjMoveStringLiteralDfa2_0(active0, 0x400180008044000L); case 68: case 100: - return jjMoveStringLiteralDfa2_0(active0, 0x40000000000000L); + return jjMoveStringLiteralDfa2_0(active0, 0x100000000000000L); case 69: case 101: - return jjMoveStringLiteralDfa2_0(active0, 0xc400000180620L); + return jjMoveStringLiteralDfa2_0(active0, 0x31000000180620L); case 72: case 104: - return jjMoveStringLiteralDfa2_0(active0, 0x80000001000100L); + return jjMoveStringLiteralDfa2_0(active0, 0x200000001000100L); case 73: case 105: return jjMoveStringLiteralDfa2_0(active0, 0xa0400000L); @@ -357,13 +360,13 @@ return jjMoveStringLiteralDfa2_0(active0, 0xa0400000L); case 76: case 108: - return jjMoveStringLiteralDfa2_0(active0, 0x12000000000c0L); + return jjMoveStringLiteralDfa2_0(active0, 0x48000000000c0L); case 78: case 110: - return jjMoveStringLiteralDfa2_0(active0, 0x800100230000L); + return jjMoveStringLiteralDfa2_0(active0, 0x2000100230000L); case 79: case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x2180014000000L); + return jjMoveStringLiteralDfa2_0(active0, 0x808600014000000L); case 82: case 114: if ((active0 & 0x200000000L) != 0L) @@ -379,14 +382,19 @@ return jjMoveStringLiteralDfa2_0(active0, 0x800000L); case 85: case 117: - return jjMoveStringLiteralDfa2_0(active0, 0x30000040000000L); + return jjMoveStringLiteralDfa2_0(active0, 0xc0000040000000L); case 88: case 120: return jjMoveStringLiteralDfa2_0(active0, 0x8000L); + case 89: + case 121: + if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(1, 60, 1); + break; default : break; } - return jjStartNfa_0(0, active0); + return jjStartNfa_0(0, active0, 0L); } private final int jjMoveStringLiteralDfa2_0(long old0, long active0) { @@ -391,10 +399,10 @@ private final int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(0, old0); + return jjStartNfa_0(0, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0); + jjStopStringLiteralDfa_0(1, active0, 0L); return 2; } switch(curChar) @@ -400,10 +408,10 @@ switch(curChar) { case 95: - return jjMoveStringLiteralDfa3_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L); case 65: case 97: - return jjMoveStringLiteralDfa3_0(active0, 0x80000000a00000L); + return jjMoveStringLiteralDfa3_0(active0, 0x200000000a00000L); case 66: case 98: return jjMoveStringLiteralDfa3_0(active0, 0x40000L); @@ -409,7 +417,7 @@ return jjMoveStringLiteralDfa3_0(active0, 0x40000L); case 67: case 99: - return jjMoveStringLiteralDfa3_0(active0, 0x8400000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x21000000000000L); case 68: case 100: if ((active0 & 0x100000000L) != 0L) @@ -414,8 +422,8 @@ case 100: if ((active0 & 0x100000000L) != 0L) return jjStartNfaWithStates_0(2, 32, 1); - else if ((active0 & 0x40000000000000L) != 0L) - return jjStartNfaWithStates_0(2, 54, 1); + else if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(2, 56, 1); break; case 69: case 101: @@ -428,13 +436,13 @@ return jjMoveStringLiteralDfa3_0(active0, 0x18180020L); case 77: case 109: - return jjMoveStringLiteralDfa3_0(active0, 0x300800e0000000L); + return jjMoveStringLiteralDfa3_0(active0, 0xc02000e0000000L); case 78: case 110: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L); case 79: case 111: - return jjMoveStringLiteralDfa3_0(active0, 0x1200002001100L); + return jjMoveStringLiteralDfa3_0(active0, 0x4800002001100L); case 82: case 114: if ((active0 & 0x4000L) != 0L) @@ -439,7 +447,7 @@ case 114: if ((active0 & 0x4000L) != 0L) return jjStartNfaWithStates_0(2, 14, 1); - break; + return jjMoveStringLiteralDfa3_0(active0, 0x800000000000000L); case 83: case 115: return jjMoveStringLiteralDfa3_0(active0, 0x410600L); @@ -445,10 +453,13 @@ return jjMoveStringLiteralDfa3_0(active0, 0x410600L); case 84: case 116: - return jjMoveStringLiteralDfa3_0(active0, 0x4000000020040L); + return jjMoveStringLiteralDfa3_0(active0, 0x10000000020040L); case 85: case 117: - return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000L); + case 86: + case 118: + return jjMoveStringLiteralDfa3_0(active0, 0x400000000000000L); case 87: case 119: if ((active0 & 0x4000000L) != 0L) @@ -456,11 +467,11 @@ break; case 88: case 120: - return jjMoveStringLiteralDfa3_0(active0, 0x60000000000L); + return jjMoveStringLiteralDfa3_0(active0, 0x180000000000L); default : break; } - return jjStartNfa_0(1, active0); + return jjStartNfa_0(1, active0, 0L); } private final int jjMoveStringLiteralDfa3_0(long old0, long active0) { @@ -465,10 +476,10 @@ private final int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(1, old0); + return jjStartNfa_0(1, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(2, active0); + jjStopStringLiteralDfa_0(2, active0, 0L); return 3; } switch(curChar) @@ -474,7 +485,7 @@ switch(curChar) { case 95: - return jjMoveStringLiteralDfa4_0(active0, 0x30060040000000L); + return jjMoveStringLiteralDfa4_0(active0, 0xc0180040000000L); case 65: case 97: return jjMoveStringLiteralDfa4_0(active0, 0x400880L); @@ -488,11 +499,13 @@ jjmatchedKind = 10; jjmatchedPos = 3; } - return jjMoveStringLiteralDfa4_0(active0, 0x200000000200L); + return jjMoveStringLiteralDfa4_0(active0, 0x800000000200L); case 69: case 101: - if ((active0 & 0x100000000000L) != 0L) - return jjStartNfaWithStates_0(3, 44, 1); + if ((active0 & 0x400000000000L) != 0L) + return jjStartNfaWithStates_0(3, 46, 1); + else if ((active0 & 0x400000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 58, 1); return jjMoveStringLiteralDfa4_0(active0, 0x20190040L); case 73: case 105: @@ -504,10 +517,10 @@ case 109: if ((active0 & 0x2000000L) != 0L) return jjStartNfaWithStates_0(3, 25, 1); - return jjMoveStringLiteralDfa4_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L); case 78: case 110: - return jjMoveStringLiteralDfa4_0(active0, 0x82000000000000L); + return jjMoveStringLiteralDfa4_0(active0, 0x208000000000000L); case 79: case 111: if ((active0 & 0x20000L) != 0L) @@ -512,7 +525,7 @@ case 111: if ((active0 & 0x20000L) != 0L) return jjStartNfaWithStates_0(3, 17, 1); - return jjMoveStringLiteralDfa4_0(active0, 0x5400000000000L); + return jjMoveStringLiteralDfa4_0(active0, 0x15000000000000L); case 80: case 112: if ((active0 & 0x20L) != 0L) @@ -519,7 +532,7 @@ return jjStartNfaWithStates_0(3, 5, 1); else if ((active0 & 0x1000L) != 0L) return jjStartNfaWithStates_0(3, 12, 1); - return jjMoveStringLiteralDfa4_0(active0, 0x80000000000L); + return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L); case 82: case 114: return jjMoveStringLiteralDfa4_0(active0, 0x1800000L); @@ -527,7 +540,9 @@ case 116: if ((active0 & 0x8000L) != 0L) return jjStartNfaWithStates_0(3, 15, 1); - return jjMoveStringLiteralDfa4_0(active0, 0x8000000000000L); + else if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 59, 1); + return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L); case 85: case 117: return jjMoveStringLiteralDfa4_0(active0, 0x18000000L); @@ -539,7 +554,7 @@ default : break; } - return jjStartNfa_0(2, active0); + return jjStartNfa_0(2, active0, 0L); } private final int jjMoveStringLiteralDfa4_0(long old0, long active0) { @@ -544,10 +559,10 @@ private final int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(2, old0); + return jjStartNfa_0(2, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(3, active0); + jjStopStringLiteralDfa_0(3, active0, 0L); return 4; } switch(curChar) @@ -564,27 +579,27 @@ return jjStartNfaWithStates_0(4, 18, 1); else if ((active0 & 0x1000000L) != 0L) return jjStartNfaWithStates_0(4, 24, 1); - return jjMoveStringLiteralDfa5_0(active0, 0x20800008000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x82000008000000L); case 71: case 103: - return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x200000000000000L); case 72: case 104: - return jjMoveStringLiteralDfa5_0(active0, 0x10000000000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L); case 75: case 107: - if ((active0 & 0x200000000000L) != 0L) - return jjStartNfaWithStates_0(4, 45, 1); + if ((active0 & 0x800000000000L) != 0L) + return jjStartNfaWithStates_0(4, 47, 1); break; case 76: case 108: - return jjMoveStringLiteralDfa5_0(active0, 0x40000200000L); + return jjMoveStringLiteralDfa5_0(active0, 0x100000200000L); case 77: case 109: - return jjMoveStringLiteralDfa5_0(active0, 0x1000010000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x4000010000000L); case 79: case 111: - return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x20000000000000L); case 82: case 114: if ((active0 & 0x40L) != 0L) @@ -591,7 +606,7 @@ return jjStartNfaWithStates_0(4, 6, 1); else if ((active0 & 0x80L) != 0L) return jjStartNfaWithStates_0(4, 7, 1); - return jjMoveStringLiteralDfa5_0(active0, 0x480000010200L); + return jjMoveStringLiteralDfa5_0(active0, 0x1200000010200L); case 83: case 115: return jjMoveStringLiteralDfa5_0(active0, 0x20000000L); @@ -599,17 +614,17 @@ case 116: if ((active0 & 0x80000000L) != 0L) return jjStartNfaWithStates_0(4, 31, 1); - return jjMoveStringLiteralDfa5_0(active0, 0x2000000880800L); + return jjMoveStringLiteralDfa5_0(active0, 0x8000000880800L); case 85: case 117: - return jjMoveStringLiteralDfa5_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x10000000000000L); case 86: case 118: - return jjMoveStringLiteralDfa5_0(active0, 0x20040000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x80040000000L); default : break; } - return jjStartNfa_0(3, active0); + return jjStartNfa_0(3, active0, 0L); } private final int jjMoveStringLiteralDfa5_0(long old0, long active0) { @@ -614,10 +629,10 @@ private final int jjMoveStringLiteralDfa5_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(3, old0); + return jjStartNfa_0(3, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(4, active0); + jjStopStringLiteralDfa_0(4, active0, 0L); return 5; } switch(curChar) @@ -624,14 +639,14 @@ { case 65: case 97: - return jjMoveStringLiteralDfa6_0(active0, 0x10000000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x40000000000000L); case 67: case 99: - return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x10000000000000L); case 68: case 100: - if ((active0 & 0x400000000000L) != 0L) - return jjStartNfaWithStates_0(5, 46, 1); + if ((active0 & 0x1000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 48, 1); break; case 69: case 101: @@ -641,15 +656,15 @@ return jjStartNfaWithStates_0(5, 19, 1); else if ((active0 & 0x200000L) != 0L) return jjStartNfaWithStates_0(5, 21, 1); - else if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 55, 1); - return jjMoveStringLiteralDfa6_0(active0, 0xe0040000000L); + else if ((active0 & 0x200000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 57, 1); + return jjMoveStringLiteralDfa6_0(active0, 0x380040000000L); case 70: case 102: - return jjMoveStringLiteralDfa6_0(active0, 0x1000000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000L); case 73: case 105: - return jjMoveStringLiteralDfa6_0(active0, 0x2000000800200L); + return jjMoveStringLiteralDfa6_0(active0, 0x8000000800200L); case 76: case 108: return jjMoveStringLiteralDfa6_0(active0, 0x400000L); @@ -655,13 +670,13 @@ return jjMoveStringLiteralDfa6_0(active0, 0x400000L); case 77: case 109: - return jjMoveStringLiteralDfa6_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x2000000000000L); case 78: case 110: - return jjMoveStringLiteralDfa6_0(active0, 0x20000010000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x80000010000000L); case 82: case 114: - return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x20000000000000L); case 83: case 115: if ((active0 & 0x8000000L) != 0L) @@ -677,7 +692,7 @@ default : break; } - return jjStartNfa_0(4, active0); + return jjStartNfa_0(4, active0, 0L); } private final int jjMoveStringLiteralDfa6_0(long old0, long active0) { @@ -682,10 +697,10 @@ private final int jjMoveStringLiteralDfa6_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(4, old0); + return jjStartNfa_0(4, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(5, active0); + jjStopStringLiteralDfa_0(5, active0, 0L); return 6; } switch(curChar) @@ -691,7 +706,7 @@ switch(curChar) { case 95: - return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x20000000000000L); case 65: case 97: return jjMoveStringLiteralDfa7_0(active0, 0x20000000L); @@ -708,29 +723,29 @@ return jjMoveStringLiteralDfa7_0(active0, 0x10000000L); case 72: case 104: - return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x10000000000000L); case 73: case 105: - return jjMoveStringLiteralDfa7_0(active0, 0x1000000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x4000000000000L); case 78: case 110: - return jjMoveStringLiteralDfa7_0(active0, 0x2040000800000L); + return jjMoveStringLiteralDfa7_0(active0, 0x8100000800000L); case 79: case 111: - return jjMoveStringLiteralDfa7_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L); case 82: case 114: - return jjMoveStringLiteralDfa7_0(active0, 0x20040000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x80040000000L); case 83: case 115: - return jjMoveStringLiteralDfa7_0(active0, 0x10080000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x40200000000000L); case 84: case 116: - return jjMoveStringLiteralDfa7_0(active0, 0x20000000000000L); + return jjMoveStringLiteralDfa7_0(active0, 0x80000000000000L); default : break; } - return jjStartNfa_0(5, active0); + return jjStartNfa_0(5, active0, 0L); } private final int jjMoveStringLiteralDfa7_0(long old0, long active0) { @@ -735,10 +750,10 @@ private final int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(5, old0); + return jjStartNfa_0(5, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(6, active0); + jjStopStringLiteralDfa_0(6, active0, 0L); return 7; } switch(curChar) @@ -750,7 +765,7 @@ case 101: if ((active0 & 0x200L) != 0L) return jjStartNfaWithStates_0(7, 9, 1); - return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x10000000000000L); case 71: case 103: if ((active0 & 0x800000L) != 0L) @@ -755,15 +770,15 @@ case 103: if ((active0 & 0x800000L) != 0L) return jjStartNfaWithStates_0(7, 23, 1); - return jjMoveStringLiteralDfa8_0(active0, 0x2040000000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x8100000000000L); case 72: case 104: - if ((active0 & 0x10000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 52, 1); + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 54, 1); break; case 76: case 108: - return jjMoveStringLiteralDfa8_0(active0, 0x1000000000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L); case 77: case 109: return jjMoveStringLiteralDfa8_0(active0, 0x20000000L); @@ -769,14 +784,14 @@ return jjMoveStringLiteralDfa8_0(active0, 0x20000000L); case 82: case 114: - return jjMoveStringLiteralDfa8_0(active0, 0x20800000000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x82000000000000L); case 83: case 115: - return jjMoveStringLiteralDfa8_0(active0, 0x80a0040000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x20280040000000L); default : break; } - return jjStartNfa_0(6, active0); + return jjStartNfa_0(6, active0, 0L); } private final int jjMoveStringLiteralDfa8_0(long old0, long active0) { @@ -781,10 +796,10 @@ private final int jjMoveStringLiteralDfa8_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(6, old0); + return jjStartNfa_0(6, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(7, active0); + jjStopStringLiteralDfa_0(7, active0, 0L); return 8; } switch(curChar) @@ -790,13 +805,13 @@ switch(curChar) { case 95: - return jjMoveStringLiteralDfa9_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L); case 68: case 100: - return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x10000000000000L); case 73: case 105: - return jjMoveStringLiteralDfa9_0(active0, 0x280a0040000000L); + return jjMoveStringLiteralDfa9_0(active0, 0xa0280040000000L); case 77: case 109: return jjMoveStringLiteralDfa9_0(active0, 0x10000000L); @@ -807,11 +822,11 @@ break; case 84: case 116: - return jjMoveStringLiteralDfa9_0(active0, 0x1040000000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x4100000000000L); case 89: case 121: - if ((active0 & 0x800000000000L) != 0L) - return jjStartNfaWithStates_0(8, 47, 1); + if ((active0 & 0x2000000000000L) != 0L) + return jjStartNfaWithStates_0(8, 49, 1); break; default : break; @@ -816,7 +831,7 @@ default : break; } - return jjStartNfa_0(7, active0); + return jjStartNfa_0(7, active0, 0L); } private final int jjMoveStringLiteralDfa9_0(long old0, long active0) { @@ -821,10 +836,10 @@ private final int jjMoveStringLiteralDfa9_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(7, old0); + return jjStartNfa_0(7, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(8, active0); + jjStopStringLiteralDfa_0(8, active0, 0L); return 9; } switch(curChar) @@ -830,17 +845,17 @@ switch(curChar) { case 95: - return jjMoveStringLiteralDfa10_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x10000000000000L); case 66: case 98: - return jjMoveStringLiteralDfa10_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L); case 69: case 101: - return jjMoveStringLiteralDfa10_0(active0, 0x21000000000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x84000000000000L); case 72: case 104: - if ((active0 & 0x40000000000L) != 0L) - return jjStartNfaWithStates_0(9, 42, 1); + if ((active0 & 0x100000000000L) != 0L) + return jjStartNfaWithStates_0(9, 44, 1); break; case 73: case 105: @@ -847,14 +862,14 @@ return jjMoveStringLiteralDfa10_0(active0, 0x10000000L); case 79: case 111: - return jjMoveStringLiteralDfa10_0(active0, 0xa0040000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x280040000000L); case 90: case 122: - return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L); + return jjMoveStringLiteralDfa10_0(active0, 0x20000000000000L); default : break; } - return jjStartNfa_0(8, active0); + return jjStartNfa_0(8, active0, 0L); } private final int jjMoveStringLiteralDfa10_0(long old0, long active0) { @@ -859,10 +874,10 @@ private final int jjMoveStringLiteralDfa10_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(8, old0); + return jjStartNfa_0(8, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(9, active0); + jjStopStringLiteralDfa_0(9, active0, 0L); return 10; } switch(curChar) @@ -869,29 +884,29 @@ { case 66: case 98: - return jjMoveStringLiteralDfa11_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa11_0(active0, 0x10000000000000L); case 69: case 101: - if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_0(10, 51, 1); + if ((active0 & 0x20000000000000L) != 0L) + return jjStartNfaWithStates_0(10, 53, 1); break; case 76: case 108: - return jjMoveStringLiteralDfa11_0(active0, 0x2000010000000L); + return jjMoveStringLiteralDfa11_0(active0, 0x8000010000000L); case 78: case 110: - if ((active0 & 0x80000000000L) != 0L) - return jjStartNfaWithStates_0(10, 43, 1); - return jjMoveStringLiteralDfa11_0(active0, 0x20040000000L); + if ((active0 & 0x200000000000L) != 0L) + return jjStartNfaWithStates_0(10, 45, 1); + return jjMoveStringLiteralDfa11_0(active0, 0x80040000000L); case 82: case 114: - if ((active0 & 0x1000000000000L) != 0L) - return jjStartNfaWithStates_0(10, 48, 1); + if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_0(10, 50, 1); break; case 83: case 115: - if ((active0 & 0x20000000000000L) != 0L) - return jjStartNfaWithStates_0(10, 53, 1); + if ((active0 & 0x80000000000000L) != 0L) + return jjStartNfaWithStates_0(10, 55, 1); break; default : break; @@ -896,7 +911,7 @@ default : break; } - return jjStartNfa_0(9, active0); + return jjStartNfa_0(9, active0, 0L); } private final int jjMoveStringLiteralDfa11_0(long old0, long active0) { @@ -901,10 +916,10 @@ private final int jjMoveStringLiteralDfa11_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(9, old0); + return jjStartNfa_0(9, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(10, active0); + jjStopStringLiteralDfa_0(10, active0, 0L); return 11; } switch(curChar) @@ -914,10 +929,10 @@ return jjMoveStringLiteralDfa12_0(active0, 0x10000000L); case 76: case 108: - return jjMoveStringLiteralDfa12_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa12_0(active0, 0x10000000000000L); case 79: case 111: - return jjMoveStringLiteralDfa12_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa12_0(active0, 0x8000000000000L); case 83: case 115: if ((active0 & 0x40000000L) != 0L) @@ -922,8 +937,8 @@ case 115: if ((active0 & 0x40000000L) != 0L) return jjStartNfaWithStates_0(11, 30, 1); - else if ((active0 & 0x20000000000L) != 0L) - return jjStartNfaWithStates_0(11, 41, 1); + else if ((active0 & 0x80000000000L) != 0L) + return jjStartNfaWithStates_0(11, 43, 1); break; default : break; @@ -928,7 +943,7 @@ default : break; } - return jjStartNfa_0(10, active0); + return jjStartNfa_0(10, active0, 0L); } private final int jjMoveStringLiteralDfa12_0(long old0, long active0) { @@ -933,10 +948,10 @@ private final int jjMoveStringLiteralDfa12_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(10, old0); + return jjStartNfa_0(10, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(11, active0); + jjStopStringLiteralDfa_0(11, active0, 0L); return 12; } switch(curChar) @@ -946,11 +961,11 @@ return jjMoveStringLiteralDfa13_0(active0, 0x10000000L); case 79: case 111: - return jjMoveStringLiteralDfa13_0(active0, 0x6000000000000L); + return jjMoveStringLiteralDfa13_0(active0, 0x18000000000000L); default : break; } - return jjStartNfa_0(11, active0); + return jjStartNfa_0(11, active0, 0L); } private final int jjMoveStringLiteralDfa13_0(long old0, long active0) { @@ -955,10 +970,10 @@ private final int jjMoveStringLiteralDfa13_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(11, old0); + return jjStartNfa_0(11, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(12, active0); + jjStopStringLiteralDfa_0(12, active0, 0L); return 13; } switch(curChar) @@ -965,10 +980,10 @@ { case 77: case 109: - return jjMoveStringLiteralDfa14_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa14_0(active0, 0x8000000000000L); case 79: case 111: - return jjMoveStringLiteralDfa14_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa14_0(active0, 0x10000000000000L); case 83: case 115: if ((active0 & 0x10000000L) != 0L) @@ -977,7 +992,7 @@ default : break; } - return jjStartNfa_0(12, active0); + return jjStartNfa_0(12, active0, 0L); } private final int jjMoveStringLiteralDfa14_0(long old0, long active0) { @@ -982,10 +997,10 @@ private final int jjMoveStringLiteralDfa14_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(12, old0); + return jjStartNfa_0(12, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(13, active0); + jjStopStringLiteralDfa_0(13, active0, 0L); return 14; } switch(curChar) @@ -992,14 +1007,14 @@ { case 70: case 102: - return jjMoveStringLiteralDfa15_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa15_0(active0, 0x8000000000000L); case 77: case 109: - return jjMoveStringLiteralDfa15_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa15_0(active0, 0x10000000000000L); default : break; } - return jjStartNfa_0(13, active0); + return jjStartNfa_0(13, active0, 0L); } private final int jjMoveStringLiteralDfa15_0(long old0, long active0) { @@ -1004,10 +1019,10 @@ private final int jjMoveStringLiteralDfa15_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(13, old0); + return jjStartNfa_0(13, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(14, active0); + jjStopStringLiteralDfa_0(14, active0, 0L); return 15; } switch(curChar) @@ -1014,14 +1029,14 @@ { case 70: case 102: - return jjMoveStringLiteralDfa16_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa16_0(active0, 0x10000000000000L); case 73: case 105: - return jjMoveStringLiteralDfa16_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa16_0(active0, 0x8000000000000L); default : break; } - return jjStartNfa_0(14, active0); + return jjStartNfa_0(14, active0, 0L); } private final int jjMoveStringLiteralDfa16_0(long old0, long active0) { @@ -1026,10 +1041,10 @@ private final int jjMoveStringLiteralDfa16_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(14, old0); + return jjStartNfa_0(14, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(15, active0); + jjStopStringLiteralDfa_0(15, active0, 0L); return 16; } switch(curChar) @@ -1036,14 +1051,14 @@ { case 73: case 105: - return jjMoveStringLiteralDfa17_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa17_0(active0, 0x10000000000000L); case 76: case 108: - return jjMoveStringLiteralDfa17_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa17_0(active0, 0x8000000000000L); default : break; } - return jjStartNfa_0(15, active0); + return jjStartNfa_0(15, active0, 0L); } private final int jjMoveStringLiteralDfa17_0(long old0, long active0) { @@ -1048,10 +1063,10 @@ private final int jjMoveStringLiteralDfa17_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(15, old0); + return jjStartNfa_0(15, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(16, active0); + jjStopStringLiteralDfa_0(16, active0, 0L); return 17; } switch(curChar) @@ -1058,14 +1073,14 @@ { case 76: case 108: - return jjMoveStringLiteralDfa18_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa18_0(active0, 0x10000000000000L); case 84: case 116: - return jjMoveStringLiteralDfa18_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa18_0(active0, 0x8000000000000L); default : break; } - return jjStartNfa_0(16, active0); + return jjStartNfa_0(16, active0, 0L); } private final int jjMoveStringLiteralDfa18_0(long old0, long active0) { @@ -1070,10 +1085,10 @@ private final int jjMoveStringLiteralDfa18_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(16, old0); + return jjStartNfa_0(16, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(17, active0); + jjStopStringLiteralDfa_0(17, active0, 0L); return 18; } switch(curChar) @@ -1080,14 +1095,14 @@ { case 69: case 101: - return jjMoveStringLiteralDfa19_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa19_0(active0, 0x8000000000000L); case 84: case 116: - return jjMoveStringLiteralDfa19_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa19_0(active0, 0x10000000000000L); default : break; } - return jjStartNfa_0(17, active0); + return jjStartNfa_0(17, active0, 0L); } private final int jjMoveStringLiteralDfa19_0(long old0, long active0) { @@ -1092,10 +1107,10 @@ private final int jjMoveStringLiteralDfa19_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(17, old0); + return jjStartNfa_0(17, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(18, active0); + jjStopStringLiteralDfa_0(18, active0, 0L); return 19; } switch(curChar) @@ -1102,11 +1117,11 @@ { case 69: case 101: - return jjMoveStringLiteralDfa20_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa20_0(active0, 0x10000000000000L); case 82: case 114: - if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_0(19, 49, 1); + if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(19, 51, 1); break; default : break; @@ -1111,7 +1126,7 @@ default : break; } - return jjStartNfa_0(18, active0); + return jjStartNfa_0(18, active0, 0L); } private final int jjMoveStringLiteralDfa20_0(long old0, long active0) { @@ -1116,10 +1131,10 @@ private final int jjMoveStringLiteralDfa20_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(18, old0); + return jjStartNfa_0(18, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(19, active0); + jjStopStringLiteralDfa_0(19, active0, 0L); return 20; } switch(curChar) @@ -1126,8 +1141,8 @@ { case 82: case 114: - if ((active0 & 0x4000000000000L) != 0L) - return jjStartNfaWithStates_0(20, 50, 1); + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(20, 52, 1); break; default : break; @@ -1132,7 +1147,7 @@ default : break; } - return jjStartNfa_0(19, active0); + return jjStartNfa_0(19, active0, 0L); } private final void jjCheckNAdd(int state) { @@ -1189,14 +1204,14 @@ case 0: if ((0x3ff000000000000L & l) != 0L) { - if (kind > 57) - kind = 57; + if (kind > 62) + kind = 62; jjCheckNAddStates(0, 6); } - else if ((0x400e00000000000L & l) != 0L) + else if ((0x400a00000000000L & l) != 0L) { - if (kind > 56) - kind = 56; + if (kind > 61) + kind = 61; jjCheckNAdd(1); } else if (curChar == 39) @@ -1203,28 +1218,14 @@ jjCheckNAddStates(7, 9); else if (curChar == 34) jjCheckNAdd(8); - if (curChar == 46) + else if (curChar == 46) jjCheckNAdd(3); break; - case 32: - if ((0x7ffe00000000000L & l) != 0L) - { - if (kind > 56) - kind = 56; - jjCheckNAdd(1); - } - if ((0x3ff000000000000L & l) != 0L) - { - if (kind > 58) - kind = 58; - jjCheckNAddTwoStates(3, 4); - } - break; case 1: - if ((0x7ffe00000000000L & l) == 0L) + if ((0x7ffa00000000000L & l) == 0L) break; - if (kind > 56) - kind = 56; + if (kind > 61) + kind = 61; jjCheckNAdd(1); break; case 2: @@ -1234,8 +1235,8 @@ case 3: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAddTwoStates(3, 4); break; case 5: @@ -1245,8 +1246,8 @@ case 6: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAdd(6); break; case 7: @@ -1258,8 +1259,8 @@ jjCheckNAddTwoStates(8, 9); break; case 9: - if (curChar == 34 && kind > 60) - kind = 60; + if (curChar == 34 && kind > 65) + kind = 65; break; case 10: if (curChar == 39) @@ -1282,8 +1283,8 @@ jjCheckNAddStates(10, 12); break; case 15: - if (curChar == 39 && kind > 61) - kind = 61; + if (curChar == 39 && kind > 66) + kind = 66; break; case 16: if ((0x3ff000000000000L & l) == 0L) @@ -1288,8 +1289,8 @@ case 16: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 57) - kind = 57; + if (kind > 62) + kind = 62; jjCheckNAddStates(0, 6); break; case 17: @@ -1295,8 +1296,8 @@ case 17: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 57) - kind = 57; + if (kind > 62) + kind = 62; jjCheckNAdd(17); break; case 18: @@ -1310,8 +1311,8 @@ case 20: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAddTwoStates(20, 21); break; case 22: @@ -1321,8 +1322,8 @@ case 23: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAdd(23); break; case 24: @@ -1336,8 +1337,8 @@ case 27: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAdd(27); break; case 28: @@ -1343,8 +1344,8 @@ case 28: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAddTwoStates(28, 29); break; case 30: @@ -1354,8 +1355,8 @@ case 31: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 58) - kind = 58; + if (kind > 63) + kind = 63; jjCheckNAdd(31); break; default : break; @@ -1370,18 +1371,11 @@ switch(jjstateSet[--i]) { case 0: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 56) - kind = 56; - jjCheckNAdd(1); - break; - case 32: case 1: if ((0x7fffffe87fffffeL & l) == 0L) break; - if (kind > 56) - kind = 56; + if (kind > 61) + kind = 61; jjCheckNAdd(1); break; case 4: @@ -1457,9 +1451,10 @@ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, "\54", "\56", "\50", "\51", "\75", -"\74\76", "\52", null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, "\73", }; +null, null, null, null, null, null, null, "\54", "\56", "\50", "\51", "\75", "\76", +"\74", "\74\76", "\52", null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +"\73", }; public static final String[] lexStateNames = { "DEFAULT", }; @@ -1464,10 +1459,10 @@ "DEFAULT", }; static final long[] jjtoToken = { - 0x77ffffffffffffe1L, + 0xffffffffffffffe1L, 0xeL, }; static final long[] jjtoSkip = { - 0x1eL, + 0x1eL, 0x0L, }; protected SimpleCharStream input_stream; private final int[] jjrounds = new int[32]; Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj (revision 582453) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj (working copy) @@ -102,6 +102,8 @@ | | | "> + | | "> | | @@ -121,9 +123,16 @@ | } +TOKEN : +{ + + | + | +} + TOKEN : /** Literals */ { - + | | )? @@ -144,7 +153,10 @@ Command statement = null; } { - ([statement = cmdStatement()] ";" | ) + ( + [statement = cmdStatement()] ";" | + ) + { return statement; } @@ -171,6 +183,8 @@ | cmd = clearCommand() | cmd = fsCommand() | cmd = jarCommand() + | cmd = substituteCommand() + | cmd = saveCommand() ) { return cmd; @@ -245,6 +259,8 @@ | t= | t= | t= + | t= + | t= | t= ) { argument = t.image.toString(); } ] @@ -263,7 +279,7 @@ { [ - argument = Identifier() + argument = identifier() ] { show.setArgument(argument); @@ -278,7 +294,7 @@ } { ( | ) - argument = Identifier() + argument = identifier() { desc.setArgument(argument); return desc; @@ -360,7 +376,7 @@ { - table = Identifier() + table = identifier() { createCommand.setTable(table); } @@ -367,7 +383,7 @@ - column = Identifier() + column = identifier() columnSpec = ColumnSpec() { createCommand.addColumnSpec(column, columnSpec); @@ -375,7 +391,7 @@ ( - column = Identifier() + column = identifier() columnSpec = ColumnSpec() { createCommand.addColumnSpec(column, columnSpec); @@ -395,7 +411,7 @@ } { -
table = Identifier() +
table = identifier() { alterCommand.setTable(table); } ( @@ -400,7 +416,7 @@ ( LOOKAHEAD(2) - column = Identifier() columnSpec = ColumnSpec() + column = identifier() columnSpec = ColumnSpec() { alterCommand.setOperationType(AlterCommand.OperationType.ADD); alterCommand.addColumnSpec(column, columnSpec); @@ -412,7 +428,7 @@ alterCommand.setOperationType(AlterCommand.OperationType.ADD); } - column = Identifier() columnSpec = ColumnSpec() + column = identifier() columnSpec = ColumnSpec() { alterCommand.addColumnSpec(column, columnSpec); } @@ -419,7 +435,7 @@ ( - column = Identifier() + column = identifier() columnSpec = ColumnSpec() { alterCommand.addColumnSpec(column, columnSpec); @@ -427,7 +443,7 @@ )* | - column = Identifier() + column = identifier() { alterCommand.setOperationType(AlterCommand.OperationType.DROP); alterCommand.setColumn(column); @@ -433,7 +449,7 @@ alterCommand.setColumn(column); } | - column = Identifier() columnSpec = ColumnSpec() + column = identifier() columnSpec = ColumnSpec() { alterCommand.setOperationType(AlterCommand.OperationType.CHANGE); alterCommand.addColumnSpec(column, columnSpec); @@ -450,7 +466,7 @@ {
- tableList = TableList() + tableList = tableList() { drop.setTableList(tableList); return drop; @@ -468,11 +484,10 @@ { - table = Identifier() + table = identifier() { in.setTable(table); } - columnfamilies = getColumns() { in.setColumnfamilies(columnfamilies); @@ -477,7 +492,7 @@ { in.setColumnfamilies(columnfamilies); } - + values = getLiteralValues() { in.setValues(values); @@ -502,7 +517,7 @@ } { - columnList = ColumnList() + columnList = columnList() { deleteCommand.setColumnList(columnList); } @@ -508,7 +523,7 @@ } - table = Identifier() + table = identifier() { deleteCommand.setTable(table); } @@ -534,9 +549,9 @@ } {
+ tableName = identifier() + { substitute.setInput(tableName); } + + | chainKey= + + columnList = columnList() + + { substitute.setChainKey(chainKey.image.toString()); + substitute.setColumnList(columnList); + } + ) + + { + return substitute; + } +} + +SaveCommand saveCommand() : +{ + Token t = null; + String tableName; + SaveCommand save = new SaveCommand(this.out); +} +{ + t= + { save.setStatement(t.image.toString()); } +
+ tableName = identifier() { save.setOutput(tableName); } + + { + return save; + } +} + //////////////////////////////////////////////// // Utility expansion units... @@ -657,29 +736,6 @@ } } -List getColumns() : // return parenthesized column list -{ - List values = new ArrayList(); - String literal = null; -} -{ - - { literal = getColumn(); - if(literal != null) values.add(literal); - } - ( - - { - literal = getColumn(); - if(literal != null) values.add(literal); - } - )* - - { - return values; - } -} - String getColumn() : { Token col; @@ -693,7 +749,7 @@ ) } -List TableList() : +List tableList() : { List tableList = new ArrayList(); String table = null; @@ -699,8 +755,8 @@ String table = null; } { - table = Identifier() { tableList.add(table); } - ( table = Identifier() + table = identifier() { tableList.add(table); } + ( table = identifier() { tableList.add(table); } )* @@ -707,7 +763,30 @@ { return tableList; } } -List ColumnList() : +List getColumns() : // return parenthesized column list +{ + List values = new ArrayList(); + String literal = null; +} +{ + + { literal = getColumn(); + if(literal != null) values.add(literal); + } + ( + + { + literal = getColumn(); + if(literal != null) values.add(literal); + } + )* + + { + return values; + } +} + +List columnList() : { List columnList = new ArrayList(); String column = null; @@ -737,7 +816,7 @@ { return Integer.parseInt(t.image.toString()); } } -String Identifier() : +String identifier() : { Token t = null; } @@ -748,4 +827,53 @@ | ( t= | t= ) { return t.image.substring(1,t.image.toString().length() - 1); } ) +} + +String booleanTerm() : +{ + String query = null; + String tmp = null; +} +{ + query = booleanTerms() + ( + ( + + { query += " AND "; } + | + { query += " OR "; } + ) tmp = booleanTerms() { query += tmp; } + )* + + { return query; } +} + +String booleanTerms() : +{ + Token tSearchName, tComparator, tComparand; + String searchName=null,comparator=null,comparand=null; +} +{ + tSearchName= { searchName = tSearchName.image.toString(); } + ( + tComparator= + { comparator = tComparator.image.toString(); } + [ { comparator += "="; }] + | tComparator= + { comparator = tComparator.image.toString(); } + [ { comparator += "="; }] + | tComparator= + { comparator = tComparator.image.toString(); } + ) + + ( + tComparand= + { comparand = tComparand.image.toString(); } + | tComparand= + { comparand = tComparand.image.substring(1,tComparand.image.length() - 1); } + | tComparand= + { comparand = tComparand.image.toString(); } + ) + + { return searchName + " " + comparator + " " + comparand; } } \ No newline at end of file Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java (revision 582453) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java (working copy) @@ -128,6 +128,36 @@ load.put("EXIT", new String[] { "Exit shell", "EXIT;"}); + // A Algebraic Query Commands + // this is a tentative query language based on a hbase which uses relational model of + // data. + + load.put("TABLE", new String[] { "Load a table", + "A = table('table_name');" }); + load.put("SUBSTITUTE", new String[] { "Substitute expression to [A~Z]", + "D = A.projection('cf_name1'[, 'cf_name2']);" }); + load.put("SAVE", new String[] { + "Save results into specified table", + "SAVE A INTO table('table_name');" }); + + // Relational Operations + load.put("PROJECTION", new String[] { + "Make a new relation set {cf_name1, ... , cf_name2}", + "A = TABLE('table_name');" + + " B = A.Projection('cf_name1'[, 'cf_name2']);" }); + load + .put( + "SELECTION", + new String[] { + "Make a new relation set of specified Rows", + "A = Table('table_name');" + + " B = A.Selection(cf_name1 > 100[ AND cf_name2 = 'string_value']);" }); + load.put("SORT", new String[] { + "Make a new sorted set, ordered according to columnfamilies", + "A = Table('table_name');" + + " B = Sort A by ('cf_name1'[, 'cf_name2']);" }); + + return load; } Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/OperationConstants.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/OperationConstants.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/OperationConstants.java (revision 0) @@ -0,0 +1,31 @@ +/** + * 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; + +/** + * List of access control operations constants. + */ +public class OperationConstants { + + public static final String RELATIONAL_ALGEBRA_PROJECTION = "projection"; + public static final String RELATIONAL_ALGEBRA_SELECTION = "selection"; + public static final String RELATIONAL_ALGEBRA_SORT = "sort"; + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/ConfigurationFactory.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/ConfigurationFactory.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/ConfigurationFactory.java (revision 0) @@ -0,0 +1,35 @@ +/** + * 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.query; + +import java.util.Map; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.mapred.JobConf; + +/** + * A factory class that provides configuration information. + */ +public interface ConfigurationFactory { + + JobConf getConf(Configuration conf, String input, String output, + Map statements); + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/GroupingFilterMap.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/GroupingFilterMap.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/GroupingFilterMap.java (revision 0) @@ -0,0 +1,152 @@ +/** + * 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.query; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Map; + +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HStoreKey; +import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.hbase.mapred.TableMap; +import org.apache.hadoop.hbase.mapred.TableOutputCollector; +import org.apache.hadoop.hbase.shell.expression.BooleanExpression; +import org.apache.hadoop.io.MapWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.io.Writable; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.mapred.Reporter; + +/** + * Extract grouping columns from filtered records. + */ +public class GroupingFilterMap extends TableMap { + + private String expression; + BooleanExpression booleanTerm = new BooleanExpression(); + public static final String EXPRESSION = "shell.mapred.filtertablemap.exps"; + public static final String GROUP_COLUMNS = "shell.mapred.filtertablemap.columns"; + private Text[] m_columns; + + /** default constructor */ + public GroupingFilterMap() { + super(); + } + + /** + * Use this before submitting a TableMap job. It will appropriately set up the + * JobConf. + * + * @param table + * table to be processed + * @param columns + * space separated list of columns to fetch + * @param groupColumns + * space separated list of columns used to form the key used in + * collect + * @param mapper + * map class + * @param job + * job configuration object + */ + public static void initJob(String table, String columns, String groupColumns, + String expression, Class mapper, JobConf job) { + + initJob(table, columns, mapper, job); + job.set(GROUP_COLUMNS, groupColumns); + job.set(EXPRESSION, expression); + } + + /** {@inheritDoc} */ + @Override + public void configure(JobConf job) { + super.configure(job); + String[] cols = job.get(GROUP_COLUMNS, "").split(" "); + m_columns = new Text[cols.length]; + for (int i = 0; i < cols.length; i++) { + m_columns[i] = new Text(cols[i]); + } + } + + public void map(@SuppressWarnings("unused") + HStoreKey key, MapWritable value, TableOutputCollector output, + @SuppressWarnings("unused") + Reporter reporter) throws IOException { + booleanTerm.setExpression(expression); + + byte[][] keyVals = extractKeyValues(value); + if (keyVals != null) { + Text tKey = createGroupKey(keyVals); + + if (booleanTerm.checkConstraints(value)) { + output.collect(tKey, value); + } + } + } + + protected byte[][] extractKeyValues(MapWritable r) { + byte[][] keyVals = null; + ArrayList foundList = new ArrayList(); + int numCols = m_columns.length; + if (numCols > 0) { + for (Map.Entry e : r.entrySet()) { + Text column = (Text) e.getKey(); + for (int i = 0; i < numCols; i++) { + if (column.equals(m_columns[i])) { + foundList.add(((ImmutableBytesWritable) e.getValue()).get()); + break; + } + } + } + if (foundList.size() == numCols) { + keyVals = foundList.toArray(new byte[numCols][]); + } + } + return keyVals; + } + + /** + * Create a key by concatenating multiple column values. Override this + * function in order to produce different types of keys. + * + * @param vals + * @return key generated by concatenating multiple column values + */ + protected Text createGroupKey(byte[][] vals) { + if (vals == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < vals.length; i++) { + if (i > 0) { + sb.append(" "); + } + try { + sb.append(new String(vals[i], HConstants.UTF8_ENCODING)); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + return new Text(sb.toString()); + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/IdentityFilterMap.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/IdentityFilterMap.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/IdentityFilterMap.java (revision 0) @@ -0,0 +1,79 @@ +/** + * 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.query; + +import java.io.IOException; +import java.util.logging.Logger; + +import org.apache.hadoop.hbase.HStoreKey; +import org.apache.hadoop.hbase.mapred.TableMap; +import org.apache.hadoop.hbase.mapred.TableOutputCollector; +import org.apache.hadoop.hbase.mapred.TableOutputFormat; +import org.apache.hadoop.hbase.shell.expression.BooleanExpression; +import org.apache.hadoop.io.MapWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.mapred.Reporter; + +/** + * Extract filtered records. + */ +public class IdentityFilterMap extends TableMap { + + static final Logger LOG = Logger.getLogger(TableOutputFormat.class.getName()); + BooleanExpression booleanTerm = new BooleanExpression(); + private String expression; + public static final String EXPRESSION = "shell.mapred.filtertablemap.exps"; + + /** Default Constructor. */ + public IdentityFilterMap() { + super(); + } + + @SuppressWarnings("deprecation") + public static void initJob(String table, String columns, String expression, + Class mapper, JobConf job) { + initJob(table, columns, mapper, job); + job.set(EXPRESSION, expression); + } + + /* + * (non-Javadoc) + * + * @see org.apache.hadoop.hbase.mapred.TableMap#configure(org.apache.hadoop.mapred.JobConf) + */ + public void configure(JobConf job) { + super.configure(job); + expression = job.get(EXPRESSION, ""); + } + + /** + * Filter the value for each specified column family. + */ + public void map(HStoreKey key, MapWritable value, TableOutputCollector output, + Reporter reporter) throws IOException { + booleanTerm.setExpression(expression); + Text tKey = key.getRow(); + if (booleanTerm.checkConstraints(value)) { + output.collect(tKey, value); + } + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/InsertOneTableToAnother.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/InsertOneTableToAnother.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/InsertOneTableToAnother.java (revision 0) @@ -0,0 +1,96 @@ +/** + * 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.query; + +import java.io.IOException; +import java.util.Map; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseAdmin; +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.hbase.mapred.IdentityTableMap; +import org.apache.hadoop.hbase.mapred.IdentityTableReduce; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.ClusterStatus; +import org.apache.hadoop.mapred.JobClient; +import org.apache.hadoop.mapred.JobConf; + +/** + * Insert one table to another. + */ +public class InsertOneTableToAnother implements ConfigurationFactory { + + public JobConf getConf(Configuration conf, String input, String output, + Map statements) { + + JobConf jobConf = new JobConf(conf, InsertOneTableToAnother.class); + + HTableDescriptor desc = new HTableDescriptor(output); + String cols = ""; + + try { + HConnection conn = HConnectionManager.getConnection(conf); + HBaseAdmin admin = new HBaseAdmin(conf); + + HTableDescriptor[] tables = conn.listTables(); + HColumnDescriptor[] columns = null; + for (int i = 0; i < tables.length; i++) { + if (tables[i].getName().equals(new Text(input))) { + columns = tables[i].getFamilies().values().toArray( + new HColumnDescriptor[] {}); + break; + } + } + if (conn.tableExists(new Text(output))) { + System.out.println("'" + output + "' Table exist already."); + return null; + } else { + for (int i = 0; i < columns.length; i++) { + desc.addFamily(columns[i]); + cols += columns[i].getName() + " "; + } + } + + admin.createTable(desc); + } catch (IOException e) { + e.printStackTrace(); + } + + IdentityTableMap.initJob(input, cols, IdentityTableMap.class, + jobConf); + IdentityTableReduce.initJob(output, IdentityTableReduce.class, jobConf); + + try { + JobClient jobClient = new JobClient(jobConf); + + ClusterStatus cluster = jobClient.getClusterStatus(); + jobConf.setNumMapTasks(cluster.getMapTasks()); + jobConf.setNumReduceTasks(1); + + } catch (IOException e) { + e.printStackTrace(); + } + return jobConf; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Projection.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Projection.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Projection.java (revision 0) @@ -0,0 +1,96 @@ +/** + * 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.query; + +import java.io.IOException; +import java.util.Map; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseAdmin; +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.hbase.mapred.GroupingTableMap; +import org.apache.hadoop.hbase.mapred.IdentityTableMap; +import org.apache.hadoop.hbase.mapred.IdentityTableReduce; +import org.apache.hadoop.hbase.shell.OperationConstants; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.ClusterStatus; +import org.apache.hadoop.mapred.JobClient; +import org.apache.hadoop.mapred.JobConf; + +/** + * Perform a relational projection using MapReduce. + */ +public class Projection implements ConfigurationFactory { + + public JobConf getConf(Configuration conf, String input, String output, + Map statements) { + + JobConf jobConf = new JobConf(conf, Projection.class); + jobConf.setJobName("shell.mapred.proj-" + System.currentTimeMillis()); + + try { + HConnection conn = HConnectionManager.getConnection(conf); + if (conn.tableExists(new Text(output))) { + System.out.println("'" + output + "' Table exist already."); + return null; + } else { + HTableDescriptor desc = new HTableDescriptor(output); + String columns = statements + .get(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION); + String[] cols = columns.split(" "); + for (int i = 0; i < cols.length; i++) { + desc.addFamily(new HColumnDescriptor(cols[i])); + } + + HBaseAdmin admin = new HBaseAdmin(conf); + admin.createTable(desc); + } + } catch (IOException e) { + e.printStackTrace(); + } + + if (statements.containsKey(OperationConstants.RELATIONAL_ALGEBRA_SORT)) { + GroupingTableMap.initJob(input, statements + .get(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION), statements + .get(OperationConstants.RELATIONAL_ALGEBRA_SORT), + GroupingTableMap.class, jobConf); + } else { + IdentityTableMap.initJob(input, statements + .get(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION), + IdentityTableMap.class, jobConf); + } + + IdentityTableReduce.initJob(output, IdentityTableReduce.class, jobConf); + try { + JobClient jobClient = new JobClient(jobConf); + ClusterStatus cluster = jobClient.getClusterStatus(); + jobConf.setNumMapTasks(cluster.getMapTasks()); + jobConf.setNumReduceTasks(1); + } catch (IOException e) { + e.printStackTrace(); + } + + return jobConf; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Selection.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Selection.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/query/Selection.java (revision 0) @@ -0,0 +1,113 @@ +/** + * 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.query; + +import java.io.IOException; +import java.util.Map; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseAdmin; +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.hbase.mapred.IdentityTableReduce; +import org.apache.hadoop.hbase.shell.OperationConstants; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.ClusterStatus; +import org.apache.hadoop.mapred.JobClient; +import org.apache.hadoop.mapred.JobConf; + +/** + * Perform a relational selection using MapReduce. + */ +public class Selection implements ConfigurationFactory { + + public JobConf getConf(Configuration conf, String input, String output, + Map statements) { + + JobConf jobConf = new JobConf(conf, Selection.class); + jobConf.setJobName("shell.mapred.select-" + +System.currentTimeMillis()); + + HTableDescriptor desc = new HTableDescriptor(output); + String cols = ""; + try { + HConnection conn = HConnectionManager.getConnection(conf); + HBaseAdmin admin = new HBaseAdmin(conf); + + if (statements + .containsKey(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION)) { + cols = statements.get(OperationConstants.RELATIONAL_ALGEBRA_PROJECTION); + } else { + + HTableDescriptor[] tables = conn.listTables(); + HColumnDescriptor[] columns = null; + for (int i = 0; i < tables.length; i++) { + if (tables[i].getName().equals(new Text(input))) { + columns = tables[i].getFamilies().values().toArray( + new HColumnDescriptor[] {}); + break; + } + } + if (conn.tableExists(new Text(output))) { + System.out.println("'" + output + "' Table exist already."); + return null; + } else { + for (int i = 0; i < columns.length; i++) { + desc.addFamily(columns[i]); + cols += columns[i].getName() + " "; + } + } + + admin.createTable(desc); + } + } catch (IOException e) { + e.printStackTrace(); + } + + if (statements.containsKey(OperationConstants.RELATIONAL_ALGEBRA_SORT)) { + GroupingFilterMap.initJob(input, cols, statements + .get(OperationConstants.RELATIONAL_ALGEBRA_SORT), statements + .get(OperationConstants.RELATIONAL_ALGEBRA_SELECTION), + GroupingFilterMap.class, jobConf); + } else { + IdentityFilterMap.initJob(input, cols, statements + .get(OperationConstants.RELATIONAL_ALGEBRA_SELECTION), + IdentityFilterMap.class, jobConf); + } + + IdentityTableReduce.initJob(output, IdentityTableReduce.class, jobConf); + + try { + JobClient jobClient = new JobClient(jobConf); + + ClusterStatus cluster = jobClient.getClusterStatus(); + jobConf.setNumMapTasks(cluster.getMapTasks()); + jobConf.setNumReduceTasks(1); + + } catch (IOException e) { + e.printStackTrace(); + } + + return jobConf; + + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SaveCommand.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SaveCommand.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SaveCommand.java (revision 0) @@ -0,0 +1,95 @@ +/** + * 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; + +import java.io.IOException; +import java.io.Writer; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.mapred.JobClient; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.mapred.RunningJob; + +/** + * Save results to specified table. + */ +public class SaveCommand extends BasicCommand { + + private String statement; + private String output; + + public SaveCommand(Writer o) { + super(o); + } + + public ReturnMsg execute(Configuration conf) { + try { + ConfigurationGenerator queryProc = new ConfigurationGenerator(conf, statement, output); + JobConf jobConf = queryProc.getJobConf(); + + return new ReturnMsg(0, submitJob(jobConf)); + } catch (IOException e) { + return new ReturnMsg(0, e.toString()); + } + } + + /** + * Submit a job to job tracker. + * @param job + * @return result + * @throws IOException + */ + public static String submitJob(JobConf job) throws IOException { + JobClient jc = new JobClient(job); + boolean success = true; + RunningJob running = null; + try { + running = jc.submitJob(job); + String jobId = running.getJobID(); + System.out.print("Job " + jobId + " is still running."); + + while (!running.isComplete()) { + System.out.print("."); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + } + running = jc.getJob(jobId); + } + success = running.isSuccessful(); + } finally { + if (!success && (running != null)) { + running.killJob(); + } + jc.close(); + System.out.println(); + } + return (success) ? "Successfully complete." : "Job Failed."; + } + + public void setOutput(String output) { + this.output = output; + } + + public void setStatement(String statement) { + this.statement = statement; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SubstituteCommand.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SubstituteCommand.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SubstituteCommand.java (revision 0) @@ -0,0 +1,79 @@ +/** + * 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; + +import java.io.Writer; +import java.util.List; + +import org.apache.hadoop.conf.Configuration; + +/** + * This class represents a substitute command. + */ +public class SubstituteCommand extends BasicCommand { + + private String input; + private String key; + private String chainKey; + private String operation; + private List columnList; + private String booleanTerm; + + public SubstituteCommand(Writer o) { + super(o); + } + + public ReturnMsg execute(Configuration conf) { + if(input != null) { + this.operation = "table"; + this.booleanTerm = input; + } + + VariableRef formula = new VariableRef(operation, columnList, booleanTerm); + VariablesPool.put(key, chainKey, formula); + + return null; + } + + public void setInput(String input) { + this.input = input; + } + + public void setKey(String key) { + this.key = key; + } + + public void setChainKey(String chainKey) { + this.chainKey = chainKey; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public void setColumnList(List columnList) { + this.columnList = columnList; + } + + public void setBooleanTerm(String booleanTerm) { + this.booleanTerm = booleanTerm; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariableRef.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariableRef.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariableRef.java (revision 0) @@ -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.shell; + +import java.util.List; + +/** + * VariableRef is used to reference declared Variables. + */ +public class VariableRef { + + String operation; + String argument; + + /** + * Constructor + */ + public VariableRef(String operation, List columnList, + String booleanTerm) { + this.operation = operation; + + if (booleanTerm != null) { + this.argument = booleanTerm; + } else { + String args = ""; + for (int i = 0; i < columnList.size(); i++) { + args += columnList.get(i) + ": "; + } + this.argument = args; + } + } + + /** + * Return argument of an operation + * @return argument + */ + public String getArguments() { + return argument; + } + + /** + * Return operation + * @return operation + */ + public String getOperation() { + return operation; + } + +} Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariablesPool.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariablesPool.java (revision 0) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/VariablesPool.java (revision 0) @@ -0,0 +1,42 @@ +/** + * 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; + +import java.util.HashMap; + +/** + * Variable pool is a collection of substitution variables. + */ +public class VariablesPool { + + static HashMap> commandMap = + new HashMap>(); + + public static void put(String key, String parentKey, VariableRef statement) { + HashMap value = new HashMap(); + value.put(parentKey, statement); + commandMap.put(key, value); + } + + public static HashMap get(String key) { + return commandMap.get(key); + } + +} Index: src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/expression/TestBooleanExpression.java =================================================================== --- src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/expression/TestBooleanExpression.java (revision 0) +++ src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/expression/TestBooleanExpression.java (revision 0) @@ -0,0 +1,49 @@ +/** + * 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.expression; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; + +/** + * Test boolean expression + */ +public class TestBooleanExpression extends TestCase { + + public static String EXPRESSION = "integer > 100 AND integer < 200 AND string = 'str'"; + static Configuration conf = new HBaseConfiguration(); + + public void testBooleanExpression() { + BooleanExpression booleanExpression = new BooleanExpression(); + booleanExpression.setExpression(EXPRESSION); + + assertTrue(booleanExpression.toString().equals( + "(integer > 100 AND integer < 200) AND string = 'str'")); + } + + public static void main(String[] args) { + TestRunner.run(new TestSuite(TestBooleanExpression.class)); + } + +} Index: src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/query/TestFilterMapReduce.java =================================================================== --- src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/query/TestFilterMapReduce.java (revision 0) +++ src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/query/TestFilterMapReduce.java (revision 0) @@ -0,0 +1,186 @@ +/** + * 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.query; + +import java.io.IOException; +import java.util.Map; +import java.util.TreeMap; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.dfs.MiniDFSCluster; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.HBaseAdmin; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HScannerInterface; +import org.apache.hadoop.hbase.HStoreKey; +import org.apache.hadoop.hbase.HTable; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.MasterNotRunningException; +import org.apache.hadoop.hbase.MiniHBaseCluster; +import org.apache.hadoop.hbase.MultiRegionTable; +import org.apache.hadoop.hbase.mapred.IdentityTableReduce; +import org.apache.hadoop.hbase.mapred.TestTableMapReduce; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.JobClient; +import org.apache.hadoop.mapred.JobConf; +import org.apache.hadoop.mapred.MiniMRCluster; + +public class TestFilterMapReduce extends MultiRegionTable { + + static final String INPUT_TABLE = "movieLog_table"; + static final String OUTPUT_TABLE = "result_table"; + static final String COLUMN_FAMILY = "year: length:"; + static final String BOOLEAN_TERM = "length > 100"; + private MiniDFSCluster dfsCluster = null; + private FileSystem fs; + private Path dir; + + @SuppressWarnings("unused") + private MiniHBaseCluster hCluster = null; + + /** + * {@inheritDoc} + */ + @Override + public void setUp() throws Exception { + super.setUp(); + // This size is picked so the table is split into two + // after addContent in testMultiRegionTableMapReduce. + conf.setLong("hbase.hregion.max.filesize", 256 * 1024); + dfsCluster = new MiniDFSCluster(conf, 1, true, (String[]) null); + try { + fs = dfsCluster.getFileSystem(); + dir = new Path("/hbase"); + fs.mkdirs(dir); + // Start up HBase cluster + hCluster = new MiniHBaseCluster(conf, 1, dfsCluster); + } catch (Exception e) { + if (dfsCluster != null) { + dfsCluster.shutdown(); + dfsCluster = null; + } + throw e; + } + } + + public void testMapReduce() { + try { + HTableDescriptor desc = new HTableDescriptor(INPUT_TABLE); + String[] columns = COLUMN_FAMILY.split(" "); + for(int i = 0; i < columns.length; i++) { + desc.addFamily(new HColumnDescriptor(columns[i])); + } + HBaseAdmin admin = new HBaseAdmin(this.conf); + admin.createTable(desc); + + // insert some data into the source table + HTable table = new HTable(conf, new Text(INPUT_TABLE)); + long lockid = table.startUpdate(new Text("Star Wars")); + + table.put(lockid, new Text("year:"), "1977" + .getBytes(HConstants.UTF8_ENCODING)); + table.put(lockid, new Text("length:"), "124" + .getBytes(HConstants.UTF8_ENCODING)); + table.commit(lockid, System.currentTimeMillis()); + + lockid = table.startUpdate(new Text("Mighty Ducks")); + + table.put(lockid, new Text("year:"), "1991" + .getBytes(HConstants.UTF8_ENCODING)); + table.put(lockid, new Text("length:"), "98" + .getBytes(HConstants.UTF8_ENCODING)); + table.commit(lockid, System.currentTimeMillis()); + + } catch (MasterNotRunningException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + try { + HTableDescriptor output = new HTableDescriptor(OUTPUT_TABLE); + String[] columns = COLUMN_FAMILY.split(" "); + for(int i = 0; i < columns.length; i++) { + output.addFamily(new HColumnDescriptor(columns[i])); + } + HBaseAdmin admin = new HBaseAdmin(this.conf); + admin.createTable(output); + } catch (MasterNotRunningException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + MiniMRCluster mrCluster = null; + try { + mrCluster = new MiniMRCluster(2, fs.getUri().toString(), 1); + + JobConf jobConf = new JobConf(conf, TestTableMapReduce.class); + jobConf.setJobName("process selection mapreduce"); + jobConf.setNumMapTasks(2); + jobConf.setNumReduceTasks(1); + + IdentityFilterMap.initJob(INPUT_TABLE, COLUMN_FAMILY, BOOLEAN_TERM, + IdentityFilterMap.class, jobConf); + + IdentityTableReduce.initJob(OUTPUT_TABLE, IdentityTableReduce.class, + jobConf); + + JobClient.runJob(jobConf); + + } catch (IOException e) { + e.printStackTrace(); + } finally { + mrCluster.shutdown(); + } + + try { + verify(conf, OUTPUT_TABLE); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void verify(Configuration conf, String outputTable) + throws IOException { + HTable table = new HTable(conf, new Text(outputTable)); + Text[] columns = { new Text("year:"), new Text("length:") }; + HScannerInterface scanner = table.obtainScanner(columns, + HConstants.EMPTY_START_ROW); + + try { + HStoreKey key = new HStoreKey(); + TreeMap results = new TreeMap(); + + while (scanner.next(key, results)) { + for (Map.Entry e : results.entrySet()) { + assertTrue(Integer.parseInt(new String(e.getValue())) > 100); + } + } + + } finally { + scanner.close(); + } + + } + +} Index: src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/TestSubstitutionVariables.java =================================================================== --- src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/TestSubstitutionVariables.java (revision 0) +++ src/contrib/hbase/src/test/org/apache/hadoop/hbase/shell/TestSubstitutionVariables.java (revision 0) @@ -0,0 +1,79 @@ +/** + * 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; + +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.util.Map; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.shell.expression.TestBooleanExpression; + +/** + * Binding variables, substitution variables test + */ +public class TestSubstitutionVariables extends TestCase { + + private String TABLE_NAME = "table_name"; + private String SUBSTITUTION_VARIABLE = "A"; + static Configuration conf = new HBaseConfiguration(); + + public void testSubstitution() { + SubstituteCommand substitute = new SubstituteCommand(null); + + substitute.setKey(SUBSTITUTION_VARIABLE); + substitute.setInput(TABLE_NAME); + substitute.execute(conf); + + VariableRef ref = VariablesPool.get(SUBSTITUTION_VARIABLE).get(null); + assertTrue(ref.getArguments().equals(TABLE_NAME)); + } + + public void testCombinedQueries() throws UnsupportedEncodingException { + Writer out = new OutputStreamWriter(System.out, "UTF-8"); + SubstituteCommand substitute = new SubstituteCommand(out); + + substitute.setKey(SUBSTITUTION_VARIABLE); + substitute.setInput(TABLE_NAME); + substitute.execute(conf); + + substitute = new SubstituteCommand(out); + substitute.setKey("B"); + substitute.setChainKey(SUBSTITUTION_VARIABLE); + substitute.setOperation(OperationConstants.RELATIONAL_ALGEBRA_SELECTION); + substitute.setBooleanTerm(TestBooleanExpression.EXPRESSION); + substitute.execute(conf); + + ConfigurationGenerator queryProc = new ConfigurationGenerator(conf, "B", "output_table"); + Map statements = queryProc.getStatements(); + assertTrue(statements.containsKey(OperationConstants.RELATIONAL_ALGEBRA_SELECTION)); + } + + public static void main(String[] args) { + TestRunner.run(new TestSuite(TestSubstitutionVariables.class)); + } + +}