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 019package org.apache.hadoop.record.meta; 020 021import java.io.IOException; 022 023import org.apache.hadoop.classification.InterfaceAudience; 024import org.apache.hadoop.classification.InterfaceStability; 025import org.apache.hadoop.record.RecordOutput; 026 027/** 028 * Represents a type information for a field, which is made up of its 029 * ID (name) and its type (a TypeID object). 030 * 031 * @deprecated Replaced by <a href="https://hadoop.apache.org/avro/">Avro</a>. 032 */ 033@Deprecated 034@InterfaceAudience.Public 035@InterfaceStability.Stable 036public class FieldTypeInfo 037{ 038 039 private String fieldID; 040 private TypeID typeID; 041 042 /** 043 * Construct a FiledTypeInfo with the given field name and the type 044 */ 045 FieldTypeInfo(String fieldID, TypeID typeID) { 046 this.fieldID = fieldID; 047 this.typeID = typeID; 048 } 049 050 /** 051 * get the field's TypeID object 052 */ 053 public TypeID getTypeID() { 054 return typeID; 055 } 056 057 /** 058 * get the field's id (name) 059 */ 060 public String getFieldID() { 061 return fieldID; 062 } 063 064 void write(RecordOutput rout, String tag) throws IOException { 065 rout.writeString(fieldID, tag); 066 typeID.write(rout, tag); 067 } 068 069 /** 070 * Two FieldTypeInfos are equal if ach of their fields matches 071 */ 072 public boolean equals(Object o) { 073 if (this == o) 074 return true; 075 if (!(o instanceof FieldTypeInfo)) 076 return false; 077 FieldTypeInfo fti = (FieldTypeInfo) o; 078 // first check if fieldID matches 079 if (!this.fieldID.equals(fti.fieldID)) { 080 return false; 081 } 082 // now see if typeID matches 083 return (this.typeID.equals(fti.typeID)); 084 } 085 086 /** 087 * We use a basic hashcode implementation, since this class will likely not 088 * be used as a hashmap key 089 */ 090 public int hashCode() { 091 return 37*17+typeID.hashCode() + 37*17+fieldID.hashCode(); 092 } 093 094 095 public boolean equals(FieldTypeInfo ti) { 096 // first check if fieldID matches 097 if (!this.fieldID.equals(ti.fieldID)) { 098 return false; 099 } 100 // now see if typeID matches 101 return (this.typeID.equals(ti.typeID)); 102 } 103 104} 105