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 typeID for vector. 
029 * @deprecated Replaced by <a href="https://hadoop.apache.org/avro/">Avro</a>.
030 */
031@Deprecated
032@InterfaceAudience.Public
033@InterfaceStability.Stable
034public class VectorTypeID extends TypeID {
035  private TypeID typeIDElement; 
036  
037  public VectorTypeID(TypeID typeIDElement) {
038    super(RIOType.VECTOR);
039    this.typeIDElement = typeIDElement;
040  }
041  
042  public TypeID getElementTypeID() {
043    return this.typeIDElement;
044  }
045  
046  @Override
047  void write(RecordOutput rout, String tag) throws IOException {
048    rout.writeByte(typeVal, tag);
049    typeIDElement.write(rout, tag);
050  }
051  
052  /**
053   * Two vector typeIDs are equal if their constituent elements have the 
054   * same type
055   */
056  @Override
057  public boolean equals(Object o) {
058    if (!super.equals (o))
059      return false;
060
061    VectorTypeID vti = (VectorTypeID) o;
062    return this.typeIDElement.equals(vti.typeIDElement);
063  }
064  
065  /**
066   * We use a basic hashcode implementation, since this class will likely not
067   * be used as a hashmap key 
068   */
069  @Override
070  public int hashCode() {
071    return 37*17+typeIDElement.hashCode();
072  }
073  
074}