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