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

  private static final org.apache.thrift.protocol.TField BUCKETED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("bucketed_by", org.apache.thrift.protocol.TType.LIST, (short)1);
  private static final org.apache.thrift.protocol.TField BUCKET_MODE_FIELD_DESC = new org.apache.thrift.protocol.TField("bucket_mode", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField BUCKET_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("bucket_count", org.apache.thrift.protocol.TType.I32, (short)3);
  private static final org.apache.thrift.protocol.TField SORTED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("sorted_by", org.apache.thrift.protocol.TType.LIST, (short)4);

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

  public @org.apache.thrift.annotation.Nullable java.util.List<java.lang.String> bucketed_by; // optional
  public @org.apache.thrift.annotation.Nullable TBucketingMode bucket_mode; // optional
  public int bucket_count; // optional
  public @org.apache.thrift.annotation.Nullable java.util.List<TSortedColumn> sorted_by; // 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 {
    BUCKETED_BY((short)1, "bucketed_by"),
    BUCKET_MODE((short)2, "bucket_mode"),
    BUCKET_COUNT((short)3, "bucket_count"),
    SORTED_BY((short)4, "sorted_by");

    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: // BUCKETED_BY
          return BUCKETED_BY;
        case 2: // BUCKET_MODE
          return BUCKET_MODE;
        case 3: // BUCKET_COUNT
          return BUCKET_COUNT;
        case 4: // SORTED_BY
          return SORTED_BY;
        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 __BUCKET_COUNT_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.BUCKETED_BY,_Fields.BUCKET_MODE,_Fields.BUCKET_COUNT,_Fields.SORTED_BY};
  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.BUCKETED_BY, new org.apache.thrift.meta_data.FieldMetaData("bucketed_by", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
    tmpMap.put(_Fields.BUCKET_MODE, new org.apache.thrift.meta_data.FieldMetaData("bucket_mode", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TBucketingMode.class)));
    tmpMap.put(_Fields.BUCKET_COUNT, new org.apache.thrift.meta_data.FieldMetaData("bucket_count", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.SORTED_BY, new org.apache.thrift.meta_data.FieldMetaData("sorted_by", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSortedColumn.class))));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(THiveBucket.class, metaDataMap);
  }

  public THiveBucket() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public THiveBucket(THiveBucket other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetBucketedBy()) {
      java.util.List<java.lang.String> __this__bucketed_by = new java.util.ArrayList<java.lang.String>(other.bucketed_by);
      this.bucketed_by = __this__bucketed_by;
    }
    if (other.isSetBucketMode()) {
      this.bucket_mode = new TBucketingMode(other.bucket_mode);
    }
    this.bucket_count = other.bucket_count;
    if (other.isSetSortedBy()) {
      java.util.List<TSortedColumn> __this__sorted_by = new java.util.ArrayList<TSortedColumn>(other.sorted_by.size());
      for (TSortedColumn other_element : other.sorted_by) {
        __this__sorted_by.add(new TSortedColumn(other_element));
      }
      this.sorted_by = __this__sorted_by;
    }
  }

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

  @Override
  public void clear() {
    this.bucketed_by = null;
    this.bucket_mode = null;
    setBucketCountIsSet(false);
    this.bucket_count = 0;
    this.sorted_by = null;
  }

  public int getBucketedBySize() {
    return (this.bucketed_by == null) ? 0 : this.bucketed_by.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<java.lang.String> getBucketedByIterator() {
    return (this.bucketed_by == null) ? null : this.bucketed_by.iterator();
  }

  public void addToBucketedBy(java.lang.String elem) {
    if (this.bucketed_by == null) {
      this.bucketed_by = new java.util.ArrayList<java.lang.String>();
    }
    this.bucketed_by.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<java.lang.String> getBucketedBy() {
    return this.bucketed_by;
  }

  public THiveBucket setBucketedBy(@org.apache.thrift.annotation.Nullable java.util.List<java.lang.String> bucketed_by) {
    this.bucketed_by = bucketed_by;
    return this;
  }

  public void unsetBucketedBy() {
    this.bucketed_by = null;
  }

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

  public void setBucketedByIsSet(boolean value) {
    if (!value) {
      this.bucketed_by = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TBucketingMode getBucketMode() {
    return this.bucket_mode;
  }

  public THiveBucket setBucketMode(@org.apache.thrift.annotation.Nullable TBucketingMode bucket_mode) {
    this.bucket_mode = bucket_mode;
    return this;
  }

  public void unsetBucketMode() {
    this.bucket_mode = null;
  }

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

  public void setBucketModeIsSet(boolean value) {
    if (!value) {
      this.bucket_mode = null;
    }
  }

  public int getBucketCount() {
    return this.bucket_count;
  }

  public THiveBucket setBucketCount(int bucket_count) {
    this.bucket_count = bucket_count;
    setBucketCountIsSet(true);
    return this;
  }

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

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

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

  public int getSortedBySize() {
    return (this.sorted_by == null) ? 0 : this.sorted_by.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<TSortedColumn> getSortedByIterator() {
    return (this.sorted_by == null) ? null : this.sorted_by.iterator();
  }

  public void addToSortedBy(TSortedColumn elem) {
    if (this.sorted_by == null) {
      this.sorted_by = new java.util.ArrayList<TSortedColumn>();
    }
    this.sorted_by.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<TSortedColumn> getSortedBy() {
    return this.sorted_by;
  }

  public THiveBucket setSortedBy(@org.apache.thrift.annotation.Nullable java.util.List<TSortedColumn> sorted_by) {
    this.sorted_by = sorted_by;
    return this;
  }

  public void unsetSortedBy() {
    this.sorted_by = null;
  }

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

  public void setSortedByIsSet(boolean value) {
    if (!value) {
      this.sorted_by = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case BUCKETED_BY:
      if (value == null) {
        unsetBucketedBy();
      } else {
        setBucketedBy((java.util.List<java.lang.String>)value);
      }
      break;

    case BUCKET_MODE:
      if (value == null) {
        unsetBucketMode();
      } else {
        setBucketMode((TBucketingMode)value);
      }
      break;

    case BUCKET_COUNT:
      if (value == null) {
        unsetBucketCount();
      } else {
        setBucketCount((java.lang.Integer)value);
      }
      break;

    case SORTED_BY:
      if (value == null) {
        unsetSortedBy();
      } else {
        setSortedBy((java.util.List<TSortedColumn>)value);
      }
      break;

    }
  }

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

    case BUCKET_MODE:
      return getBucketMode();

    case BUCKET_COUNT:
      return getBucketCount();

    case SORTED_BY:
      return getSortedBy();

    }
    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 BUCKETED_BY:
      return isSetBucketedBy();
    case BUCKET_MODE:
      return isSetBucketMode();
    case BUCKET_COUNT:
      return isSetBucketCount();
    case SORTED_BY:
      return isSetSortedBy();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_bucketed_by = true && this.isSetBucketedBy();
    boolean that_present_bucketed_by = true && that.isSetBucketedBy();
    if (this_present_bucketed_by || that_present_bucketed_by) {
      if (!(this_present_bucketed_by && that_present_bucketed_by))
        return false;
      if (!this.bucketed_by.equals(that.bucketed_by))
        return false;
    }

    boolean this_present_bucket_mode = true && this.isSetBucketMode();
    boolean that_present_bucket_mode = true && that.isSetBucketMode();
    if (this_present_bucket_mode || that_present_bucket_mode) {
      if (!(this_present_bucket_mode && that_present_bucket_mode))
        return false;
      if (!this.bucket_mode.equals(that.bucket_mode))
        return false;
    }

    boolean this_present_bucket_count = true && this.isSetBucketCount();
    boolean that_present_bucket_count = true && that.isSetBucketCount();
    if (this_present_bucket_count || that_present_bucket_count) {
      if (!(this_present_bucket_count && that_present_bucket_count))
        return false;
      if (this.bucket_count != that.bucket_count)
        return false;
    }

    boolean this_present_sorted_by = true && this.isSetSortedBy();
    boolean that_present_sorted_by = true && that.isSetSortedBy();
    if (this_present_sorted_by || that_present_sorted_by) {
      if (!(this_present_sorted_by && that_present_sorted_by))
        return false;
      if (!this.sorted_by.equals(that.sorted_by))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetBucketedBy()) ? 131071 : 524287);
    if (isSetBucketedBy())
      hashCode = hashCode * 8191 + bucketed_by.hashCode();

    hashCode = hashCode * 8191 + ((isSetBucketMode()) ? 131071 : 524287);
    if (isSetBucketMode())
      hashCode = hashCode * 8191 + bucket_mode.hashCode();

    hashCode = hashCode * 8191 + ((isSetBucketCount()) ? 131071 : 524287);
    if (isSetBucketCount())
      hashCode = hashCode * 8191 + bucket_count;

    hashCode = hashCode * 8191 + ((isSetSortedBy()) ? 131071 : 524287);
    if (isSetSortedBy())
      hashCode = hashCode * 8191 + sorted_by.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetBucketedBy(), other.isSetBucketedBy());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBucketedBy()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucketed_by, other.bucketed_by);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetBucketMode(), other.isSetBucketMode());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBucketMode()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucket_mode, other.bucket_mode);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetBucketCount(), other.isSetBucketCount());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBucketCount()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucket_count, other.bucket_count);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetSortedBy(), other.isSetSortedBy());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSortedBy()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sorted_by, other.sorted_by);
      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("THiveBucket(");
    boolean first = true;

    if (isSetBucketedBy()) {
      sb.append("bucketed_by:");
      if (this.bucketed_by == null) {
        sb.append("null");
      } else {
        sb.append(this.bucketed_by);
      }
      first = false;
    }
    if (isSetBucketMode()) {
      if (!first) sb.append(", ");
      sb.append("bucket_mode:");
      if (this.bucket_mode == null) {
        sb.append("null");
      } else {
        sb.append(this.bucket_mode);
      }
      first = false;
    }
    if (isSetBucketCount()) {
      if (!first) sb.append(", ");
      sb.append("bucket_count:");
      sb.append(this.bucket_count);
      first = false;
    }
    if (isSetSortedBy()) {
      if (!first) sb.append(", ");
      sb.append("sorted_by:");
      if (this.sorted_by == null) {
        sb.append("null");
      } else {
        sb.append(this.sorted_by);
      }
      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 (bucket_mode != null) {
      bucket_mode.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 THiveBucketStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public THiveBucketStandardScheme getScheme() {
      return new THiveBucketStandardScheme();
    }
  }

  private static class THiveBucketStandardScheme extends org.apache.thrift.scheme.StandardScheme<THiveBucket> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, THiveBucket 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: // BUCKETED_BY
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list134 = iprot.readListBegin();
                struct.bucketed_by = new java.util.ArrayList<java.lang.String>(_list134.size);
                @org.apache.thrift.annotation.Nullable java.lang.String _elem135;
                for (int _i136 = 0; _i136 < _list134.size; ++_i136)
                {
                  _elem135 = iprot.readString();
                  struct.bucketed_by.add(_elem135);
                }
                iprot.readListEnd();
              }
              struct.setBucketedByIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // BUCKET_MODE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.bucket_mode = new TBucketingMode();
              struct.bucket_mode.read(iprot);
              struct.setBucketModeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // BUCKET_COUNT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.bucket_count = iprot.readI32();
              struct.setBucketCountIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // SORTED_BY
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list137 = iprot.readListBegin();
                struct.sorted_by = new java.util.ArrayList<TSortedColumn>(_list137.size);
                @org.apache.thrift.annotation.Nullable TSortedColumn _elem138;
                for (int _i139 = 0; _i139 < _list137.size; ++_i139)
                {
                  _elem138 = new TSortedColumn();
                  _elem138.read(iprot);
                  struct.sorted_by.add(_elem138);
                }
                iprot.readListEnd();
              }
              struct.setSortedByIsSet(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, THiveBucket struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.bucketed_by != null) {
        if (struct.isSetBucketedBy()) {
          oprot.writeFieldBegin(BUCKETED_BY_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.bucketed_by.size()));
            for (java.lang.String _iter140 : struct.bucketed_by)
            {
              oprot.writeString(_iter140);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.bucket_mode != null) {
        if (struct.isSetBucketMode()) {
          oprot.writeFieldBegin(BUCKET_MODE_FIELD_DESC);
          struct.bucket_mode.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetBucketCount()) {
        oprot.writeFieldBegin(BUCKET_COUNT_FIELD_DESC);
        oprot.writeI32(struct.bucket_count);
        oprot.writeFieldEnd();
      }
      if (struct.sorted_by != null) {
        if (struct.isSetSortedBy()) {
          oprot.writeFieldBegin(SORTED_BY_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.sorted_by.size()));
            for (TSortedColumn _iter141 : struct.sorted_by)
            {
              _iter141.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class THiveBucketTupleScheme extends org.apache.thrift.scheme.TupleScheme<THiveBucket> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, THiveBucket 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.isSetBucketedBy()) {
        optionals.set(0);
      }
      if (struct.isSetBucketMode()) {
        optionals.set(1);
      }
      if (struct.isSetBucketCount()) {
        optionals.set(2);
      }
      if (struct.isSetSortedBy()) {
        optionals.set(3);
      }
      oprot.writeBitSet(optionals, 4);
      if (struct.isSetBucketedBy()) {
        {
          oprot.writeI32(struct.bucketed_by.size());
          for (java.lang.String _iter142 : struct.bucketed_by)
          {
            oprot.writeString(_iter142);
          }
        }
      }
      if (struct.isSetBucketMode()) {
        struct.bucket_mode.write(oprot);
      }
      if (struct.isSetBucketCount()) {
        oprot.writeI32(struct.bucket_count);
      }
      if (struct.isSetSortedBy()) {
        {
          oprot.writeI32(struct.sorted_by.size());
          for (TSortedColumn _iter143 : struct.sorted_by)
          {
            _iter143.write(oprot);
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, THiveBucket 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)) {
        {
          org.apache.thrift.protocol.TList _list144 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRING);
          struct.bucketed_by = new java.util.ArrayList<java.lang.String>(_list144.size);
          @org.apache.thrift.annotation.Nullable java.lang.String _elem145;
          for (int _i146 = 0; _i146 < _list144.size; ++_i146)
          {
            _elem145 = iprot.readString();
            struct.bucketed_by.add(_elem145);
          }
        }
        struct.setBucketedByIsSet(true);
      }
      if (incoming.get(1)) {
        struct.bucket_mode = new TBucketingMode();
        struct.bucket_mode.read(iprot);
        struct.setBucketModeIsSet(true);
      }
      if (incoming.get(2)) {
        struct.bucket_count = iprot.readI32();
        struct.setBucketCountIsSet(true);
      }
      if (incoming.get(3)) {
        {
          org.apache.thrift.protocol.TList _list147 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.sorted_by = new java.util.ArrayList<TSortedColumn>(_list147.size);
          @org.apache.thrift.annotation.Nullable TSortedColumn _elem148;
          for (int _i149 = 0; _i149 < _list147.size; ++_i149)
          {
            _elem148 = new TSortedColumn();
            _elem148.read(iprot);
            struct.sorted_by.add(_elem148);
          }
        }
        struct.setSortedByIsSet(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();
  }
}