PageRenderTime 62ms CodeModel.GetById 19ms RepoModel.GetById 4ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/parse/QBExpr.java

#
Java | 117 lines | 70 code | 22 blank | 25 comment | 3 complexity | f9be67980080c6f16f79f6b31cb350ef MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.ql.parse;
  19. import org.apache.commons.logging.Log;
  20. import org.apache.commons.logging.LogFactory;
  21. /**
  22. * Implementation of the query block expression.
  23. *
  24. **/
  25. public class QBExpr {
  26. private static final Log LOG = LogFactory.getLog("hive.ql.parse.QBExpr");
  27. /**
  28. * Opcode.
  29. *
  30. */
  31. public static enum Opcode {
  32. NULLOP, UNION, INTERSECT, DIFF
  33. };
  34. private Opcode opcode;
  35. private QBExpr qbexpr1;
  36. private QBExpr qbexpr2;
  37. private QB qb;
  38. private String alias;
  39. public String getAlias() {
  40. return alias;
  41. }
  42. public void setAlias(String alias) {
  43. this.alias = alias;
  44. }
  45. public QBExpr(String alias) {
  46. this.alias = alias;
  47. }
  48. public QBExpr(QB qb) {
  49. opcode = Opcode.NULLOP;
  50. this.qb = qb;
  51. }
  52. public QBExpr(Opcode opcode, QBExpr qbexpr1, QBExpr qbexpr2) {
  53. this.opcode = opcode;
  54. this.qbexpr1 = qbexpr1;
  55. this.qbexpr2 = qbexpr2;
  56. }
  57. public void setQB(QB qb) {
  58. this.qb = qb;
  59. }
  60. public void setOpcode(Opcode opcode) {
  61. this.opcode = opcode;
  62. }
  63. public void setQBExpr1(QBExpr qbexpr) {
  64. qbexpr1 = qbexpr;
  65. }
  66. public void setQBExpr2(QBExpr qbexpr) {
  67. qbexpr2 = qbexpr;
  68. }
  69. public QB getQB() {
  70. return qb;
  71. }
  72. public Opcode getOpcode() {
  73. return opcode;
  74. }
  75. public QBExpr getQBExpr1() {
  76. return qbexpr1;
  77. }
  78. public QBExpr getQBExpr2() {
  79. return qbexpr2;
  80. }
  81. public void print(String msg) {
  82. if (opcode == Opcode.NULLOP) {
  83. LOG.info(msg + "start qb = " + qb);
  84. qb.print(msg + " ");
  85. LOG.info(msg + "end qb = " + qb);
  86. } else {
  87. LOG.info(msg + "start qbexpr1 = " + qbexpr1);
  88. qbexpr1.print(msg + " ");
  89. LOG.info(msg + "end qbexpr1 = " + qbexpr1);
  90. LOG.info(msg + "start qbexpr2 = " + qbexpr2);
  91. qbexpr2.print(msg + " ");
  92. LOG.info(msg + "end qbexpr2 = " + qbexpr2);
  93. }
  94. }
  95. }