PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java

#
Java | 136 lines | 73 code | 31 blank | 32 comment | 0 complexity | e5efa79555ffdc72de2cc9376c63e4fd 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.exec;
 20
 21import java.io.Serializable;
 22
 23import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 24import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 25
 26/**
 27 * Implementation for ColumnInfo which contains the internal name for the column
 28 * (the one that is used by the operator to access the column) and the type
 29 * (identified by a java class).
 30 **/
 31
 32public class ColumnInfo implements Serializable {
 33
 34  private static final long serialVersionUID = 1L;
 35
 36  private String internalName;
 37
 38  private String alias = null; // [optional] alias of the column (external name
 39  // as seen by the users)
 40
 41  /**
 42   * Store the alias of the table where available.
 43   */
 44  private String tabAlias;
 45
 46  /**
 47   * Indicates whether the column is a virtual column.
 48   */
 49  private boolean isVirtualCol;
 50
 51  private transient TypeInfo type;
 52
 53  private boolean isHiddenVirtualCol;
 54
 55  public ColumnInfo() {
 56  }
 57
 58  public ColumnInfo(String internalName, TypeInfo type, String tabAlias,
 59      boolean isVirtualCol) {
 60    this(internalName, type, tabAlias, isVirtualCol, false);
 61  }
 62
 63  public ColumnInfo(String internalName, Class type, String tabAlias,
 64      boolean isVirtualCol) {
 65    this(internalName, TypeInfoFactory
 66        .getPrimitiveTypeInfoFromPrimitiveWritable(type), tabAlias,
 67        isVirtualCol, false);
 68  }
 69
 70  public ColumnInfo(String internalName, TypeInfo type, String tabAlias,
 71      boolean isVirtualCol, boolean isHiddenVirtualCol) {
 72    this.internalName = internalName;
 73    this.type = type;
 74    this.tabAlias = tabAlias;
 75    this.isVirtualCol = isVirtualCol;
 76    this.isHiddenVirtualCol = isHiddenVirtualCol;
 77  }
 78
 79  public TypeInfo getType() {
 80    return type;
 81  }
 82
 83  public String getInternalName() {
 84    return internalName;
 85  }
 86
 87  public void setType(TypeInfo type) {
 88    this.type = type;
 89  }
 90
 91  public void setInternalName(String internalName) {
 92    this.internalName = internalName;
 93  }
 94
 95  public String getTabAlias() {
 96    return tabAlias;
 97  }
 98
 99  public boolean getIsVirtualCol() {
100    return isVirtualCol;
101  }
102
103  public boolean isHiddenVirtualCol() {
104    return isHiddenVirtualCol;
105  }
106
107  /**
108   * Returns the string representation of the ColumnInfo.
109   */
110  @Override
111  public String toString() {
112    return internalName + ": " + type;
113  }
114
115  public void setAlias(String col_alias) {
116    alias = col_alias;
117  }
118
119  public String getAlias() {
120    return alias;
121  }
122
123  public void setTabAlias(String tabAlias) {
124    this.tabAlias = tabAlias;
125  }
126
127  public void setVirtualCol(boolean isVirtualCol) {
128    this.isVirtualCol = isVirtualCol;
129  }
130
131  public void setHiddenVirtualCol(boolean isHiddenVirtualCol) {
132    this.isHiddenVirtualCol = isHiddenVirtualCol;
133  }
134
135
136}