/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.vesoft.nebula.graph;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import com.facebook.thrift.*;
import com.facebook.thrift.annotations.*;
import com.facebook.thrift.async.*;
import com.facebook.thrift.meta_data.*;
import com.facebook.thrift.server.*;
import com.facebook.thrift.transport.*;
import com.facebook.thrift.protocol.*;

@SuppressWarnings({ "unused", "serial" })
public class ProfilingStats implements TBase, java.io.Serializable, Cloneable, Comparable<ProfilingStats> {
  private static final TStruct STRUCT_DESC = new TStruct("ProfilingStats");
  private static final TField ROWS_FIELD_DESC = new TField("rows", TType.I64, (short)1);
  private static final TField EXEC_DURATION_IN_US_FIELD_DESC = new TField("exec_duration_in_us", TType.I64, (short)2);
  private static final TField TOTAL_DURATION_IN_US_FIELD_DESC = new TField("total_duration_in_us", TType.I64, (short)3);
  private static final TField OTHER_STATS_FIELD_DESC = new TField("other_stats", TType.MAP, (short)4);

  public long rows;
  public long exec_duration_in_us;
  public long total_duration_in_us;
  public Map<byte[],byte[]> other_stats;
  public static final int ROWS = 1;
  public static final int EXEC_DURATION_IN_US = 2;
  public static final int TOTAL_DURATION_IN_US = 3;
  public static final int OTHER_STATS = 4;

  // isset id assignments
  private static final int __ROWS_ISSET_ID = 0;
  private static final int __EXEC_DURATION_IN_US_ISSET_ID = 1;
  private static final int __TOTAL_DURATION_IN_US_ISSET_ID = 2;
  private BitSet __isset_bit_vector = new BitSet(3);

  public static final Map<Integer, FieldMetaData> metaDataMap;

  static {
    Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
    tmpMetaDataMap.put(ROWS, new FieldMetaData("rows", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(EXEC_DURATION_IN_US, new FieldMetaData("exec_duration_in_us", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(TOTAL_DURATION_IN_US, new FieldMetaData("total_duration_in_us", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(OTHER_STATS, new FieldMetaData("other_stats", TFieldRequirementType.OPTIONAL, 
        new MapMetaData(TType.MAP, 
            new FieldValueMetaData(TType.STRING), 
            new FieldValueMetaData(TType.STRING))));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

  static {
    FieldMetaData.addStructMetaDataMap(ProfilingStats.class, metaDataMap);
  }

  public ProfilingStats() {
  }

  public ProfilingStats(
      long rows,
      long exec_duration_in_us,
      long total_duration_in_us) {
    this();
    this.rows = rows;
    setRowsIsSet(true);
    this.exec_duration_in_us = exec_duration_in_us;
    setExec_duration_in_usIsSet(true);
    this.total_duration_in_us = total_duration_in_us;
    setTotal_duration_in_usIsSet(true);
  }

  public ProfilingStats(
      long rows,
      long exec_duration_in_us,
      long total_duration_in_us,
      Map<byte[],byte[]> other_stats) {
    this();
    this.rows = rows;
    setRowsIsSet(true);
    this.exec_duration_in_us = exec_duration_in_us;
    setExec_duration_in_usIsSet(true);
    this.total_duration_in_us = total_duration_in_us;
    setTotal_duration_in_usIsSet(true);
    this.other_stats = other_stats;
  }

  public static class Builder {
    private long rows;
    private long exec_duration_in_us;
    private long total_duration_in_us;
    private Map<byte[],byte[]> other_stats;

    BitSet __optional_isset = new BitSet(3);

    public Builder() {
    }

    public Builder setRows(final long rows) {
      this.rows = rows;
      __optional_isset.set(__ROWS_ISSET_ID, true);
      return this;
    }

    public Builder setExec_duration_in_us(final long exec_duration_in_us) {
      this.exec_duration_in_us = exec_duration_in_us;
      __optional_isset.set(__EXEC_DURATION_IN_US_ISSET_ID, true);
      return this;
    }

    public Builder setTotal_duration_in_us(final long total_duration_in_us) {
      this.total_duration_in_us = total_duration_in_us;
      __optional_isset.set(__TOTAL_DURATION_IN_US_ISSET_ID, true);
      return this;
    }

    public Builder setOther_stats(final Map<byte[],byte[]> other_stats) {
      this.other_stats = other_stats;
      return this;
    }

    public ProfilingStats build() {
      ProfilingStats result = new ProfilingStats();
      if (__optional_isset.get(__ROWS_ISSET_ID)) {
        result.setRows(this.rows);
      }
      if (__optional_isset.get(__EXEC_DURATION_IN_US_ISSET_ID)) {
        result.setExec_duration_in_us(this.exec_duration_in_us);
      }
      if (__optional_isset.get(__TOTAL_DURATION_IN_US_ISSET_ID)) {
        result.setTotal_duration_in_us(this.total_duration_in_us);
      }
      result.setOther_stats(this.other_stats);
      return result;
    }
  }

  public static Builder builder() {
    return new Builder();
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public ProfilingStats(ProfilingStats other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.rows = TBaseHelper.deepCopy(other.rows);
    this.exec_duration_in_us = TBaseHelper.deepCopy(other.exec_duration_in_us);
    this.total_duration_in_us = TBaseHelper.deepCopy(other.total_duration_in_us);
    if (other.isSetOther_stats()) {
      this.other_stats = TBaseHelper.deepCopy(other.other_stats);
    }
  }

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

  public long getRows() {
    return this.rows;
  }

  public ProfilingStats setRows(long rows) {
    this.rows = rows;
    setRowsIsSet(true);
    return this;
  }

  public void unsetRows() {
    __isset_bit_vector.clear(__ROWS_ISSET_ID);
  }

  // Returns true if field rows is set (has been assigned a value) and false otherwise
  public boolean isSetRows() {
    return __isset_bit_vector.get(__ROWS_ISSET_ID);
  }

  public void setRowsIsSet(boolean __value) {
    __isset_bit_vector.set(__ROWS_ISSET_ID, __value);
  }

  public long getExec_duration_in_us() {
    return this.exec_duration_in_us;
  }

  public ProfilingStats setExec_duration_in_us(long exec_duration_in_us) {
    this.exec_duration_in_us = exec_duration_in_us;
    setExec_duration_in_usIsSet(true);
    return this;
  }

  public void unsetExec_duration_in_us() {
    __isset_bit_vector.clear(__EXEC_DURATION_IN_US_ISSET_ID);
  }

  // Returns true if field exec_duration_in_us is set (has been assigned a value) and false otherwise
  public boolean isSetExec_duration_in_us() {
    return __isset_bit_vector.get(__EXEC_DURATION_IN_US_ISSET_ID);
  }

  public void setExec_duration_in_usIsSet(boolean __value) {
    __isset_bit_vector.set(__EXEC_DURATION_IN_US_ISSET_ID, __value);
  }

  public long getTotal_duration_in_us() {
    return this.total_duration_in_us;
  }

  public ProfilingStats setTotal_duration_in_us(long total_duration_in_us) {
    this.total_duration_in_us = total_duration_in_us;
    setTotal_duration_in_usIsSet(true);
    return this;
  }

  public void unsetTotal_duration_in_us() {
    __isset_bit_vector.clear(__TOTAL_DURATION_IN_US_ISSET_ID);
  }

  // Returns true if field total_duration_in_us is set (has been assigned a value) and false otherwise
  public boolean isSetTotal_duration_in_us() {
    return __isset_bit_vector.get(__TOTAL_DURATION_IN_US_ISSET_ID);
  }

  public void setTotal_duration_in_usIsSet(boolean __value) {
    __isset_bit_vector.set(__TOTAL_DURATION_IN_US_ISSET_ID, __value);
  }

  public Map<byte[],byte[]> getOther_stats() {
    return this.other_stats;
  }

  public ProfilingStats setOther_stats(Map<byte[],byte[]> other_stats) {
    this.other_stats = other_stats;
    return this;
  }

  public void unsetOther_stats() {
    this.other_stats = null;
  }

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

  public void setOther_statsIsSet(boolean __value) {
    if (!__value) {
      this.other_stats = null;
    }
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case ROWS:
      if (__value == null) {
        unsetRows();
      } else {
        setRows((Long)__value);
      }
      break;

    case EXEC_DURATION_IN_US:
      if (__value == null) {
        unsetExec_duration_in_us();
      } else {
        setExec_duration_in_us((Long)__value);
      }
      break;

    case TOTAL_DURATION_IN_US:
      if (__value == null) {
        unsetTotal_duration_in_us();
      } else {
        setTotal_duration_in_us((Long)__value);
      }
      break;

    case OTHER_STATS:
      if (__value == null) {
        unsetOther_stats();
      } else {
        setOther_stats((Map<byte[],byte[]>)__value);
      }
      break;

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case ROWS:
      return new Long(getRows());

    case EXEC_DURATION_IN_US:
      return new Long(getExec_duration_in_us());

    case TOTAL_DURATION_IN_US:
      return new Long(getTotal_duration_in_us());

    case OTHER_STATS:
      return getOther_stats();

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

  @Override
  public boolean equals(Object _that) {
    if (_that == null)
      return false;
    if (this == _that)
      return true;
    if (!(_that instanceof ProfilingStats))
      return false;
    ProfilingStats that = (ProfilingStats)_that;

    if (!TBaseHelper.equalsNobinary(this.rows, that.rows)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.exec_duration_in_us, that.exec_duration_in_us)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.total_duration_in_us, that.total_duration_in_us)) { return false; }

    if (!TBaseHelper.equalsSlow(this.isSetOther_stats(), that.isSetOther_stats(), this.other_stats, that.other_stats)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {rows, exec_duration_in_us, total_duration_in_us, other_stats});
  }

  @Override
  public int compareTo(ProfilingStats other) {
    if (other == null) {
      // See java.lang.Comparable docs
      throw new NullPointerException();
    }

    if (other == this) {
      return 0;
    }
    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetRows()).compareTo(other.isSetRows());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(rows, other.rows);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetExec_duration_in_us()).compareTo(other.isSetExec_duration_in_us());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(exec_duration_in_us, other.exec_duration_in_us);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetTotal_duration_in_us()).compareTo(other.isSetTotal_duration_in_us());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(total_duration_in_us, other.total_duration_in_us);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOther_stats()).compareTo(other.isSetOther_stats());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(other_stats, other.other_stats);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField __field;
    iprot.readStructBegin(metaDataMap);
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) { 
        break;
      }
      switch (__field.id)
      {
        case ROWS:
          if (__field.type == TType.I64) {
            this.rows = iprot.readI64();
            setRowsIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case EXEC_DURATION_IN_US:
          if (__field.type == TType.I64) {
            this.exec_duration_in_us = iprot.readI64();
            setExec_duration_in_usIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case TOTAL_DURATION_IN_US:
          if (__field.type == TType.I64) {
            this.total_duration_in_us = iprot.readI64();
            setTotal_duration_in_usIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OTHER_STATS:
          if (__field.type == TType.MAP) {
            {
              TMap _map0 = iprot.readMapBegin();
              this.other_stats = new HashMap<byte[],byte[]>(Math.max(0, 2*_map0.size));
              for (int _i1 = 0; 
                   (_map0.size < 0) ? iprot.peekMap() : (_i1 < _map0.size); 
                   ++_i1)
              {
                byte[] _key2;
                byte[] _val3;
                _key2 = iprot.readBinary();
                _val3 = iprot.readBinary();
                this.other_stats.put(_key2, _val3);
              }
              iprot.readMapEnd();
            }
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();


    // check for required fields of primitive type, which can't be checked in the validate method
    if (!isSetRows()) {
      throw new TProtocolException("Required field 'rows' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetExec_duration_in_us()) {
      throw new TProtocolException("Required field 'exec_duration_in_us' was not found in serialized data! Struct: " + toString());
    }
    if (!isSetTotal_duration_in_us()) {
      throw new TProtocolException("Required field 'total_duration_in_us' was not found in serialized data! Struct: " + toString());
    }
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(ROWS_FIELD_DESC);
    oprot.writeI64(this.rows);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(EXEC_DURATION_IN_US_FIELD_DESC);
    oprot.writeI64(this.exec_duration_in_us);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(TOTAL_DURATION_IN_US_FIELD_DESC);
    oprot.writeI64(this.total_duration_in_us);
    oprot.writeFieldEnd();
    if (this.other_stats != null) {
      if (isSetOther_stats()) {
        oprot.writeFieldBegin(OTHER_STATS_FIELD_DESC);
        {
          oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.other_stats.size()));
          for (Map.Entry<byte[], byte[]> _iter4 : this.other_stats.entrySet())          {
            oprot.writeBinary(_iter4.getKey());
            oprot.writeBinary(_iter4.getValue());
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    return toString(1, true);
  }

  @Override
  public String toString(int indent, boolean prettyPrint) {
    String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : "";
    String newLine = prettyPrint ? "\n" : "";
    String space = prettyPrint ? " " : "";
    StringBuilder sb = new StringBuilder("ProfilingStats");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("rows");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getRows(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("exec_duration_in_us");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getExec_duration_in_us(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("total_duration_in_us");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getTotal_duration_in_us(), indent + 1, prettyPrint));
    first = false;
    if (isSetOther_stats())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("other_stats");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getOther_stats() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getOther_stats(), indent + 1, prettyPrint));
      }
      first = false;
    }
    sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
    // alas, we cannot check 'rows' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'exec_duration_in_us' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'total_duration_in_us' because it's a primitive and you chose the non-beans generator.
  }

}

