source: proiecte/HadoopJUnit/hadoop-0.20.1/src/core/org/apache/hadoop/record/meta/MapTypeID.java @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 2.2 KB
Line 
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.record.meta;
20
21import java.io.IOException;
22import java.util.*;
23
24import org.apache.hadoop.record.RecordOutput;
25
26/**
27 * Represents typeID for a Map
28 */
29public class MapTypeID extends TypeID {
30 
31  private TypeID typeIDKey; 
32  private TypeID typeIDValue; 
33 
34  public MapTypeID(TypeID typeIDKey, TypeID typeIDValue) {
35    super(RIOType.MAP);
36    this.typeIDKey = typeIDKey;
37    this.typeIDValue = typeIDValue;
38  }
39 
40  /**
41   * get the TypeID of the map's key element
42   */
43  public TypeID getKeyTypeID() {
44    return this.typeIDKey;
45  }
46 
47  /**
48   * get the TypeID of the map's value element
49   */
50  public TypeID getValueTypeID() {
51    return this.typeIDValue;
52  }
53 
54  void write(RecordOutput rout, String tag) throws IOException {
55    rout.writeByte(typeVal, tag);
56    typeIDKey.write(rout, tag);
57    typeIDValue.write(rout, tag);
58  }
59 
60  /**
61   * Two map  typeIDs are equal if their constituent elements have the
62   * same type
63   */
64  public boolean equals(Object o) {
65    if (!super.equals(o))
66      return false;
67
68    MapTypeID mti = (MapTypeID) o;
69
70    return this.typeIDKey.equals(mti.typeIDKey) &&
71           this.typeIDValue.equals(mti.typeIDValue);
72  }
73 
74  /**
75   * We use a basic hashcode implementation, since this class will likely not
76   * be used as a hashmap key
77   */
78  public int hashCode() {
79    return 37*17+typeIDKey.hashCode() + 37*17+typeIDValue.hashCode();
80  }
81 
82}
Note: See TracBrowser for help on using the repository browser.