From 30eb6606016a86bf8966369bb02a4aacd2bafa1d Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Mon, 3 Dec 2007 18:42:09 +0000 Subject: [PATCH] HADOOP-2332 Meta table data selection in Hbase Shell git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@600627 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 + .../apache/hadoop/hbase/shell/HBaseShell.jj | 5 +- .../hadoop/hbase/shell/SelectCommand.java | 7 +- .../hadoop/hbase/shell/generated/Parser.java | 102 ++++--- .../shell/generated/ParserConstants.java | 22 +- .../shell/generated/ParserTokenManager.java | 267 ++++++++++-------- 6 files changed, 231 insertions(+), 174 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1c6bf990e05..eb2e5948a55 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -52,6 +52,8 @@ Trunk (unreleased changes) test to time out HADOOP-2315 REST servlet doesn't treat / characters in row key correctly (Bryan Duxbury via Stack) + HADOOP-2332 Meta table data selection in Hbase Shell + (Edward Yoon via Stack) IMPROVEMENTS HADOOP-2401 Add convenience put method that takes writable diff --git a/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj b/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj index e16d6bd1f79..293a2b7e321 100644 --- a/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj +++ b/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj @@ -126,6 +126,8 @@ TOKEN: /** for HQL statements */ | | | + | + | } TOKEN : @@ -565,6 +567,7 @@ SelectCommand selectCommand() : columns = columnList() tableName = identifier() + { select.setColumns(columns); select.setTable(tableName); @@ -858,7 +861,7 @@ String identifier() : } { ( - t = + ( t= | t= | t= ) { return t.image.toString(); } | ( t= | t= ) { return t.image.substring(1,t.image.toString().length() - 1); } diff --git a/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java b/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java index fcee1697e52..bdd21ac87cf 100644 --- a/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java +++ b/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java @@ -81,7 +81,7 @@ public class SelectCommand extends BasicCommand { } try { HConnection conn = HConnectionManager.getConnection(conf); - if (!conn.tableExists(this.tableName)) { + if (!conn.tableExists(this.tableName) && !isMetaTable()) { return new ReturnMsg(0, "'" + this.tableName + "'" + TABLE_NOT_FOUND); } @@ -100,6 +100,11 @@ public class SelectCommand extends BasicCommand { } } + private boolean isMetaTable() { + return (this.tableName.equals(HConstants.ROOT_TABLE_NAME) + || this.tableName.equals(HConstants.META_TABLE_NAME)) ? true : false; + } + private int compoundWherePrint(HTable table, HBaseAdmin admin) { int count = 0; try { diff --git a/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java b/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java index 8da8a3748ae..3f1d7a45049 100644 --- a/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java +++ b/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java @@ -77,7 +77,7 @@ public class Parser implements ParserConstants { case DISABLE: case SAVE: case ID: - case 69: + case 71: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case HELP: case ALTER: @@ -103,7 +103,7 @@ public class Parser implements ParserConstants { jj_la1[0] = jj_gen; ; } - jj_consume_token(69); + jj_consume_token(71); break; case 0: jj_consume_token(0); @@ -374,6 +374,8 @@ public class Parser implements ParserConstants { String argument = null; jj_consume_token(SHOW); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case META_TABLE: + case ROOT_TABLE: case ID: case QUOTED_IDENTIFIER: case STRING_LITERAL: @@ -1101,8 +1103,24 @@ public class Parser implements ParserConstants { final public String identifier() throws ParseException { Token t = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case META_TABLE: + case ROOT_TABLE: case ID: - t = jj_consume_token(ID); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ID: + t = jj_consume_token(ID); + break; + case META_TABLE: + t = jj_consume_token(META_TABLE); + break; + case ROOT_TABLE: + t = jj_consume_token(ROOT_TABLE); + break; + default: + jj_la1[38] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } {if (true) return t.image.toString();} break; case QUOTED_IDENTIFIER: @@ -1115,14 +1133,14 @@ public class Parser implements ParserConstants { t = jj_consume_token(STRING_LITERAL); break; default: - jj_la1[38] = jj_gen; + jj_la1[39] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return t.image.substring(1,t.image.toString().length() - 1);} break; default: - jj_la1[39] = jj_gen; + jj_la1[40] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1147,7 +1165,7 @@ public class Parser implements ParserConstants { ; break; default: - jj_la1[40] = jj_gen; + jj_la1[41] = jj_gen; break label_11; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1160,7 +1178,7 @@ public class Parser implements ParserConstants { connector = " OR "; break; default: - jj_la1[41] = jj_gen; + jj_la1[42] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1204,13 +1222,13 @@ public class Parser implements ParserConstants { searchName += ".ROW"; break; default: - jj_la1[42] = jj_gen; + jj_la1[43] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[43] = jj_gen; + jj_la1[44] = jj_gen; ; } comparator = getComparator(); @@ -1240,13 +1258,13 @@ public class Parser implements ParserConstants { comparand += "." + joinColumn.image.toString(); break; default: - jj_la1[44] = jj_gen; + jj_la1[45] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[45] = jj_gen; + jj_la1[46] = jj_gen; ; } break; @@ -1266,7 +1284,7 @@ public class Parser implements ParserConstants { } break; default: - jj_la1[46] = jj_gen; + jj_la1[47] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1295,7 +1313,7 @@ public class Parser implements ParserConstants { comparator += "="; break; default: - jj_la1[47] = jj_gen; + jj_la1[48] = jj_gen; ; } break; @@ -1308,7 +1326,7 @@ public class Parser implements ParserConstants { comparator += "="; break; default: - jj_la1[48] = jj_gen; + jj_la1[49] = jj_gen; ; } break; @@ -1321,7 +1339,7 @@ public class Parser implements ParserConstants { comparator = ">" + comparator; break; default: - jj_la1[49] = jj_gen; + jj_la1[50] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1330,7 +1348,7 @@ public class Parser implements ParserConstants { comparator = "<" + comparator; break; default: - jj_la1[50] = jj_gen; + jj_la1[51] = jj_gen; ; } break; @@ -1348,7 +1366,7 @@ public class Parser implements ParserConstants { comparator = "=="; break; default: - jj_la1[51] = jj_gen; + jj_la1[52] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1370,11 +1388,6 @@ public class Parser implements ParserConstants { finally { jj_save(0, xla); } } - final private boolean jj_3R_13() { - if (jj_scan_token(ID)) return true; - return false; - } - final private boolean jj_3_1() { if (jj_scan_token(ADD)) return true; if (jj_3R_12()) return true; @@ -1394,9 +1407,22 @@ public class Parser implements ParserConstants { final private boolean jj_3R_14() { Token xsp; xsp = jj_scanpos; - if (jj_scan_token(67)) { + if (jj_scan_token(69)) { jj_scanpos = xsp; - if (jj_scan_token(68)) return true; + if (jj_scan_token(70)) return true; + } + return false; + } + + final private boolean jj_3R_13() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(65)) { + jj_scanpos = xsp; + if (jj_scan_token(60)) { + jj_scanpos = xsp; + if (jj_scan_token(61)) return true; + } } return false; } @@ -1410,7 +1436,7 @@ public class Parser implements ParserConstants { public boolean lookingAhead = false; private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[52]; + final private int[] jj_la1 = new int[53]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; @@ -1420,13 +1446,13 @@ public class Parser implements ParserConstants { jj_la1_2(); } private static void jj_la1_0() { - jj_la1_0 = new int[] {0x79ffe0,0x79ffe1,0x79ffe0,0x0,0x0,0x0,0x0,0x0,0x19fbc0,0x19fbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x1800000,0x1800000,0x20000000,0x40000000,0x80000000,0x0,0x40000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000000,0x0,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_0 = new int[] {0x79ffe0,0x79ffe1,0x79ffe0,0x0,0x0,0x0,0x0,0x0,0x19fbc0,0x19fbc0,0x0,0x600,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x1800000,0x1800000,0x20000000,0x40000000,0x80000000,0x0,0x40000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000000,0x0,0x4000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0x90000000,0x90000000,0x90000000,0x80000000,0x80000008,0x80000008,0x80000000,0x80000000,0xb0000000,0xb0000000,0x80000000,0x0,0x398e000,0x70000,0x700000,0x398e000,0x4,0x4,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xa0000000,0x80000004,0x80000000,0x80000004,0x0,0x80001000,0x0,0x80001000,0x4,0x4,0x4,0x0,0x80000000,0x3,0x3,0x80000000,0x8,0x80000000,0x8,0x80000010,0x40,0x40,0x80,0x100,0xfc0,}; + jj_la1_1 = new int[] {0x40000000,0x40000000,0x40000000,0x0,0x8,0x8,0x0,0x0,0xc0000000,0xc0000000,0x30000000,0x0,0x398e000,0x70000,0x700000,0x398e000,0x4,0x4,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x80000000,0x4,0x0,0x4,0x0,0x1000,0x0,0x1000,0x4,0x4,0x4,0x30000000,0x0,0x30000000,0x3,0x3,0x0,0x8,0x0,0x8,0x10,0x40,0x40,0x80,0x100,0xfc0,}; } private static void jj_la1_2() { - jj_la1_2 = new int[] {0x0,0x20,0x0,0x0,0x3,0x3,0x3,0x3,0x0,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x18,0x18,0x1,0x18,0x19,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_2 = new int[] {0x2,0x82,0x2,0x2,0xe,0xe,0xe,0xe,0x2,0x2,0x62,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x62,0x62,0x62,0x60,0x6,0x60,0x66,0x0,0x0,0x0,0x2,0x60,0x62,0x0,0x0,0x2,0x0,0x2,0x0,0x46,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[1]; private boolean jj_rescan = false; @@ -1441,7 +1467,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1454,7 +1480,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1464,7 +1490,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1474,7 +1500,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1483,7 +1509,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1492,7 +1518,7 @@ public class Parser implements ParserConstants { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 52; i++) jj_la1[i] = -1; + for (int i = 0; i < 53; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -1603,15 +1629,15 @@ public class Parser implements ParserConstants { public ParseException generateParseException() { jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[70]; - for (int i = 0; i < 70; i++) { + boolean[] la1tokens = new boolean[72]; + for (int i = 0; i < 72; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 52; i++) { + for (int i = 0; i < 53; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< 64) - kind = 64; + if (kind > 66) + kind = 66; jjCheckNAddStates(0, 6); } else if ((0x400a00000000000L & l) != 0L) { - if (kind > 63) - kind = 63; + if (kind > 65) + kind = 65; jjCheckNAdd(1); } else if (curChar == 39) @@ -1243,8 +1260,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 1: if ((0x7ffa00000000000L & l) == 0L) break; - if (kind > 63) - kind = 63; + if (kind > 65) + kind = 65; jjCheckNAdd(1); break; case 2: @@ -1254,8 +1271,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 3: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAddTwoStates(3, 4); break; case 5: @@ -1265,8 +1282,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 6: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAdd(6); break; case 7: @@ -1278,8 +1295,8 @@ private final int jjMoveNfa_0(int startState, int curPos) jjCheckNAddTwoStates(8, 9); break; case 9: - if (curChar == 34 && kind > 67) - kind = 67; + if (curChar == 34 && kind > 69) + kind = 69; break; case 10: if (curChar == 39) @@ -1302,21 +1319,21 @@ private final int jjMoveNfa_0(int startState, int curPos) jjCheckNAddStates(10, 12); break; case 15: - if (curChar == 39 && kind > 68) - kind = 68; + if (curChar == 39 && kind > 70) + kind = 70; break; case 16: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 64) - kind = 64; + if (kind > 66) + kind = 66; jjCheckNAddStates(0, 6); break; case 17: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 64) - kind = 64; + if (kind > 66) + kind = 66; jjCheckNAdd(17); break; case 18: @@ -1330,8 +1347,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 20: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAddTwoStates(20, 21); break; case 22: @@ -1341,8 +1358,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 23: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAdd(23); break; case 24: @@ -1356,15 +1373,15 @@ private final int jjMoveNfa_0(int startState, int curPos) case 27: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAdd(27); break; case 28: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAddTwoStates(28, 29); break; case 30: @@ -1374,8 +1391,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 31: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 65) - kind = 65; + if (kind > 67) + kind = 67; jjCheckNAdd(31); break; default : break; @@ -1393,8 +1410,8 @@ private final int jjMoveNfa_0(int startState, int curPos) case 1: if ((0x47fffffe87fffffeL & l) == 0L) break; - if (kind > 63) - kind = 63; + if (kind > 65) + kind = 65; jjCheckNAdd(1); break; case 4: @@ -1473,12 +1490,12 @@ null, null, null, null, null, null, null, null, null, null, null, null, null, nu null, null, null, null, null, null, null, "\54", "\56", "\50", "\51", "\75", "\76", "\74", null, null, "\41\75", "\52", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, "\73", }; +null, null, null, null, "\73", }; public static final String[] lexStateNames = { "DEFAULT", }; static final long[] jjtoToken = { - 0xffffffffffffffe1L, 0x3bL, + 0xffffffffffffffe1L, 0xefL, }; static final long[] jjtoSkip = { 0x1eL, 0x0L,