TSchema.java

/**
 * Autogenerated by Thrift Compiler (0.16.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.doris.thrift.schema.external;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.16.0)", date = "2026-05-14")
public class TSchema implements org.apache.thrift.TBase<TSchema, TSchema._Fields>, java.io.Serializable, Cloneable, Comparable<TSchema> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSchema");

  private static final org.apache.thrift.protocol.TField SCHEMA_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("schema_id", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField ROOT_FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField("root_field", org.apache.thrift.protocol.TType.STRUCT, (short)2);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TSchemaStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TSchemaTupleSchemeFactory();

  public long schema_id; // optional
  public @org.apache.thrift.annotation.Nullable TStructField root_field; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    SCHEMA_ID((short)1, "schema_id"),
    ROOT_FIELD((short)2, "root_field");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

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

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // SCHEMA_ID
          return SCHEMA_ID;
        case 2: // ROOT_FIELD
          return ROOT_FIELD;
        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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

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

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __SCHEMA_ID_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.SCHEMA_ID,_Fields.ROOT_FIELD};
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.SCHEMA_ID, new org.apache.thrift.meta_data.FieldMetaData("schema_id", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.ROOT_FIELD, new org.apache.thrift.meta_data.FieldMetaData("root_field", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TStructField.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSchema.class, metaDataMap);
  }

  public TSchema() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TSchema(TSchema other) {
    __isset_bitfield = other.__isset_bitfield;
    this.schema_id = other.schema_id;
    if (other.isSetRootField()) {
      this.root_field = new TStructField(other.root_field);
    }
  }

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

  @Override
  public void clear() {
    setSchemaIdIsSet(false);
    this.schema_id = 0;
    this.root_field = null;
  }

  public long getSchemaId() {
    return this.schema_id;
  }

  public TSchema setSchemaId(long schema_id) {
    this.schema_id = schema_id;
    setSchemaIdIsSet(true);
    return this;
  }

  public void unsetSchemaId() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SCHEMA_ID_ISSET_ID);
  }

  /** Returns true if field schema_id is set (has been assigned a value) and false otherwise */
  public boolean isSetSchemaId() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SCHEMA_ID_ISSET_ID);
  }

  public void setSchemaIdIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SCHEMA_ID_ISSET_ID, value);
  }

  @org.apache.thrift.annotation.Nullable
  public TStructField getRootField() {
    return this.root_field;
  }

  public TSchema setRootField(@org.apache.thrift.annotation.Nullable TStructField root_field) {
    this.root_field = root_field;
    return this;
  }

  public void unsetRootField() {
    this.root_field = null;
  }

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

  public void setRootFieldIsSet(boolean value) {
    if (!value) {
      this.root_field = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case SCHEMA_ID:
      if (value == null) {
        unsetSchemaId();
      } else {
        setSchemaId((java.lang.Long)value);
      }
      break;

    case ROOT_FIELD:
      if (value == null) {
        unsetRootField();
      } else {
        setRootField((TStructField)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case SCHEMA_ID:
      return getSchemaId();

    case ROOT_FIELD:
      return getRootField();

    }
    throw new java.lang.IllegalStateException();
  }

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

    switch (field) {
    case SCHEMA_ID:
      return isSetSchemaId();
    case ROOT_FIELD:
      return isSetRootField();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof TSchema)
      return this.equals((TSchema)that);
    return false;
  }

  public boolean equals(TSchema that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_schema_id = true && this.isSetSchemaId();
    boolean that_present_schema_id = true && that.isSetSchemaId();
    if (this_present_schema_id || that_present_schema_id) {
      if (!(this_present_schema_id && that_present_schema_id))
        return false;
      if (this.schema_id != that.schema_id)
        return false;
    }

    boolean this_present_root_field = true && this.isSetRootField();
    boolean that_present_root_field = true && that.isSetRootField();
    if (this_present_root_field || that_present_root_field) {
      if (!(this_present_root_field && that_present_root_field))
        return false;
      if (!this.root_field.equals(that.root_field))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetSchemaId()) ? 131071 : 524287);
    if (isSetSchemaId())
      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(schema_id);

    hashCode = hashCode * 8191 + ((isSetRootField()) ? 131071 : 524287);
    if (isSetRootField())
      hashCode = hashCode * 8191 + root_field.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetSchemaId(), other.isSetSchemaId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSchemaId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schema_id, other.schema_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetRootField(), other.isSetRootField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRootField()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.root_field, other.root_field);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("TSchema(");
    boolean first = true;

    if (isSetSchemaId()) {
      sb.append("schema_id:");
      sb.append(this.schema_id);
      first = false;
    }
    if (isSetRootField()) {
      if (!first) sb.append(", ");
      sb.append("root_field:");
      if (this.root_field == null) {
        sb.append("null");
      } else {
        sb.append(this.root_field);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (root_field != null) {
      root_field.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class TSchemaStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TSchemaStandardScheme getScheme() {
      return new TSchemaStandardScheme();
    }
  }

  private static class TSchemaStandardScheme extends org.apache.thrift.scheme.StandardScheme<TSchema> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TSchema struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // SCHEMA_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.schema_id = iprot.readI64();
              struct.setSchemaIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // ROOT_FIELD
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.root_field = new TStructField();
              struct.root_field.read(iprot);
              struct.setRootFieldIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

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

    public void write(org.apache.thrift.protocol.TProtocol oprot, TSchema struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.isSetSchemaId()) {
        oprot.writeFieldBegin(SCHEMA_ID_FIELD_DESC);
        oprot.writeI64(struct.schema_id);
        oprot.writeFieldEnd();
      }
      if (struct.root_field != null) {
        if (struct.isSetRootField()) {
          oprot.writeFieldBegin(ROOT_FIELD_FIELD_DESC);
          struct.root_field.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TSchemaTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TSchemaTupleScheme getScheme() {
      return new TSchemaTupleScheme();
    }
  }

  private static class TSchemaTupleScheme extends org.apache.thrift.scheme.TupleScheme<TSchema> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TSchema struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetSchemaId()) {
        optionals.set(0);
      }
      if (struct.isSetRootField()) {
        optionals.set(1);
      }
      oprot.writeBitSet(optionals, 2);
      if (struct.isSetSchemaId()) {
        oprot.writeI64(struct.schema_id);
      }
      if (struct.isSetRootField()) {
        struct.root_field.write(oprot);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TSchema struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(2);
      if (incoming.get(0)) {
        struct.schema_id = iprot.readI64();
        struct.setSchemaIdIsSet(true);
      }
      if (incoming.get(1)) {
        struct.root_field = new TStructField();
        struct.root_field.read(iprot);
        struct.setRootFieldIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}