All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xiaomi.infra.galaxy.sds.thrift.TableSchema Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.xiaomi.infra.galaxy.sds.thrift;

import libthrift091.scheme.IScheme;
import libthrift091.scheme.SchemeFactory;
import libthrift091.scheme.StandardScheme;

import libthrift091.scheme.TupleScheme;
import libthrift091.protocol.TTupleProtocol;
import libthrift091.protocol.TProtocolException;
import libthrift091.EncodingUtils;
import libthrift091.TException;
import libthrift091.async.AsyncMethodCallback;
import libthrift091.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
/**
 * 表Schema设置
 */
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-4-21")
public class TableSchema implements libthrift091.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("TableSchema");

  private static final libthrift091.protocol.TField VERSION_FIELD_DESC = new libthrift091.protocol.TField("version", libthrift091.protocol.TType.I32, (short)1);
  private static final libthrift091.protocol.TField ENTITY_GROUP_FIELD_DESC = new libthrift091.protocol.TField("entityGroup", libthrift091.protocol.TType.STRUCT, (short)2);
  private static final libthrift091.protocol.TField PRIMARY_INDEX_FIELD_DESC = new libthrift091.protocol.TField("primaryIndex", libthrift091.protocol.TType.LIST, (short)3);
  private static final libthrift091.protocol.TField SECONDARY_INDEXES_FIELD_DESC = new libthrift091.protocol.TField("secondaryIndexes", libthrift091.protocol.TType.MAP, (short)4);
  private static final libthrift091.protocol.TField ATTRIBUTES_FIELD_DESC = new libthrift091.protocol.TField("attributes", libthrift091.protocol.TType.MAP, (short)5);
  private static final libthrift091.protocol.TField TTL_FIELD_DESC = new libthrift091.protocol.TField("ttl", libthrift091.protocol.TType.I32, (short)6);
  private static final libthrift091.protocol.TField PRE_SPLITS_FIELD_DESC = new libthrift091.protocol.TField("preSplits", libthrift091.protocol.TType.I32, (short)7);

  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new TableSchemaStandardSchemeFactory());
    schemes.put(TupleScheme.class, new TableSchemaTupleSchemeFactory());
  }

  /**
   * Schema版本号,仅作为输出,作为输入不需要设置
   */
  public int version; // optional
  /**
   * Entity group定义, 不设置表示不开启Entity Group支持。
   * 开启后自动支持应用用户表空间隔离(需配合相应权限设置),
   * 即每个应用用户将看到独立的表空间
   */
  public EntityGroupSpec entityGroup; // optional
  /**
   * 主键定义
   */
  public List primaryIndex; // required
  /**
   * 二级索引定义
   */
  public Map secondaryIndexes; // optional
  /**
   * 属性定义
   */
  public Map attributes; // optional
  /**
   * 记录存活时间,单位为秒。-1表示不会自动删除
   */
  public int ttl; // optional
  /**
   * 表初始分片数目,仅支持Entity Group开启hash分布的表,且仅在建表时起作用
   */
  public int preSplits; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements libthrift091.TFieldIdEnum {
    /**
     * Schema版本号,仅作为输出,作为输入不需要设置
     */
    VERSION((short)1, "version"),
    /**
     * Entity group定义, 不设置表示不开启Entity Group支持。
     * 开启后自动支持应用用户表空间隔离(需配合相应权限设置),
     * 即每个应用用户将看到独立的表空间
     */
    ENTITY_GROUP((short)2, "entityGroup"),
    /**
     * 主键定义
     */
    PRIMARY_INDEX((short)3, "primaryIndex"),
    /**
     * 二级索引定义
     */
    SECONDARY_INDEXES((short)4, "secondaryIndexes"),
    /**
     * 属性定义
     */
    ATTRIBUTES((short)5, "attributes"),
    /**
     * 记录存活时间,单位为秒。-1表示不会自动删除
     */
    TTL((short)6, "ttl"),
    /**
     * 表初始分片数目,仅支持Entity Group开启hash分布的表,且仅在建表时起作用
     */
    PRE_SPLITS((short)7, "preSplits");

    private static final Map byName = new HashMap();

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

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // VERSION
          return VERSION;
        case 2: // ENTITY_GROUP
          return ENTITY_GROUP;
        case 3: // PRIMARY_INDEX
          return PRIMARY_INDEX;
        case 4: // SECONDARY_INDEXES
          return SECONDARY_INDEXES;
        case 5: // ATTRIBUTES
          return ATTRIBUTES;
        case 6: // TTL
          return TTL;
        case 7: // PRE_SPLITS
          return PRE_SPLITS;
        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 IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

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

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __VERSION_ISSET_ID = 0;
  private static final int __TTL_ISSET_ID = 1;
  private static final int __PRESPLITS_ISSET_ID = 2;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.VERSION,_Fields.ENTITY_GROUP,_Fields.SECONDARY_INDEXES,_Fields.ATTRIBUTES,_Fields.TTL,_Fields.PRE_SPLITS};
  public static final Map<_Fields, libthrift091.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, libthrift091.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, libthrift091.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.VERSION, new libthrift091.meta_data.FieldMetaData("version", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.I32)));
    tmpMap.put(_Fields.ENTITY_GROUP, new libthrift091.meta_data.FieldMetaData("entityGroup", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, EntityGroupSpec.class)));
    tmpMap.put(_Fields.PRIMARY_INDEX, new libthrift091.meta_data.FieldMetaData("primaryIndex", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.LIST        , "IndexSpec")));
    tmpMap.put(_Fields.SECONDARY_INDEXES, new libthrift091.meta_data.FieldMetaData("secondaryIndexes", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.MapMetaData(libthrift091.protocol.TType.MAP, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING), 
            new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, LocalSecondaryIndexSpec.class))));
    tmpMap.put(_Fields.ATTRIBUTES, new libthrift091.meta_data.FieldMetaData("attributes", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.MapMetaData(libthrift091.protocol.TType.MAP, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING), 
            new libthrift091.meta_data.EnumMetaData(libthrift091.protocol.TType.ENUM, DataType.class))));
    tmpMap.put(_Fields.TTL, new libthrift091.meta_data.FieldMetaData("ttl", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.I32)));
    tmpMap.put(_Fields.PRE_SPLITS, new libthrift091.meta_data.FieldMetaData("preSplits", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.I32)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(TableSchema.class, metaDataMap);
  }

  public TableSchema() {
    this.ttl = -1;

    this.preSplits = 1;

  }

  public TableSchema(
    List primaryIndex)
  {
    this();
    this.primaryIndex = primaryIndex;
  }

  /**
   * Performs a deep copy on other.
   */
  public TableSchema(TableSchema other) {
    __isset_bitfield = other.__isset_bitfield;
    this.version = other.version;
    if (other.isSetEntityGroup()) {
      this.entityGroup = new EntityGroupSpec(other.entityGroup);
    }
    if (other.isSetPrimaryIndex()) {
      this.primaryIndex = other.primaryIndex;
    }
    if (other.isSetSecondaryIndexes()) {
      Map __this__secondaryIndexes = new HashMap(other.secondaryIndexes.size());
      for (Map.Entry other_element : other.secondaryIndexes.entrySet()) {

        String other_element_key = other_element.getKey();
        LocalSecondaryIndexSpec other_element_value = other_element.getValue();

        String __this__secondaryIndexes_copy_key = other_element_key;

        LocalSecondaryIndexSpec __this__secondaryIndexes_copy_value = new LocalSecondaryIndexSpec(other_element_value);

        __this__secondaryIndexes.put(__this__secondaryIndexes_copy_key, __this__secondaryIndexes_copy_value);
      }
      this.secondaryIndexes = __this__secondaryIndexes;
    }
    if (other.isSetAttributes()) {
      Map __this__attributes = new HashMap(other.attributes.size());
      for (Map.Entry other_element : other.attributes.entrySet()) {

        String other_element_key = other_element.getKey();
        DataType other_element_value = other_element.getValue();

        String __this__attributes_copy_key = other_element_key;

        DataType __this__attributes_copy_value = other_element_value;

        __this__attributes.put(__this__attributes_copy_key, __this__attributes_copy_value);
      }
      this.attributes = __this__attributes;
    }
    this.ttl = other.ttl;
    this.preSplits = other.preSplits;
  }

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

  @Override
  public void clear() {
    setVersionIsSet(false);
    this.version = 0;
    this.entityGroup = null;
    this.primaryIndex = null;
    this.secondaryIndexes = null;
    this.attributes = null;
    this.ttl = -1;

    this.preSplits = 1;

  }

  /**
   * Schema版本号,仅作为输出,作为输入不需要设置
   */
  public int getVersion() {
    return this.version;
  }

  /**
   * Schema版本号,仅作为输出,作为输入不需要设置
   */
  public TableSchema setVersion(int version) {
    this.version = version;
    setVersionIsSet(true);
    return this;
  }

  public void unsetVersion() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __VERSION_ISSET_ID);
  }

  /** Returns true if field version is set (has been assigned a value) and false otherwise */
  public boolean isSetVersion() {
    return EncodingUtils.testBit(__isset_bitfield, __VERSION_ISSET_ID);
  }

  public void setVersionIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __VERSION_ISSET_ID, value);
  }

  /**
   * Entity group定义, 不设置表示不开启Entity Group支持。
   * 开启后自动支持应用用户表空间隔离(需配合相应权限设置),
   * 即每个应用用户将看到独立的表空间
   */
  public EntityGroupSpec getEntityGroup() {
    return this.entityGroup;
  }

  /**
   * Entity group定义, 不设置表示不开启Entity Group支持。
   * 开启后自动支持应用用户表空间隔离(需配合相应权限设置),
   * 即每个应用用户将看到独立的表空间
   */
  public TableSchema setEntityGroup(EntityGroupSpec entityGroup) {
    this.entityGroup = entityGroup;
    return this;
  }

  public void unsetEntityGroup() {
    this.entityGroup = null;
  }

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

  public void setEntityGroupIsSet(boolean value) {
    if (!value) {
      this.entityGroup = null;
    }
  }

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

  public java.util.Iterator getPrimaryIndexIterator() {
    return (this.primaryIndex == null) ? null : this.primaryIndex.iterator();
  }

  public void addToPrimaryIndex(KeySpec elem) {
    if (this.primaryIndex == null) {
      this.primaryIndex = new ArrayList();
    }
    this.primaryIndex.add(elem);
  }

  /**
   * 主键定义
   */
  public List getPrimaryIndex() {
    return this.primaryIndex;
  }

  /**
   * 主键定义
   */
  public TableSchema setPrimaryIndex(List primaryIndex) {
    this.primaryIndex = primaryIndex;
    return this;
  }

  public void unsetPrimaryIndex() {
    this.primaryIndex = null;
  }

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

  public void setPrimaryIndexIsSet(boolean value) {
    if (!value) {
      this.primaryIndex = null;
    }
  }

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

  public void putToSecondaryIndexes(String key, LocalSecondaryIndexSpec val) {
    if (this.secondaryIndexes == null) {
      this.secondaryIndexes = new HashMap();
    }
    this.secondaryIndexes.put(key, val);
  }

  /**
   * 二级索引定义
   */
  public Map getSecondaryIndexes() {
    return this.secondaryIndexes;
  }

  /**
   * 二级索引定义
   */
  public TableSchema setSecondaryIndexes(Map secondaryIndexes) {
    this.secondaryIndexes = secondaryIndexes;
    return this;
  }

  public void unsetSecondaryIndexes() {
    this.secondaryIndexes = null;
  }

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

  public void setSecondaryIndexesIsSet(boolean value) {
    if (!value) {
      this.secondaryIndexes = null;
    }
  }

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

  public void putToAttributes(String key, DataType val) {
    if (this.attributes == null) {
      this.attributes = new HashMap();
    }
    this.attributes.put(key, val);
  }

  /**
   * 属性定义
   */
  public Map getAttributes() {
    return this.attributes;
  }

  /**
   * 属性定义
   */
  public TableSchema setAttributes(Map attributes) {
    this.attributes = attributes;
    return this;
  }

  public void unsetAttributes() {
    this.attributes = null;
  }

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

  public void setAttributesIsSet(boolean value) {
    if (!value) {
      this.attributes = null;
    }
  }

  /**
   * 记录存活时间,单位为秒。-1表示不会自动删除
   */
  public int getTtl() {
    return this.ttl;
  }

  /**
   * 记录存活时间,单位为秒。-1表示不会自动删除
   */
  public TableSchema setTtl(int ttl) {
    this.ttl = ttl;
    setTtlIsSet(true);
    return this;
  }

  public void unsetTtl() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TTL_ISSET_ID);
  }

  /** Returns true if field ttl is set (has been assigned a value) and false otherwise */
  public boolean isSetTtl() {
    return EncodingUtils.testBit(__isset_bitfield, __TTL_ISSET_ID);
  }

  public void setTtlIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TTL_ISSET_ID, value);
  }

  /**
   * 表初始分片数目,仅支持Entity Group开启hash分布的表,且仅在建表时起作用
   */
  public int getPreSplits() {
    return this.preSplits;
  }

  /**
   * 表初始分片数目,仅支持Entity Group开启hash分布的表,且仅在建表时起作用
   */
  public TableSchema setPreSplits(int preSplits) {
    this.preSplits = preSplits;
    setPreSplitsIsSet(true);
    return this;
  }

  public void unsetPreSplits() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PRESPLITS_ISSET_ID);
  }

  /** Returns true if field preSplits is set (has been assigned a value) and false otherwise */
  public boolean isSetPreSplits() {
    return EncodingUtils.testBit(__isset_bitfield, __PRESPLITS_ISSET_ID);
  }

  public void setPreSplitsIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PRESPLITS_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case VERSION:
      if (value == null) {
        unsetVersion();
      } else {
        setVersion((Integer)value);
      }
      break;

    case ENTITY_GROUP:
      if (value == null) {
        unsetEntityGroup();
      } else {
        setEntityGroup((EntityGroupSpec)value);
      }
      break;

    case PRIMARY_INDEX:
      if (value == null) {
        unsetPrimaryIndex();
      } else {
        setPrimaryIndex((List)value);
      }
      break;

    case SECONDARY_INDEXES:
      if (value == null) {
        unsetSecondaryIndexes();
      } else {
        setSecondaryIndexes((Map)value);
      }
      break;

    case ATTRIBUTES:
      if (value == null) {
        unsetAttributes();
      } else {
        setAttributes((Map)value);
      }
      break;

    case TTL:
      if (value == null) {
        unsetTtl();
      } else {
        setTtl((Integer)value);
      }
      break;

    case PRE_SPLITS:
      if (value == null) {
        unsetPreSplits();
      } else {
        setPreSplits((Integer)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case VERSION:
      return Integer.valueOf(getVersion());

    case ENTITY_GROUP:
      return getEntityGroup();

    case PRIMARY_INDEX:
      return getPrimaryIndex();

    case SECONDARY_INDEXES:
      return getSecondaryIndexes();

    case ATTRIBUTES:
      return getAttributes();

    case TTL:
      return Integer.valueOf(getTtl());

    case PRE_SPLITS:
      return Integer.valueOf(getPreSplits());

    }
    throw new 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 IllegalArgumentException();
    }

    switch (field) {
    case VERSION:
      return isSetVersion();
    case ENTITY_GROUP:
      return isSetEntityGroup();
    case PRIMARY_INDEX:
      return isSetPrimaryIndex();
    case SECONDARY_INDEXES:
      return isSetSecondaryIndexes();
    case ATTRIBUTES:
      return isSetAttributes();
    case TTL:
      return isSetTtl();
    case PRE_SPLITS:
      return isSetPreSplits();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof TableSchema)
      return this.equals((TableSchema)that);
    return false;
  }

  public boolean equals(TableSchema that) {
    if (that == null)
      return false;

    boolean this_present_version = true && this.isSetVersion();
    boolean that_present_version = true && that.isSetVersion();
    if (this_present_version || that_present_version) {
      if (!(this_present_version && that_present_version))
        return false;
      if (this.version != that.version)
        return false;
    }

    boolean this_present_entityGroup = true && this.isSetEntityGroup();
    boolean that_present_entityGroup = true && that.isSetEntityGroup();
    if (this_present_entityGroup || that_present_entityGroup) {
      if (!(this_present_entityGroup && that_present_entityGroup))
        return false;
      if (!this.entityGroup.equals(that.entityGroup))
        return false;
    }

    boolean this_present_primaryIndex = true && this.isSetPrimaryIndex();
    boolean that_present_primaryIndex = true && that.isSetPrimaryIndex();
    if (this_present_primaryIndex || that_present_primaryIndex) {
      if (!(this_present_primaryIndex && that_present_primaryIndex))
        return false;
      if (!this.primaryIndex.equals(that.primaryIndex))
        return false;
    }

    boolean this_present_secondaryIndexes = true && this.isSetSecondaryIndexes();
    boolean that_present_secondaryIndexes = true && that.isSetSecondaryIndexes();
    if (this_present_secondaryIndexes || that_present_secondaryIndexes) {
      if (!(this_present_secondaryIndexes && that_present_secondaryIndexes))
        return false;
      if (!this.secondaryIndexes.equals(that.secondaryIndexes))
        return false;
    }

    boolean this_present_attributes = true && this.isSetAttributes();
    boolean that_present_attributes = true && that.isSetAttributes();
    if (this_present_attributes || that_present_attributes) {
      if (!(this_present_attributes && that_present_attributes))
        return false;
      if (!this.attributes.equals(that.attributes))
        return false;
    }

    boolean this_present_ttl = true && this.isSetTtl();
    boolean that_present_ttl = true && that.isSetTtl();
    if (this_present_ttl || that_present_ttl) {
      if (!(this_present_ttl && that_present_ttl))
        return false;
      if (this.ttl != that.ttl)
        return false;
    }

    boolean this_present_preSplits = true && this.isSetPreSplits();
    boolean that_present_preSplits = true && that.isSetPreSplits();
    if (this_present_preSplits || that_present_preSplits) {
      if (!(this_present_preSplits && that_present_preSplits))
        return false;
      if (this.preSplits != that.preSplits)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List list = new ArrayList();

    boolean present_version = true && (isSetVersion());
    list.add(present_version);
    if (present_version)
      list.add(version);

    boolean present_entityGroup = true && (isSetEntityGroup());
    list.add(present_entityGroup);
    if (present_entityGroup)
      list.add(entityGroup);

    boolean present_primaryIndex = true && (isSetPrimaryIndex());
    list.add(present_primaryIndex);
    if (present_primaryIndex)
      list.add(primaryIndex);

    boolean present_secondaryIndexes = true && (isSetSecondaryIndexes());
    list.add(present_secondaryIndexes);
    if (present_secondaryIndexes)
      list.add(secondaryIndexes);

    boolean present_attributes = true && (isSetAttributes());
    list.add(present_attributes);
    if (present_attributes)
      list.add(attributes);

    boolean present_ttl = true && (isSetTtl());
    list.add(present_ttl);
    if (present_ttl)
      list.add(ttl);

    boolean present_preSplits = true && (isSetPreSplits());
    list.add(present_preSplits);
    if (present_preSplits)
      list.add(preSplits);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVersion()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.version, other.version);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEntityGroup()).compareTo(other.isSetEntityGroup());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEntityGroup()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.entityGroup, other.entityGroup);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPrimaryIndex()).compareTo(other.isSetPrimaryIndex());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrimaryIndex()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.primaryIndex, other.primaryIndex);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetSecondaryIndexes()).compareTo(other.isSetSecondaryIndexes());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSecondaryIndexes()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.secondaryIndexes, other.secondaryIndexes);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(other.isSetAttributes());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAttributes()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.attributes, other.attributes);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetTtl()).compareTo(other.isSetTtl());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTtl()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.ttl, other.ttl);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPreSplits()).compareTo(other.isSetPreSplits());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPreSplits()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.preSplits, other.preSplits);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(libthrift091.protocol.TProtocol iprot) throws libthrift091.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("TableSchema(");
    boolean first = true;

    if (isSetVersion()) {
      sb.append("version:");
      sb.append(this.version);
      first = false;
    }
    if (isSetEntityGroup()) {
      if (!first) sb.append(", ");
      sb.append("entityGroup:");
      if (this.entityGroup == null) {
        sb.append("null");
      } else {
        sb.append(this.entityGroup);
      }
      first = false;
    }
    if (!first) sb.append(", ");
    sb.append("primaryIndex:");
    if (this.primaryIndex == null) {
      sb.append("null");
    } else {
      sb.append(this.primaryIndex);
    }
    first = false;
    if (isSetSecondaryIndexes()) {
      if (!first) sb.append(", ");
      sb.append("secondaryIndexes:");
      if (this.secondaryIndexes == null) {
        sb.append("null");
      } else {
        sb.append(this.secondaryIndexes);
      }
      first = false;
    }
    if (isSetAttributes()) {
      if (!first) sb.append(", ");
      sb.append("attributes:");
      if (this.attributes == null) {
        sb.append("null");
      } else {
        sb.append(this.attributes);
      }
      first = false;
    }
    if (isSetTtl()) {
      if (!first) sb.append(", ");
      sb.append("ttl:");
      sb.append(this.ttl);
      first = false;
    }
    if (isSetPreSplits()) {
      if (!first) sb.append(", ");
      sb.append("preSplits:");
      sb.append(this.preSplits);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

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

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

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, 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 libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(in)));
    } catch (libthrift091.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class TableSchemaStandardSchemeFactory implements SchemeFactory {
    public TableSchemaStandardScheme getScheme() {
      return new TableSchemaStandardScheme();
    }
  }

  private static class TableSchemaStandardScheme extends StandardScheme {

    public void read(libthrift091.protocol.TProtocol iprot, TableSchema struct) throws libthrift091.TException {
      libthrift091.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == libthrift091.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // VERSION
            if (schemeField.type == libthrift091.protocol.TType.I32) {
              struct.version = iprot.readI32();
              struct.setVersionIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // ENTITY_GROUP
            if (schemeField.type == libthrift091.protocol.TType.STRUCT) {
              struct.entityGroup = new EntityGroupSpec();
              struct.entityGroup.read(iprot);
              struct.setEntityGroupIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // PRIMARY_INDEX
            if (schemeField.type == libthrift091.protocol.TType.LIST) {
              {
                libthrift091.protocol.TList _list88 = iprot.readListBegin();
                struct.primaryIndex = new ArrayList(_list88.size);
                KeySpec _elem89;
                for (int _i90 = 0; _i90 < _list88.size; ++_i90)
                {
                  _elem89 = new KeySpec();
                  _elem89.read(iprot);
                  struct.primaryIndex.add(_elem89);
                }
                iprot.readListEnd();
              }
              struct.setPrimaryIndexIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // SECONDARY_INDEXES
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map91 = iprot.readMapBegin();
                struct.secondaryIndexes = new HashMap(2*_map91.size);
                String _key92;
                LocalSecondaryIndexSpec _val93;
                for (int _i94 = 0; _i94 < _map91.size; ++_i94)
                {
                  _key92 = iprot.readString();
                  _val93 = new LocalSecondaryIndexSpec();
                  _val93.read(iprot);
                  struct.secondaryIndexes.put(_key92, _val93);
                }
                iprot.readMapEnd();
              }
              struct.setSecondaryIndexesIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // ATTRIBUTES
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map95 = iprot.readMapBegin();
                struct.attributes = new HashMap(2*_map95.size);
                String _key96;
                DataType _val97;
                for (int _i98 = 0; _i98 < _map95.size; ++_i98)
                {
                  _key96 = iprot.readString();
                  _val97 = com.xiaomi.infra.galaxy.sds.thrift.DataType.findByValue(iprot.readI32());
                  struct.attributes.put(_key96, _val97);
                }
                iprot.readMapEnd();
              }
              struct.setAttributesIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // TTL
            if (schemeField.type == libthrift091.protocol.TType.I32) {
              struct.ttl = iprot.readI32();
              struct.setTtlIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // PRE_SPLITS
            if (schemeField.type == libthrift091.protocol.TType.I32) {
              struct.preSplits = iprot.readI32();
              struct.setPreSplitsIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            libthrift091.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(libthrift091.protocol.TProtocol oprot, TableSchema struct) throws libthrift091.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.isSetVersion()) {
        oprot.writeFieldBegin(VERSION_FIELD_DESC);
        oprot.writeI32(struct.version);
        oprot.writeFieldEnd();
      }
      if (struct.entityGroup != null) {
        if (struct.isSetEntityGroup()) {
          oprot.writeFieldBegin(ENTITY_GROUP_FIELD_DESC);
          struct.entityGroup.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.primaryIndex != null) {
        oprot.writeFieldBegin(PRIMARY_INDEX_FIELD_DESC);
        {
          oprot.writeListBegin(new libthrift091.protocol.TList(libthrift091.protocol.TType.STRUCT, struct.primaryIndex.size()));
          for (KeySpec _iter99 : struct.primaryIndex)
          {
            _iter99.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.secondaryIndexes != null) {
        if (struct.isSetSecondaryIndexes()) {
          oprot.writeFieldBegin(SECONDARY_INDEXES_FIELD_DESC);
          {
            oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRUCT, struct.secondaryIndexes.size()));
            for (Map.Entry _iter100 : struct.secondaryIndexes.entrySet())
            {
              oprot.writeString(_iter100.getKey());
              _iter100.getValue().write(oprot);
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.attributes != null) {
        if (struct.isSetAttributes()) {
          oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
          {
            oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, struct.attributes.size()));
            for (Map.Entry _iter101 : struct.attributes.entrySet())
            {
              oprot.writeString(_iter101.getKey());
              oprot.writeI32(_iter101.getValue().getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetTtl()) {
        oprot.writeFieldBegin(TTL_FIELD_DESC);
        oprot.writeI32(struct.ttl);
        oprot.writeFieldEnd();
      }
      if (struct.isSetPreSplits()) {
        oprot.writeFieldBegin(PRE_SPLITS_FIELD_DESC);
        oprot.writeI32(struct.preSplits);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TableSchemaTupleSchemeFactory implements SchemeFactory {
    public TableSchemaTupleScheme getScheme() {
      return new TableSchemaTupleScheme();
    }
  }

  private static class TableSchemaTupleScheme extends TupleScheme {

    @Override
    public void write(libthrift091.protocol.TProtocol prot, TableSchema struct) throws libthrift091.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetVersion()) {
        optionals.set(0);
      }
      if (struct.isSetEntityGroup()) {
        optionals.set(1);
      }
      if (struct.isSetPrimaryIndex()) {
        optionals.set(2);
      }
      if (struct.isSetSecondaryIndexes()) {
        optionals.set(3);
      }
      if (struct.isSetAttributes()) {
        optionals.set(4);
      }
      if (struct.isSetTtl()) {
        optionals.set(5);
      }
      if (struct.isSetPreSplits()) {
        optionals.set(6);
      }
      oprot.writeBitSet(optionals, 7);
      if (struct.isSetVersion()) {
        oprot.writeI32(struct.version);
      }
      if (struct.isSetEntityGroup()) {
        struct.entityGroup.write(oprot);
      }
      if (struct.isSetPrimaryIndex()) {
        {
          oprot.writeI32(struct.primaryIndex.size());
          for (KeySpec _iter102 : struct.primaryIndex)
          {
            _iter102.write(oprot);
          }
        }
      }
      if (struct.isSetSecondaryIndexes()) {
        {
          oprot.writeI32(struct.secondaryIndexes.size());
          for (Map.Entry _iter103 : struct.secondaryIndexes.entrySet())
          {
            oprot.writeString(_iter103.getKey());
            _iter103.getValue().write(oprot);
          }
        }
      }
      if (struct.isSetAttributes()) {
        {
          oprot.writeI32(struct.attributes.size());
          for (Map.Entry _iter104 : struct.attributes.entrySet())
          {
            oprot.writeString(_iter104.getKey());
            oprot.writeI32(_iter104.getValue().getValue());
          }
        }
      }
      if (struct.isSetTtl()) {
        oprot.writeI32(struct.ttl);
      }
      if (struct.isSetPreSplits()) {
        oprot.writeI32(struct.preSplits);
      }
    }

    @Override
    public void read(libthrift091.protocol.TProtocol prot, TableSchema struct) throws libthrift091.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(7);
      if (incoming.get(0)) {
        struct.version = iprot.readI32();
        struct.setVersionIsSet(true);
      }
      if (incoming.get(1)) {
        struct.entityGroup = new EntityGroupSpec();
        struct.entityGroup.read(iprot);
        struct.setEntityGroupIsSet(true);
      }
      if (incoming.get(2)) {
        {
          libthrift091.protocol.TList _list105 = new libthrift091.protocol.TList(libthrift091.protocol.TType.STRUCT, iprot.readI32());
          struct.primaryIndex = new ArrayList(_list105.size);
          KeySpec _elem106;
          for (int _i107 = 0; _i107 < _list105.size; ++_i107)
          {
            _elem106 = new KeySpec();
            _elem106.read(iprot);
            struct.primaryIndex.add(_elem106);
          }
        }
        struct.setPrimaryIndexIsSet(true);
      }
      if (incoming.get(3)) {
        {
          libthrift091.protocol.TMap _map108 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRUCT, iprot.readI32());
          struct.secondaryIndexes = new HashMap(2*_map108.size);
          String _key109;
          LocalSecondaryIndexSpec _val110;
          for (int _i111 = 0; _i111 < _map108.size; ++_i111)
          {
            _key109 = iprot.readString();
            _val110 = new LocalSecondaryIndexSpec();
            _val110.read(iprot);
            struct.secondaryIndexes.put(_key109, _val110);
          }
        }
        struct.setSecondaryIndexesIsSet(true);
      }
      if (incoming.get(4)) {
        {
          libthrift091.protocol.TMap _map112 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, iprot.readI32());
          struct.attributes = new HashMap(2*_map112.size);
          String _key113;
          DataType _val114;
          for (int _i115 = 0; _i115 < _map112.size; ++_i115)
          {
            _key113 = iprot.readString();
            _val114 = com.xiaomi.infra.galaxy.sds.thrift.DataType.findByValue(iprot.readI32());
            struct.attributes.put(_key113, _val114);
          }
        }
        struct.setAttributesIsSet(true);
      }
      if (incoming.get(5)) {
        struct.ttl = iprot.readI32();
        struct.setTtlIsSet(true);
      }
      if (incoming.get(6)) {
        struct.preSplits = iprot.readI32();
        struct.setPreSplitsIsSet(true);
      }
    }
  }

}