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

org.apache.parquet.format.DataPageHeaderV2 Maven / Gradle / Ivy

Go to download

Parquet is a columnar storage format that supports nested data. This provides all generated metadata code.

There is a newer version: 2.10.0
Show newest version
/**
 * Autogenerated by Thrift Compiler (0.7.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package org.apache.parquet.format;

import org.apache.commons.lang.builder.HashCodeBuilder;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * New page format alowing reading levels without decompressing the data
 * Repetition and definition levels are uncompressed
 * The remaining section containing the data is compressed if is_compressed is true
 * 
 */
public class DataPageHeaderV2 implements org.apache.thrift.TBase, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DataPageHeaderV2");

  private static final org.apache.thrift.protocol.TField NUM_VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("num_values", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField NUM_NULLS_FIELD_DESC = new org.apache.thrift.protocol.TField("num_nulls", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField NUM_ROWS_FIELD_DESC = new org.apache.thrift.protocol.TField("num_rows", org.apache.thrift.protocol.TType.I32, (short)3);
  private static final org.apache.thrift.protocol.TField ENCODING_FIELD_DESC = new org.apache.thrift.protocol.TField("encoding", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField DEFINITION_LEVELS_BYTE_LENGTH_FIELD_DESC = new org.apache.thrift.protocol.TField("definition_levels_byte_length", org.apache.thrift.protocol.TType.I32, (short)5);
  private static final org.apache.thrift.protocol.TField REPETITION_LEVELS_BYTE_LENGTH_FIELD_DESC = new org.apache.thrift.protocol.TField("repetition_levels_byte_length", org.apache.thrift.protocol.TType.I32, (short)6);
  private static final org.apache.thrift.protocol.TField IS_COMPRESSED_FIELD_DESC = new org.apache.thrift.protocol.TField("is_compressed", org.apache.thrift.protocol.TType.BOOL, (short)7);
  private static final org.apache.thrift.protocol.TField STATISTICS_FIELD_DESC = new org.apache.thrift.protocol.TField("statistics", org.apache.thrift.protocol.TType.STRUCT, (short)8);

  /**
   * Number of values, including NULLs, in this data page. *
   */
  public int num_values; // required
  /**
   * Number of NULL values, in this data page.
   * Number of non-null = num_values - num_nulls which is also the number of values in the data section *
   */
  public int num_nulls; // required
  /**
   * Number of rows in this data page. which means pages change on record boundaries (r = 0) *
   */
  public int num_rows; // required
  /**
   * Encoding used for data in this page *
   * 
   * @see Encoding
   */
  public Encoding encoding; // required
  /**
   * length of the repetition levels
   */
  public int definition_levels_byte_length; // required
  /**
   * length of the definition levels
   */
  public int repetition_levels_byte_length; // required
  /**
   * whether the values are compressed.
   * Which means the section of the page between
   * definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included)
   * is compressed with the compression_codec.
   * If missing it is considered compressed
   */
  public boolean is_compressed; // required
  /**
   * optional statistics for this column chunk
   */
  public Statistics statistics; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    /**
     * Number of values, including NULLs, in this data page. *
     */
    NUM_VALUES((short)1, "num_values"),
    /**
     * Number of NULL values, in this data page.
     * Number of non-null = num_values - num_nulls which is also the number of values in the data section *
     */
    NUM_NULLS((short)2, "num_nulls"),
    /**
     * Number of rows in this data page. which means pages change on record boundaries (r = 0) *
     */
    NUM_ROWS((short)3, "num_rows"),
    /**
     * Encoding used for data in this page *
     * 
     * @see Encoding
     */
    ENCODING((short)4, "encoding"),
    /**
     * length of the repetition levels
     */
    DEFINITION_LEVELS_BYTE_LENGTH((short)5, "definition_levels_byte_length"),
    /**
     * length of the definition levels
     */
    REPETITION_LEVELS_BYTE_LENGTH((short)6, "repetition_levels_byte_length"),
    /**
     * whether the values are compressed.
     * Which means the section of the page between
     * definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included)
     * is compressed with the compression_codec.
     * If missing it is considered compressed
     */
    IS_COMPRESSED((short)7, "is_compressed"),
    /**
     * optional statistics for this column chunk
     */
    STATISTICS((short)8, "statistics");

    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: // NUM_VALUES
          return NUM_VALUES;
        case 2: // NUM_NULLS
          return NUM_NULLS;
        case 3: // NUM_ROWS
          return NUM_ROWS;
        case 4: // ENCODING
          return ENCODING;
        case 5: // DEFINITION_LEVELS_BYTE_LENGTH
          return DEFINITION_LEVELS_BYTE_LENGTH;
        case 6: // REPETITION_LEVELS_BYTE_LENGTH
          return REPETITION_LEVELS_BYTE_LENGTH;
        case 7: // IS_COMPRESSED
          return IS_COMPRESSED;
        case 8: // STATISTICS
          return STATISTICS;
        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 __NUM_VALUES_ISSET_ID = 0;
  private static final int __NUM_NULLS_ISSET_ID = 1;
  private static final int __NUM_ROWS_ISSET_ID = 2;
  private static final int __DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID = 3;
  private static final int __REPETITION_LEVELS_BYTE_LENGTH_ISSET_ID = 4;
  private static final int __IS_COMPRESSED_ISSET_ID = 5;
  private BitSet __isset_bit_vector = new BitSet(6);

  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.NUM_VALUES, new org.apache.thrift.meta_data.FieldMetaData("num_values", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.NUM_NULLS, new org.apache.thrift.meta_data.FieldMetaData("num_nulls", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.NUM_ROWS, new org.apache.thrift.meta_data.FieldMetaData("num_rows", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.ENCODING, new org.apache.thrift.meta_data.FieldMetaData("encoding", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Encoding.class)));
    tmpMap.put(_Fields.DEFINITION_LEVELS_BYTE_LENGTH, new org.apache.thrift.meta_data.FieldMetaData("definition_levels_byte_length", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.REPETITION_LEVELS_BYTE_LENGTH, new org.apache.thrift.meta_data.FieldMetaData("repetition_levels_byte_length", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.IS_COMPRESSED, new org.apache.thrift.meta_data.FieldMetaData("is_compressed", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.STATISTICS, new org.apache.thrift.meta_data.FieldMetaData("statistics", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Statistics.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DataPageHeaderV2.class, metaDataMap);
  }

  public DataPageHeaderV2() {
    this.is_compressed = true;

  }

  public DataPageHeaderV2(
    int num_values,
    int num_nulls,
    int num_rows,
    Encoding encoding,
    int definition_levels_byte_length,
    int repetition_levels_byte_length)
  {
    this();
    this.num_values = num_values;
    setNum_valuesIsSet(true);
    this.num_nulls = num_nulls;
    setNum_nullsIsSet(true);
    this.num_rows = num_rows;
    setNum_rowsIsSet(true);
    this.encoding = encoding;
    this.definition_levels_byte_length = definition_levels_byte_length;
    setDefinition_levels_byte_lengthIsSet(true);
    this.repetition_levels_byte_length = repetition_levels_byte_length;
    setRepetition_levels_byte_lengthIsSet(true);
  }

  /**
   * Performs a deep copy on other.
   */
  public DataPageHeaderV2(DataPageHeaderV2 other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.num_values = other.num_values;
    this.num_nulls = other.num_nulls;
    this.num_rows = other.num_rows;
    if (other.isSetEncoding()) {
      this.encoding = other.encoding;
    }
    this.definition_levels_byte_length = other.definition_levels_byte_length;
    this.repetition_levels_byte_length = other.repetition_levels_byte_length;
    this.is_compressed = other.is_compressed;
    if (other.isSetStatistics()) {
      this.statistics = new Statistics(other.statistics);
    }
  }

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

  @Override
  public void clear() {
    setNum_valuesIsSet(false);
    this.num_values = 0;
    setNum_nullsIsSet(false);
    this.num_nulls = 0;
    setNum_rowsIsSet(false);
    this.num_rows = 0;
    this.encoding = null;
    setDefinition_levels_byte_lengthIsSet(false);
    this.definition_levels_byte_length = 0;
    setRepetition_levels_byte_lengthIsSet(false);
    this.repetition_levels_byte_length = 0;
    this.is_compressed = true;

    this.statistics = null;
  }

  /**
   * Number of values, including NULLs, in this data page. *
   */
  public int getNum_values() {
    return this.num_values;
  }

  /**
   * Number of values, including NULLs, in this data page. *
   */
  public DataPageHeaderV2 setNum_values(int num_values) {
    this.num_values = num_values;
    setNum_valuesIsSet(true);
    return this;
  }

  public void unsetNum_values() {
    __isset_bit_vector.clear(__NUM_VALUES_ISSET_ID);
  }

  /** Returns true if field num_values is set (has been assigned a value) and false otherwise */
  public boolean isSetNum_values() {
    return __isset_bit_vector.get(__NUM_VALUES_ISSET_ID);
  }

  public void setNum_valuesIsSet(boolean value) {
    __isset_bit_vector.set(__NUM_VALUES_ISSET_ID, value);
  }

  /**
   * Number of NULL values, in this data page.
   * Number of non-null = num_values - num_nulls which is also the number of values in the data section *
   */
  public int getNum_nulls() {
    return this.num_nulls;
  }

  /**
   * Number of NULL values, in this data page.
   * Number of non-null = num_values - num_nulls which is also the number of values in the data section *
   */
  public DataPageHeaderV2 setNum_nulls(int num_nulls) {
    this.num_nulls = num_nulls;
    setNum_nullsIsSet(true);
    return this;
  }

  public void unsetNum_nulls() {
    __isset_bit_vector.clear(__NUM_NULLS_ISSET_ID);
  }

  /** Returns true if field num_nulls is set (has been assigned a value) and false otherwise */
  public boolean isSetNum_nulls() {
    return __isset_bit_vector.get(__NUM_NULLS_ISSET_ID);
  }

  public void setNum_nullsIsSet(boolean value) {
    __isset_bit_vector.set(__NUM_NULLS_ISSET_ID, value);
  }

  /**
   * Number of rows in this data page. which means pages change on record boundaries (r = 0) *
   */
  public int getNum_rows() {
    return this.num_rows;
  }

  /**
   * Number of rows in this data page. which means pages change on record boundaries (r = 0) *
   */
  public DataPageHeaderV2 setNum_rows(int num_rows) {
    this.num_rows = num_rows;
    setNum_rowsIsSet(true);
    return this;
  }

  public void unsetNum_rows() {
    __isset_bit_vector.clear(__NUM_ROWS_ISSET_ID);
  }

  /** Returns true if field num_rows is set (has been assigned a value) and false otherwise */
  public boolean isSetNum_rows() {
    return __isset_bit_vector.get(__NUM_ROWS_ISSET_ID);
  }

  public void setNum_rowsIsSet(boolean value) {
    __isset_bit_vector.set(__NUM_ROWS_ISSET_ID, value);
  }

  /**
   * Encoding used for data in this page *
   * 
   * @see Encoding
   */
  public Encoding getEncoding() {
    return this.encoding;
  }

  /**
   * Encoding used for data in this page *
   * 
   * @see Encoding
   */
  public DataPageHeaderV2 setEncoding(Encoding encoding) {
    this.encoding = encoding;
    return this;
  }

  public void unsetEncoding() {
    this.encoding = null;
  }

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

  public void setEncodingIsSet(boolean value) {
    if (!value) {
      this.encoding = null;
    }
  }

  /**
   * length of the repetition levels
   */
  public int getDefinition_levels_byte_length() {
    return this.definition_levels_byte_length;
  }

  /**
   * length of the repetition levels
   */
  public DataPageHeaderV2 setDefinition_levels_byte_length(int definition_levels_byte_length) {
    this.definition_levels_byte_length = definition_levels_byte_length;
    setDefinition_levels_byte_lengthIsSet(true);
    return this;
  }

  public void unsetDefinition_levels_byte_length() {
    __isset_bit_vector.clear(__DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  /** Returns true if field definition_levels_byte_length is set (has been assigned a value) and false otherwise */
  public boolean isSetDefinition_levels_byte_length() {
    return __isset_bit_vector.get(__DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  public void setDefinition_levels_byte_lengthIsSet(boolean value) {
    __isset_bit_vector.set(__DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID, value);
  }

  /**
   * length of the definition levels
   */
  public int getRepetition_levels_byte_length() {
    return this.repetition_levels_byte_length;
  }

  /**
   * length of the definition levels
   */
  public DataPageHeaderV2 setRepetition_levels_byte_length(int repetition_levels_byte_length) {
    this.repetition_levels_byte_length = repetition_levels_byte_length;
    setRepetition_levels_byte_lengthIsSet(true);
    return this;
  }

  public void unsetRepetition_levels_byte_length() {
    __isset_bit_vector.clear(__REPETITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  /** Returns true if field repetition_levels_byte_length is set (has been assigned a value) and false otherwise */
  public boolean isSetRepetition_levels_byte_length() {
    return __isset_bit_vector.get(__REPETITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  public void setRepetition_levels_byte_lengthIsSet(boolean value) {
    __isset_bit_vector.set(__REPETITION_LEVELS_BYTE_LENGTH_ISSET_ID, value);
  }

  /**
   * whether the values are compressed.
   * Which means the section of the page between
   * definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included)
   * is compressed with the compression_codec.
   * If missing it is considered compressed
   */
  public boolean isIs_compressed() {
    return this.is_compressed;
  }

  /**
   * whether the values are compressed.
   * Which means the section of the page between
   * definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included)
   * is compressed with the compression_codec.
   * If missing it is considered compressed
   */
  public DataPageHeaderV2 setIs_compressed(boolean is_compressed) {
    this.is_compressed = is_compressed;
    setIs_compressedIsSet(true);
    return this;
  }

  public void unsetIs_compressed() {
    __isset_bit_vector.clear(__IS_COMPRESSED_ISSET_ID);
  }

  /** Returns true if field is_compressed is set (has been assigned a value) and false otherwise */
  public boolean isSetIs_compressed() {
    return __isset_bit_vector.get(__IS_COMPRESSED_ISSET_ID);
  }

  public void setIs_compressedIsSet(boolean value) {
    __isset_bit_vector.set(__IS_COMPRESSED_ISSET_ID, value);
  }

  /**
   * optional statistics for this column chunk
   */
  public Statistics getStatistics() {
    return this.statistics;
  }

  /**
   * optional statistics for this column chunk
   */
  public DataPageHeaderV2 setStatistics(Statistics statistics) {
    this.statistics = statistics;
    return this;
  }

  public void unsetStatistics() {
    this.statistics = null;
  }

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

  public void setStatisticsIsSet(boolean value) {
    if (!value) {
      this.statistics = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case NUM_VALUES:
      if (value == null) {
        unsetNum_values();
      } else {
        setNum_values((Integer)value);
      }
      break;

    case NUM_NULLS:
      if (value == null) {
        unsetNum_nulls();
      } else {
        setNum_nulls((Integer)value);
      }
      break;

    case NUM_ROWS:
      if (value == null) {
        unsetNum_rows();
      } else {
        setNum_rows((Integer)value);
      }
      break;

    case ENCODING:
      if (value == null) {
        unsetEncoding();
      } else {
        setEncoding((Encoding)value);
      }
      break;

    case DEFINITION_LEVELS_BYTE_LENGTH:
      if (value == null) {
        unsetDefinition_levels_byte_length();
      } else {
        setDefinition_levels_byte_length((Integer)value);
      }
      break;

    case REPETITION_LEVELS_BYTE_LENGTH:
      if (value == null) {
        unsetRepetition_levels_byte_length();
      } else {
        setRepetition_levels_byte_length((Integer)value);
      }
      break;

    case IS_COMPRESSED:
      if (value == null) {
        unsetIs_compressed();
      } else {
        setIs_compressed((Boolean)value);
      }
      break;

    case STATISTICS:
      if (value == null) {
        unsetStatistics();
      } else {
        setStatistics((Statistics)value);
      }
      break;

    }
  }

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

    case NUM_NULLS:
      return Integer.valueOf(getNum_nulls());

    case NUM_ROWS:
      return Integer.valueOf(getNum_rows());

    case ENCODING:
      return getEncoding();

    case DEFINITION_LEVELS_BYTE_LENGTH:
      return Integer.valueOf(getDefinition_levels_byte_length());

    case REPETITION_LEVELS_BYTE_LENGTH:
      return Integer.valueOf(getRepetition_levels_byte_length());

    case IS_COMPRESSED:
      return Boolean.valueOf(isIs_compressed());

    case STATISTICS:
      return getStatistics();

    }
    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 NUM_VALUES:
      return isSetNum_values();
    case NUM_NULLS:
      return isSetNum_nulls();
    case NUM_ROWS:
      return isSetNum_rows();
    case ENCODING:
      return isSetEncoding();
    case DEFINITION_LEVELS_BYTE_LENGTH:
      return isSetDefinition_levels_byte_length();
    case REPETITION_LEVELS_BYTE_LENGTH:
      return isSetRepetition_levels_byte_length();
    case IS_COMPRESSED:
      return isSetIs_compressed();
    case STATISTICS:
      return isSetStatistics();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_num_values = true;
    boolean that_present_num_values = true;
    if (this_present_num_values || that_present_num_values) {
      if (!(this_present_num_values && that_present_num_values))
        return false;
      if (this.num_values != that.num_values)
        return false;
    }

    boolean this_present_num_nulls = true;
    boolean that_present_num_nulls = true;
    if (this_present_num_nulls || that_present_num_nulls) {
      if (!(this_present_num_nulls && that_present_num_nulls))
        return false;
      if (this.num_nulls != that.num_nulls)
        return false;
    }

    boolean this_present_num_rows = true;
    boolean that_present_num_rows = true;
    if (this_present_num_rows || that_present_num_rows) {
      if (!(this_present_num_rows && that_present_num_rows))
        return false;
      if (this.num_rows != that.num_rows)
        return false;
    }

    boolean this_present_encoding = true && this.isSetEncoding();
    boolean that_present_encoding = true && that.isSetEncoding();
    if (this_present_encoding || that_present_encoding) {
      if (!(this_present_encoding && that_present_encoding))
        return false;
      if (!this.encoding.equals(that.encoding))
        return false;
    }

    boolean this_present_definition_levels_byte_length = true;
    boolean that_present_definition_levels_byte_length = true;
    if (this_present_definition_levels_byte_length || that_present_definition_levels_byte_length) {
      if (!(this_present_definition_levels_byte_length && that_present_definition_levels_byte_length))
        return false;
      if (this.definition_levels_byte_length != that.definition_levels_byte_length)
        return false;
    }

    boolean this_present_repetition_levels_byte_length = true;
    boolean that_present_repetition_levels_byte_length = true;
    if (this_present_repetition_levels_byte_length || that_present_repetition_levels_byte_length) {
      if (!(this_present_repetition_levels_byte_length && that_present_repetition_levels_byte_length))
        return false;
      if (this.repetition_levels_byte_length != that.repetition_levels_byte_length)
        return false;
    }

    boolean this_present_is_compressed = true && this.isSetIs_compressed();
    boolean that_present_is_compressed = true && that.isSetIs_compressed();
    if (this_present_is_compressed || that_present_is_compressed) {
      if (!(this_present_is_compressed && that_present_is_compressed))
        return false;
      if (this.is_compressed != that.is_compressed)
        return false;
    }

    boolean this_present_statistics = true && this.isSetStatistics();
    boolean that_present_statistics = true && that.isSetStatistics();
    if (this_present_statistics || that_present_statistics) {
      if (!(this_present_statistics && that_present_statistics))
        return false;
      if (!this.statistics.equals(that.statistics))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();

    boolean present_num_values = true;
    builder.append(present_num_values);
    if (present_num_values)
      builder.append(num_values);

    boolean present_num_nulls = true;
    builder.append(present_num_nulls);
    if (present_num_nulls)
      builder.append(num_nulls);

    boolean present_num_rows = true;
    builder.append(present_num_rows);
    if (present_num_rows)
      builder.append(num_rows);

    boolean present_encoding = true && (isSetEncoding());
    builder.append(present_encoding);
    if (present_encoding)
      builder.append(encoding.getValue());

    boolean present_definition_levels_byte_length = true;
    builder.append(present_definition_levels_byte_length);
    if (present_definition_levels_byte_length)
      builder.append(definition_levels_byte_length);

    boolean present_repetition_levels_byte_length = true;
    builder.append(present_repetition_levels_byte_length);
    if (present_repetition_levels_byte_length)
      builder.append(repetition_levels_byte_length);

    boolean present_is_compressed = true && (isSetIs_compressed());
    builder.append(present_is_compressed);
    if (present_is_compressed)
      builder.append(is_compressed);

    boolean present_statistics = true && (isSetStatistics());
    builder.append(present_statistics);
    if (present_statistics)
      builder.append(statistics);

    return builder.toHashCode();
  }

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

    int lastComparison = 0;
    DataPageHeaderV2 typedOther = (DataPageHeaderV2)other;

    lastComparison = Boolean.valueOf(isSetNum_values()).compareTo(typedOther.isSetNum_values());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_values()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_values, typedOther.num_values);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNum_nulls()).compareTo(typedOther.isSetNum_nulls());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_nulls()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_nulls, typedOther.num_nulls);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNum_rows()).compareTo(typedOther.isSetNum_rows());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_rows()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_rows, typedOther.num_rows);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEncoding()).compareTo(typedOther.isSetEncoding());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEncoding()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encoding, typedOther.encoding);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDefinition_levels_byte_length()).compareTo(typedOther.isSetDefinition_levels_byte_length());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDefinition_levels_byte_length()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.definition_levels_byte_length, typedOther.definition_levels_byte_length);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRepetition_levels_byte_length()).compareTo(typedOther.isSetRepetition_levels_byte_length());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRepetition_levels_byte_length()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.repetition_levels_byte_length, typedOther.repetition_levels_byte_length);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIs_compressed()).compareTo(typedOther.isSetIs_compressed());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIs_compressed()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.is_compressed, typedOther.is_compressed);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStatistics()).compareTo(typedOther.isSetStatistics());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStatistics()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statistics, typedOther.statistics);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

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

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
        break;
      }
      switch (field.id) {
        case 1: // NUM_VALUES
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.num_values = iprot.readI32();
            setNum_valuesIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // NUM_NULLS
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.num_nulls = iprot.readI32();
            setNum_nullsIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // NUM_ROWS
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.num_rows = iprot.readI32();
            setNum_rowsIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // ENCODING
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.encoding = Encoding.findByValue(iprot.readI32());
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // DEFINITION_LEVELS_BYTE_LENGTH
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.definition_levels_byte_length = iprot.readI32();
            setDefinition_levels_byte_lengthIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 6: // REPETITION_LEVELS_BYTE_LENGTH
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.repetition_levels_byte_length = iprot.readI32();
            setRepetition_levels_byte_lengthIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 7: // IS_COMPRESSED
          if (field.type == org.apache.thrift.protocol.TType.BOOL) {
            this.is_compressed = iprot.readBool();
            setIs_compressedIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 8: // STATISTICS
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.statistics = new Statistics();
            this.statistics.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    if (!isSetNum_values()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_values' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetNum_nulls()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_nulls' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetNum_rows()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_rows' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetDefinition_levels_byte_length()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'definition_levels_byte_length' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetRepetition_levels_byte_length()) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'repetition_levels_byte_length' was not found in serialized data! Struct: " + toString());
    }
    validate();
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(NUM_VALUES_FIELD_DESC);
    oprot.writeI32(this.num_values);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(NUM_NULLS_FIELD_DESC);
    oprot.writeI32(this.num_nulls);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(NUM_ROWS_FIELD_DESC);
    oprot.writeI32(this.num_rows);
    oprot.writeFieldEnd();
    if (this.encoding != null) {
      oprot.writeFieldBegin(ENCODING_FIELD_DESC);
      oprot.writeI32(this.encoding.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(DEFINITION_LEVELS_BYTE_LENGTH_FIELD_DESC);
    oprot.writeI32(this.definition_levels_byte_length);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(REPETITION_LEVELS_BYTE_LENGTH_FIELD_DESC);
    oprot.writeI32(this.repetition_levels_byte_length);
    oprot.writeFieldEnd();
    if (isSetIs_compressed()) {
      oprot.writeFieldBegin(IS_COMPRESSED_FIELD_DESC);
      oprot.writeBool(this.is_compressed);
      oprot.writeFieldEnd();
    }
    if (this.statistics != null) {
      if (isSetStatistics()) {
        oprot.writeFieldBegin(STATISTICS_FIELD_DESC);
        this.statistics.write(oprot);
        oprot.writeFieldEnd();
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("num_values:");
    sb.append(this.num_values);
    first = false;
    if (!first) sb.append(", ");
    sb.append("num_nulls:");
    sb.append(this.num_nulls);
    first = false;
    if (!first) sb.append(", ");
    sb.append("num_rows:");
    sb.append(this.num_rows);
    first = false;
    if (!first) sb.append(", ");
    sb.append("encoding:");
    if (this.encoding == null) {
      sb.append("null");
    } else {
      sb.append(this.encoding);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("definition_levels_byte_length:");
    sb.append(this.definition_levels_byte_length);
    first = false;
    if (!first) sb.append(", ");
    sb.append("repetition_levels_byte_length:");
    sb.append(this.repetition_levels_byte_length);
    first = false;
    if (isSetIs_compressed()) {
      if (!first) sb.append(", ");
      sb.append("is_compressed:");
      sb.append(this.is_compressed);
      first = false;
    }
    if (isSetStatistics()) {
      if (!first) sb.append(", ");
      sb.append("statistics:");
      if (this.statistics == null) {
        sb.append("null");
      } else {
        sb.append(this.statistics);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // alas, we cannot check 'num_values' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'num_nulls' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'num_rows' because it's a primitive and you chose the non-beans generator.
    if (encoding == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'encoding' was not present! Struct: " + toString());
    }
    // alas, we cannot check 'definition_levels_byte_length' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'repetition_levels_byte_length' because it's a primitive and you chose the non-beans generator.
  }

  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, 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_bit_vector = new BitSet(1);
      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);
    }
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy