PageRenderTime 31ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 2ms 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
  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
 19package org.apache.hadoop.hive.ql.parse;
 20
 21import org.apache.commons.logging.Log;
 22import org.apache.commons.logging.LogFactory;
 23
 24/**
 25 * Implementation of the query block expression.
 26 * 
 27 **/
 28
 29public class QBExpr {
 30
 31  private static final Log LOG = LogFactory.getLog("hive.ql.parse.QBExpr");
 32
 33  /**
 34   * Opcode.
 35   *
 36   */
 37  public static enum Opcode {
 38    NULLOP, UNION, INTERSECT, DIFF
 39  };
 40
 41  private Opcode opcode;
 42  private QBExpr qbexpr1;
 43  private QBExpr qbexpr2;
 44  private QB qb;
 45  private String alias;
 46
 47  public String getAlias() {
 48    return alias;
 49  }
 50
 51  public void setAlias(String alias) {
 52    this.alias = alias;
 53  }
 54
 55  public QBExpr(String alias) {
 56    this.alias = alias;
 57  }
 58
 59  public QBExpr(QB qb) {
 60    opcode = Opcode.NULLOP;
 61    this.qb = qb;
 62  }
 63
 64  public QBExpr(Opcode opcode, QBExpr qbexpr1, QBExpr qbexpr2) {
 65    this.opcode = opcode;
 66    this.qbexpr1 = qbexpr1;
 67    this.qbexpr2 = qbexpr2;
 68  }
 69
 70  public void setQB(QB qb) {
 71    this.qb = qb;
 72  }
 73
 74  public void setOpcode(Opcode opcode) {
 75    this.opcode = opcode;
 76  }
 77
 78  public void setQBExpr1(QBExpr qbexpr) {
 79    qbexpr1 = qbexpr;
 80  }
 81
 82  public void setQBExpr2(QBExpr qbexpr) {
 83    qbexpr2 = qbexpr;
 84  }
 85
 86  public QB getQB() {
 87    return qb;
 88  }
 89
 90  public Opcode getOpcode() {
 91    return opcode;
 92  }
 93
 94  public QBExpr getQBExpr1() {
 95    return qbexpr1;
 96  }
 97
 98  public QBExpr getQBExpr2() {
 99    return qbexpr2;
100  }
101
102  public void print(String msg) {
103    if (opcode == Opcode.NULLOP) {
104      LOG.info(msg + "start qb = " + qb);
105      qb.print(msg + " ");
106      LOG.info(msg + "end qb = " + qb);
107    } else {
108      LOG.info(msg + "start qbexpr1 = " + qbexpr1);
109      qbexpr1.print(msg + " ");
110      LOG.info(msg + "end qbexpr1 = " + qbexpr1);
111      LOG.info(msg + "start qbexpr2 = " + qbexpr2);
112      qbexpr2.print(msg + " ");
113      LOG.info(msg + "end qbexpr2 = " + qbexpr2);
114    }
115  }
116
117}