All Downloads are FREE. Search and download functionalities are using the official Maven repository.

parquet.format.SchemaElement Maven / Gradle / Ivy

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package parquet.format;

import com.facebook.presto.hive.$internal.org.apache.commons.lang.builder.HashCodeBuilder;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import com.facebook.presto.hive.$internal.org.slf4j.Logger;
import com.facebook.presto.hive.$internal.org.slf4j.LoggerFactory;

import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;

/**
 * Represents a element inside a schema definition.
 *  - if it is a group (inner node) then type is undefined and num_children is defined
 *  - if it is a primitive type (leaf) then type is defined and num_children is undefined
 * the nodes are listed in depth first traversal order.
 */
public class SchemaElement implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("SchemaElement");

  private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)1);
  private static final TField TYPE_LENGTH_FIELD_DESC = new TField("type_length", TType.I32, (short)2);
  private static final TField REPETITION_TYPE_FIELD_DESC = new TField("repetition_type", TType.I32, (short)3);
  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)4);
  private static final TField NUM_CHILDREN_FIELD_DESC = new TField("num_children", TType.I32, (short)5);
  private static final TField CONVERTED_TYPE_FIELD_DESC = new TField("converted_type", TType.I32, (short)6);
  private static final TField SCALE_FIELD_DESC = new TField("scale", TType.I32, (short)7);
  private static final TField PRECISION_FIELD_DESC = new TField("precision", TType.I32, (short)8);
  private static final TField FIELD_ID_FIELD_DESC = new TField("field_id", TType.I32, (short)9);

  /**
   * Data type for this field. Not set if the current element is a non-leaf node
   * 
   * @see Type
   */
  public Type type;
  /**
   * If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the vales.
   * Otherwise, if specified, this is the maximum bit length to store any of the values.
   * (e.g. a low cardinality INT col could have this set to 3).  Note that this is
   * in the schema, and therefore fixed for the entire file.
   */
  public int type_length;
  /**
   * repetition of the field. The root of the schema does not have a repetition_type.
   * All other nodes must have one
   * 
   * @see FieldRepetitionType
   */
  public FieldRepetitionType repetition_type;
  /**
   * Name of the field in the schema
   */
  public String name;
  /**
   * Nested fields.  Since thrift does not support nested fields,
   * the nesting is flattened to a single list by a depth-first traversal.
   * The children count is used to construct the nested relationship.
   * This field is not set when the element is a primitive type
   */
  public int num_children;
  /**
   * When the schema is the result of a conversion from another model
   * Used to record the original type to help with cross conversion.
   * 
   * @see ConvertedType
   */
  public ConvertedType converted_type;
  /**
   * Used when this column contains decimal data.
   * See the DECIMAL converted type for more details.
   */
  public int scale;
  public int precision;
  /**
   * When the original schema supports field ids, this will save the
   * original field id in the parquet schema
   */
  public int field_id;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    /**
     * Data type for this field. Not set if the current element is a non-leaf node
     * 
     * @see Type
     */
    TYPE((short)1, "type"),
    /**
     * If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the vales.
     * Otherwise, if specified, this is the maximum bit length to store any of the values.
     * (e.g. a low cardinality INT col could have this set to 3).  Note that this is
     * in the schema, and therefore fixed for the entire file.
     */
    TYPE_LENGTH((short)2, "type_length"),
    /**
     * repetition of the field. The root of the schema does not have a repetition_type.
     * All other nodes must have one
     * 
     * @see FieldRepetitionType
     */
    REPETITION_TYPE((short)3, "repetition_type"),
    /**
     * Name of the field in the schema
     */
    NAME((short)4, "name"),
    /**
     * Nested fields.  Since thrift does not support nested fields,
     * the nesting is flattened to a single list by a depth-first traversal.
     * The children count is used to construct the nested relationship.
     * This field is not set when the element is a primitive type
     */
    NUM_CHILDREN((short)5, "num_children"),
    /**
     * When the schema is the result of a conversion from another model
     * Used to record the original type to help with cross conversion.
     * 
     * @see ConvertedType
     */
    CONVERTED_TYPE((short)6, "converted_type"),
    /**
     * Used when this column contains decimal data.
     * See the DECIMAL converted type for more details.
     */
    SCALE((short)7, "scale"),
    PRECISION((short)8, "precision"),
    /**
     * When the original schema supports field ids, this will save the
     * original field id in the parquet schema
     */
    FIELD_ID((short)9, "field_id");

    private static final Map byName = new HashMap();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // TYPE
          return TYPE;
        case 2: // TYPE_LENGTH
          return TYPE_LENGTH;
        case 3: // REPETITION_TYPE
          return REPETITION_TYPE;
        case 4: // NAME
          return NAME;
        case 5: // NUM_CHILDREN
          return NUM_CHILDREN;
        case 6: // CONVERTED_TYPE
          return CONVERTED_TYPE;
        case 7: // SCALE
          return SCALE;
        case 8: // PRECISION
          return PRECISION;
        case 9: // FIELD_ID
          return FIELD_ID;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __TYPE_LENGTH_ISSET_ID = 0;
  private static final int __NUM_CHILDREN_ISSET_ID = 1;
  private static final int __SCALE_ISSET_ID = 2;
  private static final int __PRECISION_ISSET_ID = 3;
  private static final int __FIELD_ID_ISSET_ID = 4;
  private BitSet __isset_bit_vector = new BitSet(5);

  public static final Map<_Fields, FieldMetaData> metaDataMap;
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.OPTIONAL, 
        new EnumMetaData(TType.ENUM, Type.class)));
    tmpMap.put(_Fields.TYPE_LENGTH, new FieldMetaData("type_length", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    tmpMap.put(_Fields.REPETITION_TYPE, new FieldMetaData("repetition_type", TFieldRequirementType.OPTIONAL, 
        new EnumMetaData(TType.ENUM, FieldRepetitionType.class)));
    tmpMap.put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.STRING)));
    tmpMap.put(_Fields.NUM_CHILDREN, new FieldMetaData("num_children", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    tmpMap.put(_Fields.CONVERTED_TYPE, new FieldMetaData("converted_type", TFieldRequirementType.OPTIONAL, 
        new EnumMetaData(TType.ENUM, ConvertedType.class)));
    tmpMap.put(_Fields.SCALE, new FieldMetaData("scale", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    tmpMap.put(_Fields.PRECISION, new FieldMetaData("precision", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    tmpMap.put(_Fields.FIELD_ID, new FieldMetaData("field_id", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(SchemaElement.class, metaDataMap);
  }

  public SchemaElement() {
  }

  public SchemaElement(
    String name)
  {
    this();
    this.name = name;
  }

  /**
   * Performs a deep copy on other.
   */
  public SchemaElement(SchemaElement other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetType()) {
      this.type = other.type;
    }
    this.type_length = other.type_length;
    if (other.isSetRepetition_type()) {
      this.repetition_type = other.repetition_type;
    }
    if (other.isSetName()) {
      this.name = other.name;
    }
    this.num_children = other.num_children;
    if (other.isSetConverted_type()) {
      this.converted_type = other.converted_type;
    }
    this.scale = other.scale;
    this.precision = other.precision;
    this.field_id = other.field_id;
  }

  public SchemaElement deepCopy() {
    return new SchemaElement(this);
  }

  @Override
  public void clear() {
    this.type = null;
    setType_lengthIsSet(false);
    this.type_length = 0;
    this.repetition_type = null;
    this.name = null;
    setNum_childrenIsSet(false);
    this.num_children = 0;
    this.converted_type = null;
    setScaleIsSet(false);
    this.scale = 0;
    setPrecisionIsSet(false);
    this.precision = 0;
    setField_idIsSet(false);
    this.field_id = 0;
  }

  /**
   * Data type for this field. Not set if the current element is a non-leaf node
   * 
   * @see Type
   */
  public Type getType() {
    return this.type;
  }

  /**
   * Data type for this field. Not set if the current element is a non-leaf node
   * 
   * @see Type
   */
  public SchemaElement setType(Type type) {
    this.type = type;
    return this;
  }

  public void unsetType() {
    this.type = null;
  }

  /** Returns true if field type is set (has been asigned a value) and false otherwise */
  public boolean isSetType() {
    return this.type != null;
  }

  public void setTypeIsSet(boolean value) {
    if (!value) {
      this.type = null;
    }
  }

  /**
   * If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the vales.
   * Otherwise, if specified, this is the maximum bit length to store any of the values.
   * (e.g. a low cardinality INT col could have this set to 3).  Note that this is
   * in the schema, and therefore fixed for the entire file.
   */
  public int getType_length() {
    return this.type_length;
  }

  /**
   * If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the vales.
   * Otherwise, if specified, this is the maximum bit length to store any of the values.
   * (e.g. a low cardinality INT col could have this set to 3).  Note that this is
   * in the schema, and therefore fixed for the entire file.
   */
  public SchemaElement setType_length(int type_length) {
    this.type_length = type_length;
    setType_lengthIsSet(true);
    return this;
  }

  public void unsetType_length() {
    __isset_bit_vector.clear(__TYPE_LENGTH_ISSET_ID);
  }

  /** Returns true if field type_length is set (has been asigned a value) and false otherwise */
  public boolean isSetType_length() {
    return __isset_bit_vector.get(__TYPE_LENGTH_ISSET_ID);
  }

  public void setType_lengthIsSet(boolean value) {
    __isset_bit_vector.set(__TYPE_LENGTH_ISSET_ID, value);
  }

  /**
   * repetition of the field. The root of the schema does not have a repetition_type.
   * All other nodes must have one
   * 
   * @see FieldRepetitionType
   */
  public FieldRepetitionType getRepetition_type() {
    return this.repetition_type;
  }

  /**
   * repetition of the field. The root of the schema does not have a repetition_type.
   * All other nodes must have one
   * 
   * @see FieldRepetitionType
   */
  public SchemaElement setRepetition_type(FieldRepetitionType repetition_type) {
    this.repetition_type = repetition_type;
    return this;
  }

  public void unsetRepetition_type() {
    this.repetition_type = null;
  }

  /** Returns true if field repetition_type is set (has been asigned a value) and false otherwise */
  public boolean isSetRepetition_type() {
    return this.repetition_type != null;
  }

  public void setRepetition_typeIsSet(boolean value) {
    if (!value) {
      this.repetition_type = null;
    }
  }

  /**
   * Name of the field in the schema
   */
  public String getName() {
    return this.name;
  }

  /**
   * Name of the field in the schema
   */
  public SchemaElement setName(String name) {
    this.name = name;
    return this;
  }

  public void unsetName() {
    this.name = null;
  }

  /** Returns true if field name is set (has been asigned a value) and false otherwise */
  public boolean isSetName() {
    return this.name != null;
  }

  public void setNameIsSet(boolean value) {
    if (!value) {
      this.name = null;
    }
  }

  /**
   * Nested fields.  Since thrift does not support nested fields,
   * the nesting is flattened to a single list by a depth-first traversal.
   * The children count is used to construct the nested relationship.
   * This field is not set when the element is a primitive type
   */
  public int getNum_children() {
    return this.num_children;
  }

  /**
   * Nested fields.  Since thrift does not support nested fields,
   * the nesting is flattened to a single list by a depth-first traversal.
   * The children count is used to construct the nested relationship.
   * This field is not set when the element is a primitive type
   */
  public SchemaElement setNum_children(int num_children) {
    this.num_children = num_children;
    setNum_childrenIsSet(true);
    return this;
  }

  public void unsetNum_children() {
    __isset_bit_vector.clear(__NUM_CHILDREN_ISSET_ID);
  }

  /** Returns true if field num_children is set (has been asigned a value) and false otherwise */
  public boolean isSetNum_children() {
    return __isset_bit_vector.get(__NUM_CHILDREN_ISSET_ID);
  }

  public void setNum_childrenIsSet(boolean value) {
    __isset_bit_vector.set(__NUM_CHILDREN_ISSET_ID, value);
  }

  /**
   * When the schema is the result of a conversion from another model
   * Used to record the original type to help with cross conversion.
   * 
   * @see ConvertedType
   */
  public ConvertedType getConverted_type() {
    return this.converted_type;
  }

  /**
   * When the schema is the result of a conversion from another model
   * Used to record the original type to help with cross conversion.
   * 
   * @see ConvertedType
   */
  public SchemaElement setConverted_type(ConvertedType converted_type) {
    this.converted_type = converted_type;
    return this;
  }

  public void unsetConverted_type() {
    this.converted_type = null;
  }

  /** Returns true if field converted_type is set (has been asigned a value) and false otherwise */
  public boolean isSetConverted_type() {
    return this.converted_type != null;
  }

  public void setConverted_typeIsSet(boolean value) {
    if (!value) {
      this.converted_type = null;
    }
  }

  /**
   * Used when this column contains decimal data.
   * See the DECIMAL converted type for more details.
   */
  public int getScale() {
    return this.scale;
  }

  /**
   * Used when this column contains decimal data.
   * See the DECIMAL converted type for more details.
   */
  public SchemaElement setScale(int scale) {
    this.scale = scale;
    setScaleIsSet(true);
    return this;
  }

  public void unsetScale() {
    __isset_bit_vector.clear(__SCALE_ISSET_ID);
  }

  /** Returns true if field scale is set (has been asigned a value) and false otherwise */
  public boolean isSetScale() {
    return __isset_bit_vector.get(__SCALE_ISSET_ID);
  }

  public void setScaleIsSet(boolean value) {
    __isset_bit_vector.set(__SCALE_ISSET_ID, value);
  }

  public int getPrecision() {
    return this.precision;
  }

  public SchemaElement setPrecision(int precision) {
    this.precision = precision;
    setPrecisionIsSet(true);
    return this;
  }

  public void unsetPrecision() {
    __isset_bit_vector.clear(__PRECISION_ISSET_ID);
  }

  /** Returns true if field precision is set (has been asigned a value) and false otherwise */
  public boolean isSetPrecision() {
    return __isset_bit_vector.get(__PRECISION_ISSET_ID);
  }

  public void setPrecisionIsSet(boolean value) {
    __isset_bit_vector.set(__PRECISION_ISSET_ID, value);
  }

  /**
   * When the original schema supports field ids, this will save the
   * original field id in the parquet schema
   */
  public int getField_id() {
    return this.field_id;
  }

  /**
   * When the original schema supports field ids, this will save the
   * original field id in the parquet schema
   */
  public SchemaElement setField_id(int field_id) {
    this.field_id = field_id;
    setField_idIsSet(true);
    return this;
  }

  public void unsetField_id() {
    __isset_bit_vector.clear(__FIELD_ID_ISSET_ID);
  }

  /** Returns true if field field_id is set (has been asigned a value) and false otherwise */
  public boolean isSetField_id() {
    return __isset_bit_vector.get(__FIELD_ID_ISSET_ID);
  }

  public void setField_idIsSet(boolean value) {
    __isset_bit_vector.set(__FIELD_ID_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case TYPE:
      if (value == null) {
        unsetType();
      } else {
        setType((Type)value);
      }
      break;

    case TYPE_LENGTH:
      if (value == null) {
        unsetType_length();
      } else {
        setType_length((Integer)value);
      }
      break;

    case REPETITION_TYPE:
      if (value == null) {
        unsetRepetition_type();
      } else {
        setRepetition_type((FieldRepetitionType)value);
      }
      break;

    case NAME:
      if (value == null) {
        unsetName();
      } else {
        setName((String)value);
      }
      break;

    case NUM_CHILDREN:
      if (value == null) {
        unsetNum_children();
      } else {
        setNum_children((Integer)value);
      }
      break;

    case CONVERTED_TYPE:
      if (value == null) {
        unsetConverted_type();
      } else {
        setConverted_type((ConvertedType)value);
      }
      break;

    case SCALE:
      if (value == null) {
        unsetScale();
      } else {
        setScale((Integer)value);
      }
      break;

    case PRECISION:
      if (value == null) {
        unsetPrecision();
      } else {
        setPrecision((Integer)value);
      }
      break;

    case FIELD_ID:
      if (value == null) {
        unsetField_id();
      } else {
        setField_id((Integer)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case TYPE:
      return getType();

    case TYPE_LENGTH:
      return new Integer(getType_length());

    case REPETITION_TYPE:
      return getRepetition_type();

    case NAME:
      return getName();

    case NUM_CHILDREN:
      return new Integer(getNum_children());

    case CONVERTED_TYPE:
      return getConverted_type();

    case SCALE:
      return new Integer(getScale());

    case PRECISION:
      return new Integer(getPrecision());

    case FIELD_ID:
      return new Integer(getField_id());

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case TYPE:
      return isSetType();
    case TYPE_LENGTH:
      return isSetType_length();
    case REPETITION_TYPE:
      return isSetRepetition_type();
    case NAME:
      return isSetName();
    case NUM_CHILDREN:
      return isSetNum_children();
    case CONVERTED_TYPE:
      return isSetConverted_type();
    case SCALE:
      return isSetScale();
    case PRECISION:
      return isSetPrecision();
    case FIELD_ID:
      return isSetField_id();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof SchemaElement)
      return this.equals((SchemaElement)that);
    return false;
  }

  public boolean equals(SchemaElement that) {
    if (that == null)
      return false;

    boolean this_present_type = true && this.isSetType();
    boolean that_present_type = true && that.isSetType();
    if (this_present_type || that_present_type) {
      if (!(this_present_type && that_present_type))
        return false;
      if (!this.type.equals(that.type))
        return false;
    }

    boolean this_present_type_length = true && this.isSetType_length();
    boolean that_present_type_length = true && that.isSetType_length();
    if (this_present_type_length || that_present_type_length) {
      if (!(this_present_type_length && that_present_type_length))
        return false;
      if (this.type_length != that.type_length)
        return false;
    }

    boolean this_present_repetition_type = true && this.isSetRepetition_type();
    boolean that_present_repetition_type = true && that.isSetRepetition_type();
    if (this_present_repetition_type || that_present_repetition_type) {
      if (!(this_present_repetition_type && that_present_repetition_type))
        return false;
      if (!this.repetition_type.equals(that.repetition_type))
        return false;
    }

    boolean this_present_name = true && this.isSetName();
    boolean that_present_name = true && that.isSetName();
    if (this_present_name || that_present_name) {
      if (!(this_present_name && that_present_name))
        return false;
      if (!this.name.equals(that.name))
        return false;
    }

    boolean this_present_num_children = true && this.isSetNum_children();
    boolean that_present_num_children = true && that.isSetNum_children();
    if (this_present_num_children || that_present_num_children) {
      if (!(this_present_num_children && that_present_num_children))
        return false;
      if (this.num_children != that.num_children)
        return false;
    }

    boolean this_present_converted_type = true && this.isSetConverted_type();
    boolean that_present_converted_type = true && that.isSetConverted_type();
    if (this_present_converted_type || that_present_converted_type) {
      if (!(this_present_converted_type && that_present_converted_type))
        return false;
      if (!this.converted_type.equals(that.converted_type))
        return false;
    }

    boolean this_present_scale = true && this.isSetScale();
    boolean that_present_scale = true && that.isSetScale();
    if (this_present_scale || that_present_scale) {
      if (!(this_present_scale && that_present_scale))
        return false;
      if (this.scale != that.scale)
        return false;
    }

    boolean this_present_precision = true && this.isSetPrecision();
    boolean that_present_precision = true && that.isSetPrecision();
    if (this_present_precision || that_present_precision) {
      if (!(this_present_precision && that_present_precision))
        return false;
      if (this.precision != that.precision)
        return false;
    }

    boolean this_present_field_id = true && this.isSetField_id();
    boolean that_present_field_id = true && that.isSetField_id();
    if (this_present_field_id || that_present_field_id) {
      if (!(this_present_field_id && that_present_field_id))
        return false;
      if (this.field_id != that.field_id)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();

    boolean present_type = true && (isSetType());
    builder.append(present_type);
    if (present_type)
      builder.append(type.getValue());

    boolean present_type_length = true && (isSetType_length());
    builder.append(present_type_length);
    if (present_type_length)
      builder.append(type_length);

    boolean present_repetition_type = true && (isSetRepetition_type());
    builder.append(present_repetition_type);
    if (present_repetition_type)
      builder.append(repetition_type.getValue());

    boolean present_name = true && (isSetName());
    builder.append(present_name);
    if (present_name)
      builder.append(name);

    boolean present_num_children = true && (isSetNum_children());
    builder.append(present_num_children);
    if (present_num_children)
      builder.append(num_children);

    boolean present_converted_type = true && (isSetConverted_type());
    builder.append(present_converted_type);
    if (present_converted_type)
      builder.append(converted_type.getValue());

    boolean present_scale = true && (isSetScale());
    builder.append(present_scale);
    if (present_scale)
      builder.append(scale);

    boolean present_precision = true && (isSetPrecision());
    builder.append(present_precision);
    if (present_precision)
      builder.append(precision);

    boolean present_field_id = true && (isSetField_id());
    builder.append(present_field_id);
    if (present_field_id)
      builder.append(field_id);

    return builder.toHashCode();
  }

  public int compareTo(SchemaElement other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    SchemaElement typedOther = (SchemaElement)other;

    lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = TBaseHelper.compareTo(this.type, typedOther.type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetType_length()).compareTo(typedOther.isSetType_length());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType_length()) {
      lastComparison = TBaseHelper.compareTo(this.type_length, typedOther.type_length);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRepetition_type()).compareTo(typedOther.isSetRepetition_type());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRepetition_type()) {
      lastComparison = TBaseHelper.compareTo(this.repetition_type, typedOther.repetition_type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetName()) {
      lastComparison = TBaseHelper.compareTo(this.name, typedOther.name);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNum_children()).compareTo(typedOther.isSetNum_children());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_children()) {
      lastComparison = TBaseHelper.compareTo(this.num_children, typedOther.num_children);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetConverted_type()).compareTo(typedOther.isSetConverted_type());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetConverted_type()) {
      lastComparison = TBaseHelper.compareTo(this.converted_type, typedOther.converted_type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetScale()).compareTo(typedOther.isSetScale());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetScale()) {
      lastComparison = TBaseHelper.compareTo(this.scale, typedOther.scale);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPrecision()).compareTo(typedOther.isSetPrecision());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrecision()) {
      lastComparison = TBaseHelper.compareTo(this.precision, typedOther.precision);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetField_id()).compareTo(typedOther.isSetField_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetField_id()) {
      lastComparison = TBaseHelper.compareTo(this.field_id, typedOther.field_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      switch (field.id) {
        case 1: // TYPE
          if (field.type == TType.I32) {
            this.type = Type.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // TYPE_LENGTH
          if (field.type == TType.I32) {
            this.type_length = iprot.readI32();
            setType_lengthIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // REPETITION_TYPE
          if (field.type == TType.I32) {
            this.repetition_type = FieldRepetitionType.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // NAME
          if (field.type == TType.STRING) {
            this.name = iprot.readString();
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // NUM_CHILDREN
          if (field.type == TType.I32) {
            this.num_children = iprot.readI32();
            setNum_childrenIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 6: // CONVERTED_TYPE
          if (field.type == TType.I32) {
            this.converted_type = ConvertedType.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 7: // SCALE
          if (field.type == TType.I32) {
            this.scale = iprot.readI32();
            setScaleIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 8: // PRECISION
          if (field.type == TType.I32) {
            this.precision = iprot.readI32();
            setPrecisionIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 9: // FIELD_ID
          if (field.type == TType.I32) {
            this.field_id = iprot.readI32();
            setField_idIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.type != null) {
      if (isSetType()) {
        oprot.writeFieldBegin(TYPE_FIELD_DESC);
        oprot.writeI32(this.type.getValue());
        oprot.writeFieldEnd();
      }
    }
    if (isSetType_length()) {
      oprot.writeFieldBegin(TYPE_LENGTH_FIELD_DESC);
      oprot.writeI32(this.type_length);
      oprot.writeFieldEnd();
    }
    if (this.repetition_type != null) {
      if (isSetRepetition_type()) {
        oprot.writeFieldBegin(REPETITION_TYPE_FIELD_DESC);
        oprot.writeI32(this.repetition_type.getValue());
        oprot.writeFieldEnd();
      }
    }
    if (this.name != null) {
      oprot.writeFieldBegin(NAME_FIELD_DESC);
      oprot.writeString(this.name);
      oprot.writeFieldEnd();
    }
    if (isSetNum_children()) {
      oprot.writeFieldBegin(NUM_CHILDREN_FIELD_DESC);
      oprot.writeI32(this.num_children);
      oprot.writeFieldEnd();
    }
    if (this.converted_type != null) {
      if (isSetConverted_type()) {
        oprot.writeFieldBegin(CONVERTED_TYPE_FIELD_DESC);
        oprot.writeI32(this.converted_type.getValue());
        oprot.writeFieldEnd();
      }
    }
    if (isSetScale()) {
      oprot.writeFieldBegin(SCALE_FIELD_DESC);
      oprot.writeI32(this.scale);
      oprot.writeFieldEnd();
    }
    if (isSetPrecision()) {
      oprot.writeFieldBegin(PRECISION_FIELD_DESC);
      oprot.writeI32(this.precision);
      oprot.writeFieldEnd();
    }
    if (isSetField_id()) {
      oprot.writeFieldBegin(FIELD_ID_FIELD_DESC);
      oprot.writeI32(this.field_id);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("SchemaElement(");
    boolean first = true;

    if (isSetType()) {
      sb.append("type:");
      if (this.type == null) {
        sb.append("null");
      } else {
        sb.append(this.type);
      }
      first = false;
    }
    if (isSetType_length()) {
      if (!first) sb.append(", ");
      sb.append("type_length:");
      sb.append(this.type_length);
      first = false;
    }
    if (isSetRepetition_type()) {
      if (!first) sb.append(", ");
      sb.append("repetition_type:");
      if (this.repetition_type == null) {
        sb.append("null");
      } else {
        sb.append(this.repetition_type);
      }
      first = false;
    }
    if (!first) sb.append(", ");
    sb.append("name:");
    if (this.name == null) {
      sb.append("null");
    } else {
      sb.append(this.name);
    }
    first = false;
    if (isSetNum_children()) {
      if (!first) sb.append(", ");
      sb.append("num_children:");
      sb.append(this.num_children);
      first = false;
    }
    if (isSetConverted_type()) {
      if (!first) sb.append(", ");
      sb.append("converted_type:");
      if (this.converted_type == null) {
        sb.append("null");
      } else {
        sb.append(this.converted_type);
      }
      first = false;
    }
    if (isSetScale()) {
      if (!first) sb.append(", ");
      sb.append("scale:");
      sb.append(this.scale);
      first = false;
    }
    if (isSetPrecision()) {
      if (!first) sb.append(", ");
      sb.append("precision:");
      sb.append(this.precision);
      first = false;
    }
    if (isSetField_id()) {
      if (!first) sb.append(", ");
      sb.append("field_id:");
      sb.append(this.field_id);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
    if (name == null) {
      throw new TProtocolException("Required field 'name' was not present! Struct: " + toString());
    }
  }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy