001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.hadoop.record.meta; 020 021 import java.io.IOException; 022 import java.util.*; 023 024 import org.apache.hadoop.classification.InterfaceAudience; 025 import org.apache.hadoop.classification.InterfaceStability; 026 import org.apache.hadoop.record.RecordOutput; 027 028 /** 029 * Represents typeID for a Map 030 * 031 * @deprecated Replaced by <a href="http://hadoop.apache.org/avro/">Avro</a>. 032 */ 033 @Deprecated 034 @InterfaceAudience.Public 035 @InterfaceStability.Stable 036 public class MapTypeID extends TypeID { 037 038 private TypeID typeIDKey; 039 private TypeID typeIDValue; 040 041 public MapTypeID(TypeID typeIDKey, TypeID typeIDValue) { 042 super(RIOType.MAP); 043 this.typeIDKey = typeIDKey; 044 this.typeIDValue = typeIDValue; 045 } 046 047 /** 048 * get the TypeID of the map's key element 049 */ 050 public TypeID getKeyTypeID() { 051 return this.typeIDKey; 052 } 053 054 /** 055 * get the TypeID of the map's value element 056 */ 057 public TypeID getValueTypeID() { 058 return this.typeIDValue; 059 } 060 061 void write(RecordOutput rout, String tag) throws IOException { 062 rout.writeByte(typeVal, tag); 063 typeIDKey.write(rout, tag); 064 typeIDValue.write(rout, tag); 065 } 066 067 /** 068 * Two map typeIDs are equal if their constituent elements have the 069 * same type 070 */ 071 public boolean equals(Object o) { 072 if (!super.equals(o)) 073 return false; 074 075 MapTypeID mti = (MapTypeID) o; 076 077 return this.typeIDKey.equals(mti.typeIDKey) && 078 this.typeIDValue.equals(mti.typeIDValue); 079 } 080 081 /** 082 * We use a basic hashcode implementation, since this class will likely not 083 * be used as a hashmap key 084 */ 085 public int hashCode() { 086 return 37*17+typeIDKey.hashCode() + 37*17+typeIDValue.hashCode(); 087 } 088 089 }