TResultSink.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;

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

  private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField FILE_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("file_options", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField FETCH_OPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("fetch_option", org.apache.thrift.protocol.TType.STRUCT, (short)3);

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

  /**
   * 
   * @see TResultSinkType
   */
  public @org.apache.thrift.annotation.Nullable TResultSinkType type; // optional
  public @org.apache.thrift.annotation.Nullable TResultFileSinkOptions file_options; // optional
  public @org.apache.thrift.annotation.Nullable TFetchOption fetch_option; // 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 {
    /**
     * 
     * @see TResultSinkType
     */
    TYPE((short)1, "type"),
    FILE_OPTIONS((short)2, "file_options"),
    FETCH_OPTION((short)3, "fetch_option");

    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: // TYPE
          return TYPE;
        case 2: // FILE_OPTIONS
          return FILE_OPTIONS;
        case 3: // FETCH_OPTION
          return FETCH_OPTION;
        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 _Fields optionals[] = {_Fields.TYPE,_Fields.FILE_OPTIONS,_Fields.FETCH_OPTION};
  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.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TResultSinkType.class)));
    tmpMap.put(_Fields.FILE_OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("file_options", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TResultFileSinkOptions.class)));
    tmpMap.put(_Fields.FETCH_OPTION, new org.apache.thrift.meta_data.FieldMetaData("fetch_option", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TFetchOption.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TResultSink.class, metaDataMap);
  }

  public TResultSink() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TResultSink(TResultSink other) {
    if (other.isSetType()) {
      this.type = other.type;
    }
    if (other.isSetFileOptions()) {
      this.file_options = new TResultFileSinkOptions(other.file_options);
    }
    if (other.isSetFetchOption()) {
      this.fetch_option = new TFetchOption(other.fetch_option);
    }
  }

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

  @Override
  public void clear() {
    this.type = null;
    this.file_options = null;
    this.fetch_option = null;
  }

  /**
   * 
   * @see TResultSinkType
   */
  @org.apache.thrift.annotation.Nullable
  public TResultSinkType getType() {
    return this.type;
  }

  /**
   * 
   * @see TResultSinkType
   */
  public TResultSink setType(@org.apache.thrift.annotation.Nullable TResultSinkType type) {
    this.type = type;
    return this;
  }

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

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

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

  @org.apache.thrift.annotation.Nullable
  public TResultFileSinkOptions getFileOptions() {
    return this.file_options;
  }

  public TResultSink setFileOptions(@org.apache.thrift.annotation.Nullable TResultFileSinkOptions file_options) {
    this.file_options = file_options;
    return this;
  }

  public void unsetFileOptions() {
    this.file_options = null;
  }

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

  public void setFileOptionsIsSet(boolean value) {
    if (!value) {
      this.file_options = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TFetchOption getFetchOption() {
    return this.fetch_option;
  }

  public TResultSink setFetchOption(@org.apache.thrift.annotation.Nullable TFetchOption fetch_option) {
    this.fetch_option = fetch_option;
    return this;
  }

  public void unsetFetchOption() {
    this.fetch_option = null;
  }

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

  public void setFetchOptionIsSet(boolean value) {
    if (!value) {
      this.fetch_option = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case TYPE:
      if (value == null) {
        unsetType();
      } else {
        setType((TResultSinkType)value);
      }
      break;

    case FILE_OPTIONS:
      if (value == null) {
        unsetFileOptions();
      } else {
        setFileOptions((TResultFileSinkOptions)value);
      }
      break;

    case FETCH_OPTION:
      if (value == null) {
        unsetFetchOption();
      } else {
        setFetchOption((TFetchOption)value);
      }
      break;

    }
  }

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

    case FILE_OPTIONS:
      return getFileOptions();

    case FETCH_OPTION:
      return getFetchOption();

    }
    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 TYPE:
      return isSetType();
    case FILE_OPTIONS:
      return isSetFileOptions();
    case FETCH_OPTION:
      return isSetFetchOption();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    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_file_options = true && this.isSetFileOptions();
    boolean that_present_file_options = true && that.isSetFileOptions();
    if (this_present_file_options || that_present_file_options) {
      if (!(this_present_file_options && that_present_file_options))
        return false;
      if (!this.file_options.equals(that.file_options))
        return false;
    }

    boolean this_present_fetch_option = true && this.isSetFetchOption();
    boolean that_present_fetch_option = true && that.isSetFetchOption();
    if (this_present_fetch_option || that_present_fetch_option) {
      if (!(this_present_fetch_option && that_present_fetch_option))
        return false;
      if (!this.fetch_option.equals(that.fetch_option))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetType()) ? 131071 : 524287);
    if (isSetType())
      hashCode = hashCode * 8191 + type.getValue();

    hashCode = hashCode * 8191 + ((isSetFileOptions()) ? 131071 : 524287);
    if (isSetFileOptions())
      hashCode = hashCode * 8191 + file_options.hashCode();

    hashCode = hashCode * 8191 + ((isSetFetchOption()) ? 131071 : 524287);
    if (isSetFetchOption())
      hashCode = hashCode * 8191 + fetch_option.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetType(), other.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFileOptions(), other.isSetFileOptions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFileOptions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.file_options, other.file_options);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFetchOption(), other.isSetFetchOption());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFetchOption()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fetch_option, other.fetch_option);
      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("TResultSink(");
    boolean first = true;

    if (isSetType()) {
      sb.append("type:");
      if (this.type == null) {
        sb.append("null");
      } else {
        sb.append(this.type);
      }
      first = false;
    }
    if (isSetFileOptions()) {
      if (!first) sb.append(", ");
      sb.append("file_options:");
      if (this.file_options == null) {
        sb.append("null");
      } else {
        sb.append(this.file_options);
      }
      first = false;
    }
    if (isSetFetchOption()) {
      if (!first) sb.append(", ");
      sb.append("fetch_option:");
      if (this.fetch_option == null) {
        sb.append("null");
      } else {
        sb.append(this.fetch_option);
      }
      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 (file_options != null) {
      file_options.validate();
    }
    if (fetch_option != null) {
      fetch_option.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 {
      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 TResultSinkStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TResultSinkStandardScheme getScheme() {
      return new TResultSinkStandardScheme();
    }
  }

  private static class TResultSinkStandardScheme extends org.apache.thrift.scheme.StandardScheme<TResultSink> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TResultSink 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: // TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.type = org.apache.doris.thrift.TResultSinkType.findByValue(iprot.readI32());
              struct.setTypeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // FILE_OPTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.file_options = new TResultFileSinkOptions();
              struct.file_options.read(iprot);
              struct.setFileOptionsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // FETCH_OPTION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.fetch_option = new TFetchOption();
              struct.fetch_option.read(iprot);
              struct.setFetchOptionIsSet(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, TResultSink struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.type != null) {
        if (struct.isSetType()) {
          oprot.writeFieldBegin(TYPE_FIELD_DESC);
          oprot.writeI32(struct.type.getValue());
          oprot.writeFieldEnd();
        }
      }
      if (struct.file_options != null) {
        if (struct.isSetFileOptions()) {
          oprot.writeFieldBegin(FILE_OPTIONS_FIELD_DESC);
          struct.file_options.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.fetch_option != null) {
        if (struct.isSetFetchOption()) {
          oprot.writeFieldBegin(FETCH_OPTION_FIELD_DESC);
          struct.fetch_option.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TResultSinkTupleScheme extends org.apache.thrift.scheme.TupleScheme<TResultSink> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TResultSink 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.isSetType()) {
        optionals.set(0);
      }
      if (struct.isSetFileOptions()) {
        optionals.set(1);
      }
      if (struct.isSetFetchOption()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetType()) {
        oprot.writeI32(struct.type.getValue());
      }
      if (struct.isSetFileOptions()) {
        struct.file_options.write(oprot);
      }
      if (struct.isSetFetchOption()) {
        struct.fetch_option.write(oprot);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TResultSink struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        struct.type = org.apache.doris.thrift.TResultSinkType.findByValue(iprot.readI32());
        struct.setTypeIsSet(true);
      }
      if (incoming.get(1)) {
        struct.file_options = new TResultFileSinkOptions();
        struct.file_options.read(iprot);
        struct.setFileOptionsIsSet(true);
      }
      if (incoming.get(2)) {
        struct.fetch_option = new TFetchOption();
        struct.fetch_option.read(iprot);
        struct.setFetchOptionIsSet(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();
  }
}