Package parquet.format

Source Code of parquet.format.Statistics

/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package parquet.format;

import com.facebook.presto.hive.shaded.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 com.facebook.presto.hive.shaded.org.slf4j.Logger;
import com.facebook.presto.hive.shaded.org.slf4j.LoggerFactory;

import com.facebook.presto.hive.shaded.org.apache.thrift.*;
import com.facebook.presto.hive.shaded.org.apache.thrift.async.*;
import com.facebook.presto.hive.shaded.org.apache.thrift.meta_data.*;
import com.facebook.presto.hive.shaded.org.apache.thrift.transport.*;
import com.facebook.presto.hive.shaded.org.apache.thrift.protocol.*;

/**
* Statistics per row group and per page
* All fields are optional.
*/
public class Statistics implements TBase<Statistics, Statistics._Fields>, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("Statistics");

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

  /**
   * min and max value of the column, encoded in PLAIN encoding
   */
  public ByteBuffer max;
  public ByteBuffer min;
  /**
   * count of null value in the column
   */
  public long null_count;
  /**
   * count of dictinct values occuring
   */
  public long distinct_count;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements 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 dictinct values occuring
     */
    DISTINCT_COUNT((short)4, "distinct_count");

    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

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

  public Statistics() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Statistics(Statistics other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetMax()) {
      this.max = TBaseHelper.copyBinary(other.max);
;
    }
    if (other.isSetMin()) {
      this.min = 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(TBaseHelper.rightSize(max));
    return max.array();
  }

  public ByteBuffer BufferForMax() {
    return max;
  }

  /**
   * min and max value of the column, encoded in PLAIN encoding
   */
  public Statistics setMax(byte[] max) {
    setMax(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 asigned 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(TBaseHelper.rightSize(min));
    return min.array();
  }

  public ByteBuffer BufferForMin() {
    return min;
  }

  public Statistics setMin(byte[] min) {
    setMin(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 asigned 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 asigned 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 dictinct values occuring
   */
  public long getDistinct_count() {
    return this.distinct_count;
  }

  /**
   * count of dictinct values occuring
   */
  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 asigned 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 new Long(getNull_count());

    case DISTINCT_COUNT:
      return new Long(getDistinct_count());

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned 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 = 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 = 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 = 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 = 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(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) {
        break;
      }
      switch (field.id) {
        case 1: // MAX
          if (field.type == TType.STRING) {
            this.max = iprot.readBinary();
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // MIN
          if (field.type == TType.STRING) {
            this.min = iprot.readBinary();
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // NULL_COUNT
          if (field.type == TType.I64) {
            this.null_count = iprot.readI64();
            setNull_countIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // DISTINCT_COUNT
          if (field.type == TType.I64) {
            this.distinct_count = iprot.readI64();
            setDistinct_countIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          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(TProtocol oprot) throws 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 {
        TBaseHelper.toString(this.max, sb);
      }
      first = false;
    }
    if (isSetMin()) {
      if (!first) sb.append(", ");
      sb.append("min:");
      if (this.min == null) {
        sb.append("null");
      } else {
        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 TException {
    // check for required fields
  }

}
TOP

Related Classes of parquet.format.Statistics

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.