PageRenderTime 23ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 6ms app.codeStats 0ms

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