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

org.apache.parquet.format.Statistics 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;

/**
 * Statistics per row group and per page
 * All fields are optional.
 */
public class Statistics 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("Statistics");

  private static final org.apache.thrift.protocol.TField MAX_FIELD_DESC = new org.apache.thrift.protocol.TField("max", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField MIN_FIELD_DESC = new org.apache.thrift.protocol.TField("min", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField NULL_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("null_count", org.apache.thrift.protocol.TType.I64, (short)3);
  private static final org.apache.thrift.protocol.TField DISTINCT_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("distinct_count", org.apache.thrift.protocol.TType.I64, (short)4);

  /**
   * min and max value of the column, encoded in PLAIN encoding
   */
  public ByteBuffer max; // required
  public ByteBuffer min; // required
  /**
   * count of null value in the column
   */
  public long null_count; // required
  /**
   * count of distinct values occurring
   */
  public long distinct_count; // 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 {
    /**
     * min and max value of the column, encoded in PLAIN encoding
     */
    MAX((short)1, "max"),
    MIN((short)2, "min"),
    /**
     * count of null value in the column
     */
    NULL_COUNT((short)3, "null_count"),
    /**
     * count of distinct values occurring
     */
    DISTINCT_COUNT((short)4, "distinct_count");

    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: // MAX
          return MAX;
        case 2: // MIN
          return MIN;
        case 3: // NULL_COUNT
          return NULL_COUNT;
        case 4: // DISTINCT_COUNT
          return DISTINCT_COUNT;
        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 __NULL_COUNT_ISSET_ID = 0;
  private static final int __DISTINCT_COUNT_ISSET_ID = 1;
  private BitSet __isset_bit_vector = new BitSet(2);

  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.MAX, new org.apache.thrift.meta_data.FieldMetaData("max", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
    tmpMap.put(_Fields.MIN, new org.apache.thrift.meta_data.FieldMetaData("min", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
    tmpMap.put(_Fields.NULL_COUNT, new org.apache.thrift.meta_data.FieldMetaData("null_count", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.DISTINCT_COUNT, new org.apache.thrift.meta_data.FieldMetaData("distinct_count", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Statistics.class, metaDataMap);
  }

  public Statistics() {
  }

  /**
   * Performs a deep copy on other.
   */
  public Statistics(Statistics other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetMax()) {
      this.max = org.apache.thrift.TBaseHelper.copyBinary(other.max);
;
    }
    if (other.isSetMin()) {
      this.min = org.apache.thrift.TBaseHelper.copyBinary(other.min);
;
    }
    this.null_count = other.null_count;
    this.distinct_count = other.distinct_count;
  }

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

  @Override
  public void clear() {
    this.max = null;
    this.min = null;
    setNull_countIsSet(false);
    this.null_count = 0;
    setDistinct_countIsSet(false);
    this.distinct_count = 0;
  }

  /**
   * min and max value of the column, encoded in PLAIN encoding
   */
  public byte[] getMax() {
    setMax(org.apache.thrift.TBaseHelper.rightSize(max));
    return max == null ? null : max.array();
  }

  public ByteBuffer bufferForMax() {
    return max;
  }

  /**
   * min and max value of the column, encoded in PLAIN encoding
   */
  public Statistics setMax(byte[] max) {
    setMax(max == null ? (ByteBuffer)null : ByteBuffer.wrap(max));
    return this;
  }

  public Statistics setMax(ByteBuffer max) {
    this.max = max;
    return this;
  }

  public void unsetMax() {
    this.max = null;
  }

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

  public void setMaxIsSet(boolean value) {
    if (!value) {
      this.max = null;
    }
  }

  public byte[] getMin() {
    setMin(org.apache.thrift.TBaseHelper.rightSize(min));
    return min == null ? null : min.array();
  }

  public ByteBuffer bufferForMin() {
    return min;
  }

  public Statistics setMin(byte[] min) {
    setMin(min == null ? (ByteBuffer)null : ByteBuffer.wrap(min));
    return this;
  }

  public Statistics setMin(ByteBuffer min) {
    this.min = min;
    return this;
  }

  public void unsetMin() {
    this.min = null;
  }

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

  public void setMinIsSet(boolean value) {
    if (!value) {
      this.min = null;
    }
  }

  /**
   * count of null value in the column
   */
  public long getNull_count() {
    return this.null_count;
  }

  /**
   * count of null value in the column
   */
  public Statistics setNull_count(long null_count) {
    this.null_count = null_count;
    setNull_countIsSet(true);
    return this;
  }

  public void unsetNull_count() {
    __isset_bit_vector.clear(__NULL_COUNT_ISSET_ID);
  }

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

  public void setNull_countIsSet(boolean value) {
    __isset_bit_vector.set(__NULL_COUNT_ISSET_ID, value);
  }

  /**
   * count of distinct values occurring
   */
  public long getDistinct_count() {
    return this.distinct_count;
  }

  /**
   * count of distinct values occurring
   */
  public Statistics setDistinct_count(long distinct_count) {
    this.distinct_count = distinct_count;
    setDistinct_countIsSet(true);
    return this;
  }

  public void unsetDistinct_count() {
    __isset_bit_vector.clear(__DISTINCT_COUNT_ISSET_ID);
  }

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

  public void setDistinct_countIsSet(boolean value) {
    __isset_bit_vector.set(__DISTINCT_COUNT_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case MAX:
      if (value == null) {
        unsetMax();
      } else {
        setMax((ByteBuffer)value);
      }
      break;

    case MIN:
      if (value == null) {
        unsetMin();
      } else {
        setMin((ByteBuffer)value);
      }
      break;

    case NULL_COUNT:
      if (value == null) {
        unsetNull_count();
      } else {
        setNull_count((Long)value);
      }
      break;

    case DISTINCT_COUNT:
      if (value == null) {
        unsetDistinct_count();
      } else {
        setDistinct_count((Long)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case MAX:
      return getMax();

    case MIN:
      return getMin();

    case NULL_COUNT:
      return Long.valueOf(getNull_count());

    case DISTINCT_COUNT:
      return Long.valueOf(getDistinct_count());

    }
    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 MAX:
      return isSetMax();
    case MIN:
      return isSetMin();
    case NULL_COUNT:
      return isSetNull_count();
    case DISTINCT_COUNT:
      return isSetDistinct_count();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_max = true && this.isSetMax();
    boolean that_present_max = true && that.isSetMax();
    if (this_present_max || that_present_max) {
      if (!(this_present_max && that_present_max))
        return false;
      if (!this.max.equals(that.max))
        return false;
    }

    boolean this_present_min = true && this.isSetMin();
    boolean that_present_min = true && that.isSetMin();
    if (this_present_min || that_present_min) {
      if (!(this_present_min && that_present_min))
        return false;
      if (!this.min.equals(that.min))
        return false;
    }

    boolean this_present_null_count = true && this.isSetNull_count();
    boolean that_present_null_count = true && that.isSetNull_count();
    if (this_present_null_count || that_present_null_count) {
      if (!(this_present_null_count && that_present_null_count))
        return false;
      if (this.null_count != that.null_count)
        return false;
    }

    boolean this_present_distinct_count = true && this.isSetDistinct_count();
    boolean that_present_distinct_count = true && that.isSetDistinct_count();
    if (this_present_distinct_count || that_present_distinct_count) {
      if (!(this_present_distinct_count && that_present_distinct_count))
        return false;
      if (this.distinct_count != that.distinct_count)
        return false;
    }

    return true;
  }

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

    boolean present_max = true && (isSetMax());
    builder.append(present_max);
    if (present_max)
      builder.append(max);

    boolean present_min = true && (isSetMin());
    builder.append(present_min);
    if (present_min)
      builder.append(min);

    boolean present_null_count = true && (isSetNull_count());
    builder.append(present_null_count);
    if (present_null_count)
      builder.append(null_count);

    boolean present_distinct_count = true && (isSetDistinct_count());
    builder.append(present_distinct_count);
    if (present_distinct_count)
      builder.append(distinct_count);

    return builder.toHashCode();
  }

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

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

    lastComparison = Boolean.valueOf(isSetMax()).compareTo(typedOther.isSetMax());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMax()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.max, typedOther.max);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMin()).compareTo(typedOther.isSetMin());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMin()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.min, typedOther.min);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNull_count()).compareTo(typedOther.isSetNull_count());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNull_count()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.null_count, typedOther.null_count);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDistinct_count()).compareTo(typedOther.isSetDistinct_count());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDistinct_count()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.distinct_count, typedOther.distinct_count);
      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: // MAX
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.max = iprot.readBinary();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // MIN
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.min = iprot.readBinary();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // NULL_COUNT
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.null_count = iprot.readI64();
            setNull_countIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // DISTINCT_COUNT
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.distinct_count = iprot.readI64();
            setDistinct_countIsSet(true);
          } 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
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.max != null) {
      if (isSetMax()) {
        oprot.writeFieldBegin(MAX_FIELD_DESC);
        oprot.writeBinary(this.max);
        oprot.writeFieldEnd();
      }
    }
    if (this.min != null) {
      if (isSetMin()) {
        oprot.writeFieldBegin(MIN_FIELD_DESC);
        oprot.writeBinary(this.min);
        oprot.writeFieldEnd();
      }
    }
    if (isSetNull_count()) {
      oprot.writeFieldBegin(NULL_COUNT_FIELD_DESC);
      oprot.writeI64(this.null_count);
      oprot.writeFieldEnd();
    }
    if (isSetDistinct_count()) {
      oprot.writeFieldBegin(DISTINCT_COUNT_FIELD_DESC);
      oprot.writeI64(this.distinct_count);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    if (isSetMax()) {
      sb.append("max:");
      if (this.max == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.max, sb);
      }
      first = false;
    }
    if (isSetMin()) {
      if (!first) sb.append(", ");
      sb.append("min:");
      if (this.min == null) {
        sb.append("null");
      } else {
        org.apache.thrift.TBaseHelper.toString(this.min, sb);
      }
      first = false;
    }
    if (isSetNull_count()) {
      if (!first) sb.append(", ");
      sb.append("null_count:");
      sb.append(this.null_count);
      first = false;
    }
    if (isSetDistinct_count()) {
      if (!first) sb.append(", ");
      sb.append("distinct_count:");
      sb.append(this.distinct_count);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

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

  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