PageRenderTime 51ms CodeModel.GetById 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/ListTypeInfo.java

#
Java | 89 lines | 42 code | 14 blank | 33 comment | 3 complexity | 71fff9774147662511f1e616b6fbb18d 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.serde2.typeinfo;
  19. import java.io.Serializable;
  20. import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
  21. /**
  22. * A List Type has homogeneous elements. All elements of the List has the same
  23. * TypeInfo which is returned by getListElementTypeInfo.
  24. *
  25. * Always use the TypeInfoFactory to create new TypeInfo objects, instead of
  26. * directly creating an instance of this class.
  27. */
  28. public final class ListTypeInfo extends TypeInfo implements Serializable {
  29. private static final long serialVersionUID = 1L;
  30. private TypeInfo listElementTypeInfo;
  31. /**
  32. * For java serialization use only.
  33. */
  34. public ListTypeInfo() {
  35. }
  36. @Override
  37. public String getTypeName() {
  38. return org.apache.hadoop.hive.serde.Constants.LIST_TYPE_NAME + "<"
  39. + listElementTypeInfo.getTypeName() + ">";
  40. }
  41. /**
  42. * For java serialization use only.
  43. */
  44. public void setListElementTypeInfo(TypeInfo listElementTypeInfo) {
  45. this.listElementTypeInfo = listElementTypeInfo;
  46. }
  47. /**
  48. * For TypeInfoFactory use only.
  49. */
  50. ListTypeInfo(TypeInfo elementTypeInfo) {
  51. listElementTypeInfo = elementTypeInfo;
  52. }
  53. @Override
  54. public Category getCategory() {
  55. return Category.LIST;
  56. }
  57. public TypeInfo getListElementTypeInfo() {
  58. return listElementTypeInfo;
  59. }
  60. @Override
  61. public boolean equals(Object other) {
  62. if (this == other) {
  63. return true;
  64. }
  65. if (!(other instanceof ListTypeInfo)) {
  66. return false;
  67. }
  68. return getListElementTypeInfo().equals(
  69. ((ListTypeInfo) other).getListElementTypeInfo());
  70. }
  71. @Override
  72. public int hashCode() {
  73. return listElementTypeInfo.hashCode();
  74. }
  75. }