TExternalSearchRequest.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-08-05")
public class TExternalSearchRequest implements org.apache.thrift.TBase<TExternalSearchRequest, TExternalSearchRequest._Fields>, java.io.Serializable, Cloneable, Comparable<TExternalSearchRequest> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TExternalSearchRequest");

  private static final org.apache.thrift.protocol.TField SCHEMA_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("schema_version", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("query", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField FILTER_FIELD_DESC = new org.apache.thrift.protocol.TField("filter", org.apache.thrift.protocol.TType.STRUCT, (short)3);
  private static final org.apache.thrift.protocol.TField LANCE_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("lance_options", org.apache.thrift.protocol.TType.STRUCT, (short)4);

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

  public int schema_version; // optional
  public @org.apache.thrift.annotation.Nullable TExternalSearchQuery query; // optional
  public @org.apache.thrift.annotation.Nullable TSearchFilter filter; // optional
  public @org.apache.thrift.annotation.Nullable TLanceVectorSearchOptions lance_options; // 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_VERSION((short)1, "schema_version"),
    QUERY((short)2, "query"),
    FILTER((short)3, "filter"),
    LANCE_OPTIONS((short)4, "lance_options");

    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_VERSION
          return SCHEMA_VERSION;
        case 2: // QUERY
          return QUERY;
        case 3: // FILTER
          return FILTER;
        case 4: // LANCE_OPTIONS
          return LANCE_OPTIONS;
        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_VERSION_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.SCHEMA_VERSION,_Fields.QUERY,_Fields.FILTER,_Fields.LANCE_OPTIONS};
  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_VERSION, new org.apache.thrift.meta_data.FieldMetaData("schema_version", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.QUERY, new org.apache.thrift.meta_data.FieldMetaData("query", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TExternalSearchQuery.class)));
    tmpMap.put(_Fields.FILTER, new org.apache.thrift.meta_data.FieldMetaData("filter", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSearchFilter.class)));
    tmpMap.put(_Fields.LANCE_OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("lance_options", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TLanceVectorSearchOptions.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TExternalSearchRequest.class, metaDataMap);
  }

  public TExternalSearchRequest() {
    this.schema_version = 1;

  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TExternalSearchRequest(TExternalSearchRequest other) {
    __isset_bitfield = other.__isset_bitfield;
    this.schema_version = other.schema_version;
    if (other.isSetQuery()) {
      this.query = new TExternalSearchQuery(other.query);
    }
    if (other.isSetFilter()) {
      this.filter = new TSearchFilter(other.filter);
    }
    if (other.isSetLanceOptions()) {
      this.lance_options = new TLanceVectorSearchOptions(other.lance_options);
    }
  }

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

  @Override
  public void clear() {
    this.schema_version = 1;

    this.query = null;
    this.filter = null;
    this.lance_options = null;
  }

  public int getSchemaVersion() {
    return this.schema_version;
  }

  public TExternalSearchRequest setSchemaVersion(int schema_version) {
    this.schema_version = schema_version;
    setSchemaVersionIsSet(true);
    return this;
  }

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

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

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

  @org.apache.thrift.annotation.Nullable
  public TExternalSearchQuery getQuery() {
    return this.query;
  }

  public TExternalSearchRequest setQuery(@org.apache.thrift.annotation.Nullable TExternalSearchQuery query) {
    this.query = query;
    return this;
  }

  public void unsetQuery() {
    this.query = null;
  }

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

  public void setQueryIsSet(boolean value) {
    if (!value) {
      this.query = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TSearchFilter getFilter() {
    return this.filter;
  }

  public TExternalSearchRequest setFilter(@org.apache.thrift.annotation.Nullable TSearchFilter filter) {
    this.filter = filter;
    return this;
  }

  public void unsetFilter() {
    this.filter = null;
  }

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

  public void setFilterIsSet(boolean value) {
    if (!value) {
      this.filter = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TLanceVectorSearchOptions getLanceOptions() {
    return this.lance_options;
  }

  public TExternalSearchRequest setLanceOptions(@org.apache.thrift.annotation.Nullable TLanceVectorSearchOptions lance_options) {
    this.lance_options = lance_options;
    return this;
  }

  public void unsetLanceOptions() {
    this.lance_options = null;
  }

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

  public void setLanceOptionsIsSet(boolean value) {
    if (!value) {
      this.lance_options = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case SCHEMA_VERSION:
      if (value == null) {
        unsetSchemaVersion();
      } else {
        setSchemaVersion((java.lang.Integer)value);
      }
      break;

    case QUERY:
      if (value == null) {
        unsetQuery();
      } else {
        setQuery((TExternalSearchQuery)value);
      }
      break;

    case FILTER:
      if (value == null) {
        unsetFilter();
      } else {
        setFilter((TSearchFilter)value);
      }
      break;

    case LANCE_OPTIONS:
      if (value == null) {
        unsetLanceOptions();
      } else {
        setLanceOptions((TLanceVectorSearchOptions)value);
      }
      break;

    }
  }

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

    case QUERY:
      return getQuery();

    case FILTER:
      return getFilter();

    case LANCE_OPTIONS:
      return getLanceOptions();

    }
    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_VERSION:
      return isSetSchemaVersion();
    case QUERY:
      return isSetQuery();
    case FILTER:
      return isSetFilter();
    case LANCE_OPTIONS:
      return isSetLanceOptions();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_schema_version = true && this.isSetSchemaVersion();
    boolean that_present_schema_version = true && that.isSetSchemaVersion();
    if (this_present_schema_version || that_present_schema_version) {
      if (!(this_present_schema_version && that_present_schema_version))
        return false;
      if (this.schema_version != that.schema_version)
        return false;
    }

    boolean this_present_query = true && this.isSetQuery();
    boolean that_present_query = true && that.isSetQuery();
    if (this_present_query || that_present_query) {
      if (!(this_present_query && that_present_query))
        return false;
      if (!this.query.equals(that.query))
        return false;
    }

    boolean this_present_filter = true && this.isSetFilter();
    boolean that_present_filter = true && that.isSetFilter();
    if (this_present_filter || that_present_filter) {
      if (!(this_present_filter && that_present_filter))
        return false;
      if (!this.filter.equals(that.filter))
        return false;
    }

    boolean this_present_lance_options = true && this.isSetLanceOptions();
    boolean that_present_lance_options = true && that.isSetLanceOptions();
    if (this_present_lance_options || that_present_lance_options) {
      if (!(this_present_lance_options && that_present_lance_options))
        return false;
      if (!this.lance_options.equals(that.lance_options))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetSchemaVersion()) ? 131071 : 524287);
    if (isSetSchemaVersion())
      hashCode = hashCode * 8191 + schema_version;

    hashCode = hashCode * 8191 + ((isSetQuery()) ? 131071 : 524287);
    if (isSetQuery())
      hashCode = hashCode * 8191 + query.hashCode();

    hashCode = hashCode * 8191 + ((isSetFilter()) ? 131071 : 524287);
    if (isSetFilter())
      hashCode = hashCode * 8191 + filter.hashCode();

    hashCode = hashCode * 8191 + ((isSetLanceOptions()) ? 131071 : 524287);
    if (isSetLanceOptions())
      hashCode = hashCode * 8191 + lance_options.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetSchemaVersion(), other.isSetSchemaVersion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSchemaVersion()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schema_version, other.schema_version);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetQuery(), other.isSetQuery());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQuery()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.query, other.query);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFilter(), other.isSetFilter());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFilter()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filter, other.filter);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetLanceOptions(), other.isSetLanceOptions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLanceOptions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lance_options, other.lance_options);
      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("TExternalSearchRequest(");
    boolean first = true;

    if (isSetSchemaVersion()) {
      sb.append("schema_version:");
      sb.append(this.schema_version);
      first = false;
    }
    if (isSetQuery()) {
      if (!first) sb.append(", ");
      sb.append("query:");
      if (this.query == null) {
        sb.append("null");
      } else {
        sb.append(this.query);
      }
      first = false;
    }
    if (isSetFilter()) {
      if (!first) sb.append(", ");
      sb.append("filter:");
      if (this.filter == null) {
        sb.append("null");
      } else {
        sb.append(this.filter);
      }
      first = false;
    }
    if (isSetLanceOptions()) {
      if (!first) sb.append(", ");
      sb.append("lance_options:");
      if (this.lance_options == null) {
        sb.append("null");
      } else {
        sb.append(this.lance_options);
      }
      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 (filter != null) {
      filter.validate();
    }
    if (lance_options != null) {
      lance_options.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 TExternalSearchRequestStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TExternalSearchRequestStandardScheme getScheme() {
      return new TExternalSearchRequestStandardScheme();
    }
  }

  private static class TExternalSearchRequestStandardScheme extends org.apache.thrift.scheme.StandardScheme<TExternalSearchRequest> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TExternalSearchRequest 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_VERSION
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.schema_version = iprot.readI32();
              struct.setSchemaVersionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // QUERY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.query = new TExternalSearchQuery();
              struct.query.read(iprot);
              struct.setQueryIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // FILTER
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.filter = new TSearchFilter();
              struct.filter.read(iprot);
              struct.setFilterIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // LANCE_OPTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.lance_options = new TLanceVectorSearchOptions();
              struct.lance_options.read(iprot);
              struct.setLanceOptionsIsSet(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, TExternalSearchRequest struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.isSetSchemaVersion()) {
        oprot.writeFieldBegin(SCHEMA_VERSION_FIELD_DESC);
        oprot.writeI32(struct.schema_version);
        oprot.writeFieldEnd();
      }
      if (struct.query != null) {
        if (struct.isSetQuery()) {
          oprot.writeFieldBegin(QUERY_FIELD_DESC);
          struct.query.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.filter != null) {
        if (struct.isSetFilter()) {
          oprot.writeFieldBegin(FILTER_FIELD_DESC);
          struct.filter.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.lance_options != null) {
        if (struct.isSetLanceOptions()) {
          oprot.writeFieldBegin(LANCE_OPTIONS_FIELD_DESC);
          struct.lance_options.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TExternalSearchRequestTupleScheme extends org.apache.thrift.scheme.TupleScheme<TExternalSearchRequest> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TExternalSearchRequest 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.isSetSchemaVersion()) {
        optionals.set(0);
      }
      if (struct.isSetQuery()) {
        optionals.set(1);
      }
      if (struct.isSetFilter()) {
        optionals.set(2);
      }
      if (struct.isSetLanceOptions()) {
        optionals.set(3);
      }
      oprot.writeBitSet(optionals, 4);
      if (struct.isSetSchemaVersion()) {
        oprot.writeI32(struct.schema_version);
      }
      if (struct.isSetQuery()) {
        struct.query.write(oprot);
      }
      if (struct.isSetFilter()) {
        struct.filter.write(oprot);
      }
      if (struct.isSetLanceOptions()) {
        struct.lance_options.write(oprot);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TExternalSearchRequest struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(4);
      if (incoming.get(0)) {
        struct.schema_version = iprot.readI32();
        struct.setSchemaVersionIsSet(true);
      }
      if (incoming.get(1)) {
        struct.query = new TExternalSearchQuery();
        struct.query.read(iprot);
        struct.setQueryIsSet(true);
      }
      if (incoming.get(2)) {
        struct.filter = new TSearchFilter();
        struct.filter.read(iprot);
        struct.setFilterIsSet(true);
      }
      if (incoming.get(3)) {
        struct.lance_options = new TLanceVectorSearchOptions();
        struct.lance_options.read(iprot);
        struct.setLanceOptionsIsSet(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();
  }
}