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.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.parquet.format;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.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"})
/**
 * New page format allowing 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
 * 
 */
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-10-17")
public class DataPageHeaderV2 implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
  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);

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

  /**
   * 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 definition levels
   */
  public int definition_levels_byte_length; // required
  /**
   * length of the repetition 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; // optional
  /**
   * optional statistics for this column chunk
   */
  public Statistics statistics; // 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 {
    /**
     * 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 definition levels
     */
    DEFINITION_LEVELS_BYTE_LENGTH((short)5, "definition_levels_byte_length"),
    /**
     * length of the repetition 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 byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.IS_COMPRESSED,_Fields.STATISTICS};
  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_bitfield = other.__isset_bitfield;
    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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __NUM_VALUES_ISSET_ID);
  }

  public void setNum_valuesIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __NUM_NULLS_ISSET_ID);
  }

  public void setNum_nullsIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __NUM_ROWS_ISSET_ID);
  }

  public void setNum_rowsIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __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 definition levels
   */
  public int getDefinition_levels_byte_length() {
    return this.definition_levels_byte_length;
  }

  /**
   * length of the definition 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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  public void setDefinition_levels_byte_lengthIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __DEFINITION_LEVELS_BYTE_LENGTH_ISSET_ID, value);
  }

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

  /**
   * length of the repetition 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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __REPETITION_LEVELS_BYTE_LENGTH_ISSET_ID);
  }

  public void setRepetition_levels_byte_lengthIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __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_bitfield = EncodingUtils.clearBit(__isset_bitfield, __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 EncodingUtils.testBit(__isset_bitfield, __IS_COMPRESSED_ISSET_ID);
  }

  public void setIs_compressedIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __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 getNum_values();

    case NUM_NULLS:
      return getNum_nulls();

    case NUM_ROWS:
      return getNum_rows();

    case ENCODING:
      return getEncoding();

    case DEFINITION_LEVELS_BYTE_LENGTH:
      return getDefinition_levels_byte_length();

    case REPETITION_LEVELS_BYTE_LENGTH:
      return getRepetition_levels_byte_length();

    case IS_COMPRESSED:
      return 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() {
    List list = new ArrayList();

    boolean present_num_values = true;
    list.add(present_num_values);
    if (present_num_values)
      list.add(num_values);

    boolean present_num_nulls = true;
    list.add(present_num_nulls);
    if (present_num_nulls)
      list.add(num_nulls);

    boolean present_num_rows = true;
    list.add(present_num_rows);
    if (present_num_rows)
      list.add(num_rows);

    boolean present_encoding = true && (isSetEncoding());
    list.add(present_encoding);
    if (present_encoding)
      list.add(encoding.getValue());

    boolean present_definition_levels_byte_length = true;
    list.add(present_definition_levels_byte_length);
    if (present_definition_levels_byte_length)
      list.add(definition_levels_byte_length);

    boolean present_repetition_levels_byte_length = true;
    list.add(present_repetition_levels_byte_length);
    if (present_repetition_levels_byte_length)
      list.add(repetition_levels_byte_length);

    boolean present_is_compressed = true && (isSetIs_compressed());
    list.add(present_is_compressed);
    if (present_is_compressed)
      list.add(is_compressed);

    boolean present_statistics = true && (isSetStatistics());
    list.add(present_statistics);
    if (present_statistics)
      list.add(statistics);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetNum_values()).compareTo(other.isSetNum_values());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_values()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_values, other.num_values);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNum_nulls()).compareTo(other.isSetNum_nulls());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_nulls()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_nulls, other.num_nulls);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNum_rows()).compareTo(other.isSetNum_rows());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNum_rows()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.num_rows, other.num_rows);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEncoding()).compareTo(other.isSetEncoding());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEncoding()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encoding, other.encoding);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDefinition_levels_byte_length()).compareTo(other.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, other.definition_levels_byte_length);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRepetition_levels_byte_length()).compareTo(other.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, other.repetition_levels_byte_length);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIs_compressed()).compareTo(other.isSetIs_compressed());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIs_compressed()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.is_compressed, other.is_compressed);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStatistics()).compareTo(other.isSetStatistics());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStatistics()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statistics, other.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 {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

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

  @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.
    // check for sub-struct validity
    if (statistics != null) {
      statistics.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, 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 DataPageHeaderV2StandardSchemeFactory implements SchemeFactory {
    public DataPageHeaderV2StandardScheme getScheme() {
      return new DataPageHeaderV2StandardScheme();
    }
  }

  private static class DataPageHeaderV2StandardScheme extends StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, DataPageHeaderV2 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: // NUM_VALUES
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.num_values = iprot.readI32();
              struct.setNum_valuesIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // NUM_NULLS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.num_nulls = iprot.readI32();
              struct.setNum_nullsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // NUM_ROWS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.num_rows = iprot.readI32();
              struct.setNum_rowsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // ENCODING
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.encoding = org.apache.parquet.format.Encoding.findByValue(iprot.readI32());
              struct.setEncodingIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // DEFINITION_LEVELS_BYTE_LENGTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.definition_levels_byte_length = iprot.readI32();
              struct.setDefinition_levels_byte_lengthIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // REPETITION_LEVELS_BYTE_LENGTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.repetition_levels_byte_length = iprot.readI32();
              struct.setRepetition_levels_byte_lengthIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // IS_COMPRESSED
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.is_compressed = iprot.readBool();
              struct.setIs_compressedIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // STATISTICS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.statistics = new Statistics();
              struct.statistics.read(iprot);
              struct.setStatisticsIsSet(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
      if (!struct.isSetNum_values()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_values' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetNum_nulls()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_nulls' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetNum_rows()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'num_rows' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.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 (!struct.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());
      }
      struct.validate();
    }

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

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

  }

  private static class DataPageHeaderV2TupleSchemeFactory implements SchemeFactory {
    public DataPageHeaderV2TupleScheme getScheme() {
      return new DataPageHeaderV2TupleScheme();
    }
  }

  private static class DataPageHeaderV2TupleScheme extends TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, DataPageHeaderV2 struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      oprot.writeI32(struct.num_values);
      oprot.writeI32(struct.num_nulls);
      oprot.writeI32(struct.num_rows);
      oprot.writeI32(struct.encoding.getValue());
      oprot.writeI32(struct.definition_levels_byte_length);
      oprot.writeI32(struct.repetition_levels_byte_length);
      BitSet optionals = new BitSet();
      if (struct.isSetIs_compressed()) {
        optionals.set(0);
      }
      if (struct.isSetStatistics()) {
        optionals.set(1);
      }
      oprot.writeBitSet(optionals, 2);
      if (struct.isSetIs_compressed()) {
        oprot.writeBool(struct.is_compressed);
      }
      if (struct.isSetStatistics()) {
        struct.statistics.write(oprot);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, DataPageHeaderV2 struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      struct.num_values = iprot.readI32();
      struct.setNum_valuesIsSet(true);
      struct.num_nulls = iprot.readI32();
      struct.setNum_nullsIsSet(true);
      struct.num_rows = iprot.readI32();
      struct.setNum_rowsIsSet(true);
      struct.encoding = org.apache.parquet.format.Encoding.findByValue(iprot.readI32());
      struct.setEncodingIsSet(true);
      struct.definition_levels_byte_length = iprot.readI32();
      struct.setDefinition_levels_byte_lengthIsSet(true);
      struct.repetition_levels_byte_length = iprot.readI32();
      struct.setRepetition_levels_byte_lengthIsSet(true);
      BitSet incoming = iprot.readBitSet(2);
      if (incoming.get(0)) {
        struct.is_compressed = iprot.readBool();
        struct.setIs_compressedIsSet(true);
      }
      if (incoming.get(1)) {
        struct.statistics = new Statistics();
        struct.statistics.read(iprot);
        struct.setStatisticsIsSet(true);
      }
    }
  }

}