PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/metadata/Dimension.java

#
Java | 79 lines | 47 code | 10 blank | 22 comment | 8 complexity | 01a5ab9c273a0339b289f37ae3df2c9a 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.metadata;
  19. /**
  20. * Hive consists of a fixed, well defined set of Dimensions. Each dimension has
  21. * a type and id. Dimensions link columns in different tables
  22. *
  23. */
  24. public class Dimension {
  25. protected Class<?> dimensionType;
  26. protected String dimensionId;
  27. public Dimension(Class<?> t, String id) {
  28. dimensionType = t;
  29. dimensionId = id;
  30. }
  31. public Class<?> getDimensionType() {
  32. return dimensionType;
  33. }
  34. public String getDimensionId() {
  35. return dimensionId;
  36. }
  37. @Override
  38. public boolean equals(Object o) {
  39. if (super.equals(o)) {
  40. return true;
  41. }
  42. if (o == null) {
  43. return false;
  44. }
  45. if (o instanceof Dimension) {
  46. Dimension d = (Dimension) o;
  47. return (dimensionId.equals(d.dimensionId) && (dimensionType == d.dimensionType));
  48. }
  49. return false;
  50. }
  51. @Override
  52. @SuppressWarnings("nls")
  53. public String toString() {
  54. return "Type=" + dimensionType.getName() + "," + "Id=" + dimensionId;
  55. }
  56. @Override
  57. public int hashCode() {
  58. final int prime = 31;
  59. int result = 1;
  60. result = prime * result
  61. + ((dimensionId == null) ? 0 : dimensionId.hashCode());
  62. result = prime * result
  63. + ((dimensionType == null) ? 0 : dimensionType.hashCode());
  64. return result;
  65. }
  66. public int hashCode(Object o) {
  67. return dimensionType.hashCode() ^ dimensionId.hashCode();
  68. }
  69. }