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

  private static final org.apache.thrift.protocol.TField ELEMENT_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("element_type", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField DIMENSION_FIELD_DESC = new org.apache.thrift.protocol.TField("dimension", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("values", org.apache.thrift.protocol.TType.STRING, (short)3);

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

  /**
   * 
   * @see TVectorElementType
   */
  public @org.apache.thrift.annotation.Nullable TVectorElementType element_type; // optional
  public int dimension; // optional
  public @org.apache.thrift.annotation.Nullable java.nio.ByteBuffer values; // 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 TVectorElementType
     */
    ELEMENT_TYPE((short)1, "element_type"),
    DIMENSION((short)2, "dimension"),
    VALUES((short)3, "values");

    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: // ELEMENT_TYPE
          return ELEMENT_TYPE;
        case 2: // DIMENSION
          return DIMENSION;
        case 3: // VALUES
          return VALUES;
        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 __DIMENSION_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.ELEMENT_TYPE,_Fields.DIMENSION,_Fields.VALUES};
  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.ELEMENT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("element_type", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TVectorElementType.class)));
    tmpMap.put(_Fields.DIMENSION, new org.apache.thrift.meta_data.FieldMetaData("dimension", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.VALUES, new org.apache.thrift.meta_data.FieldMetaData("values", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSearchVector.class, metaDataMap);
  }

  public TSearchVector() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TSearchVector(TSearchVector other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetElementType()) {
      this.element_type = other.element_type;
    }
    this.dimension = other.dimension;
    if (other.isSetValues()) {
      this.values = org.apache.thrift.TBaseHelper.copyBinary(other.values);
    }
  }

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

  @Override
  public void clear() {
    this.element_type = null;
    setDimensionIsSet(false);
    this.dimension = 0;
    this.values = null;
  }

  /**
   * 
   * @see TVectorElementType
   */
  @org.apache.thrift.annotation.Nullable
  public TVectorElementType getElementType() {
    return this.element_type;
  }

  /**
   * 
   * @see TVectorElementType
   */
  public TSearchVector setElementType(@org.apache.thrift.annotation.Nullable TVectorElementType element_type) {
    this.element_type = element_type;
    return this;
  }

  public void unsetElementType() {
    this.element_type = null;
  }

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

  public void setElementTypeIsSet(boolean value) {
    if (!value) {
      this.element_type = null;
    }
  }

  public int getDimension() {
    return this.dimension;
  }

  public TSearchVector setDimension(int dimension) {
    this.dimension = dimension;
    setDimensionIsSet(true);
    return this;
  }

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

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

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

  public byte[] getValues() {
    setValues(org.apache.thrift.TBaseHelper.rightSize(values));
    return values == null ? null : values.array();
  }

  public java.nio.ByteBuffer bufferForValues() {
    return org.apache.thrift.TBaseHelper.copyBinary(values);
  }

  public TSearchVector setValues(byte[] values) {
    this.values = values == null ? (java.nio.ByteBuffer)null   : java.nio.ByteBuffer.wrap(values.clone());
    return this;
  }

  public TSearchVector setValues(@org.apache.thrift.annotation.Nullable java.nio.ByteBuffer values) {
    this.values = org.apache.thrift.TBaseHelper.copyBinary(values);
    return this;
  }

  public void unsetValues() {
    this.values = null;
  }

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

  public void setValuesIsSet(boolean value) {
    if (!value) {
      this.values = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case ELEMENT_TYPE:
      if (value == null) {
        unsetElementType();
      } else {
        setElementType((TVectorElementType)value);
      }
      break;

    case DIMENSION:
      if (value == null) {
        unsetDimension();
      } else {
        setDimension((java.lang.Integer)value);
      }
      break;

    case VALUES:
      if (value == null) {
        unsetValues();
      } else {
        if (value instanceof byte[]) {
          setValues((byte[])value);
        } else {
          setValues((java.nio.ByteBuffer)value);
        }
      }
      break;

    }
  }

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

    case DIMENSION:
      return getDimension();

    case VALUES:
      return getValues();

    }
    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 ELEMENT_TYPE:
      return isSetElementType();
    case DIMENSION:
      return isSetDimension();
    case VALUES:
      return isSetValues();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_element_type = true && this.isSetElementType();
    boolean that_present_element_type = true && that.isSetElementType();
    if (this_present_element_type || that_present_element_type) {
      if (!(this_present_element_type && that_present_element_type))
        return false;
      if (!this.element_type.equals(that.element_type))
        return false;
    }

    boolean this_present_dimension = true && this.isSetDimension();
    boolean that_present_dimension = true && that.isSetDimension();
    if (this_present_dimension || that_present_dimension) {
      if (!(this_present_dimension && that_present_dimension))
        return false;
      if (this.dimension != that.dimension)
        return false;
    }

    boolean this_present_values = true && this.isSetValues();
    boolean that_present_values = true && that.isSetValues();
    if (this_present_values || that_present_values) {
      if (!(this_present_values && that_present_values))
        return false;
      if (!this.values.equals(that.values))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetElementType()) ? 131071 : 524287);
    if (isSetElementType())
      hashCode = hashCode * 8191 + element_type.getValue();

    hashCode = hashCode * 8191 + ((isSetDimension()) ? 131071 : 524287);
    if (isSetDimension())
      hashCode = hashCode * 8191 + dimension;

    hashCode = hashCode * 8191 + ((isSetValues()) ? 131071 : 524287);
    if (isSetValues())
      hashCode = hashCode * 8191 + values.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetElementType(), other.isSetElementType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetElementType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.element_type, other.element_type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetDimension(), other.isSetDimension());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDimension()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dimension, other.dimension);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetValues(), other.isSetValues());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetValues()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.values, other.values);
      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("TSearchVector(");
    boolean first = true;

    if (isSetElementType()) {
      sb.append("element_type:");
      if (this.element_type == null) {
        sb.append("null");
      } else {
        sb.append(this.element_type);
      }
      first = false;
    }
    if (isSetDimension()) {
      if (!first) sb.append(", ");
      sb.append("dimension:");
      sb.append(this.dimension);
      first = false;
    }
    if (isSetValues()) {
      if (!first) sb.append(", ");
      sb.append("values:");
      if (this.values == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.values, sb);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
  }

  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 TSearchVectorStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TSearchVectorStandardScheme getScheme() {
      return new TSearchVectorStandardScheme();
    }
  }

  private static class TSearchVectorStandardScheme extends org.apache.thrift.scheme.StandardScheme<TSearchVector> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TSearchVector 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: // ELEMENT_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.element_type = org.apache.doris.thrift.TVectorElementType.findByValue(iprot.readI32());
              struct.setElementTypeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // DIMENSION
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.dimension = iprot.readI32();
              struct.setDimensionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // VALUES
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.values = iprot.readBinary();
              struct.setValuesIsSet(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, TSearchVector struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.element_type != null) {
        if (struct.isSetElementType()) {
          oprot.writeFieldBegin(ELEMENT_TYPE_FIELD_DESC);
          oprot.writeI32(struct.element_type.getValue());
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetDimension()) {
        oprot.writeFieldBegin(DIMENSION_FIELD_DESC);
        oprot.writeI32(struct.dimension);
        oprot.writeFieldEnd();
      }
      if (struct.values != null) {
        if (struct.isSetValues()) {
          oprot.writeFieldBegin(VALUES_FIELD_DESC);
          oprot.writeBinary(struct.values);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TSearchVectorTupleScheme extends org.apache.thrift.scheme.TupleScheme<TSearchVector> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TSearchVector 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.isSetElementType()) {
        optionals.set(0);
      }
      if (struct.isSetDimension()) {
        optionals.set(1);
      }
      if (struct.isSetValues()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetElementType()) {
        oprot.writeI32(struct.element_type.getValue());
      }
      if (struct.isSetDimension()) {
        oprot.writeI32(struct.dimension);
      }
      if (struct.isSetValues()) {
        oprot.writeBinary(struct.values);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TSearchVector 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.element_type = org.apache.doris.thrift.TVectorElementType.findByValue(iprot.readI32());
        struct.setElementTypeIsSet(true);
      }
      if (incoming.get(1)) {
        struct.dimension = iprot.readI32();
        struct.setDimensionIsSet(true);
      }
      if (incoming.get(2)) {
        struct.values = iprot.readBinary();
        struct.setValuesIsSet(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();
  }
}