/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * 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.storm.generated;

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"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)")
public class TopologyStats implements org.apache.thrift.TBase<TopologyStats, TopologyStats._Fields>, java.io.Serializable, Cloneable, Comparable<TopologyStats> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TopologyStats");

  private static final org.apache.thrift.protocol.TField WINDOW_TO_EMITTED_FIELD_DESC = new org.apache.thrift.protocol.TField("window_to_emitted", org.apache.thrift.protocol.TType.MAP, (short)1);
  private static final org.apache.thrift.protocol.TField WINDOW_TO_TRANSFERRED_FIELD_DESC = new org.apache.thrift.protocol.TField("window_to_transferred", org.apache.thrift.protocol.TType.MAP, (short)2);
  private static final org.apache.thrift.protocol.TField WINDOW_TO_COMPLETE_LATENCIES_MS_FIELD_DESC = new org.apache.thrift.protocol.TField("window_to_complete_latencies_ms", org.apache.thrift.protocol.TType.MAP, (short)3);
  private static final org.apache.thrift.protocol.TField WINDOW_TO_ACKED_FIELD_DESC = new org.apache.thrift.protocol.TField("window_to_acked", org.apache.thrift.protocol.TType.MAP, (short)4);
  private static final org.apache.thrift.protocol.TField WINDOW_TO_FAILED_FIELD_DESC = new org.apache.thrift.protocol.TField("window_to_failed", org.apache.thrift.protocol.TType.MAP, (short)5);

  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new TopologyStatsStandardSchemeFactory());
    schemes.put(TupleScheme.class, new TopologyStatsTupleSchemeFactory());
  }

  private Map<String,Long> window_to_emitted; // optional
  private Map<String,Long> window_to_transferred; // optional
  private Map<String,Double> window_to_complete_latencies_ms; // optional
  private Map<String,Long> window_to_acked; // optional
  private Map<String,Long> window_to_failed; // 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 {
    WINDOW_TO_EMITTED((short)1, "window_to_emitted"),
    WINDOW_TO_TRANSFERRED((short)2, "window_to_transferred"),
    WINDOW_TO_COMPLETE_LATENCIES_MS((short)3, "window_to_complete_latencies_ms"),
    WINDOW_TO_ACKED((short)4, "window_to_acked"),
    WINDOW_TO_FAILED((short)5, "window_to_failed");

    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: // WINDOW_TO_EMITTED
          return WINDOW_TO_EMITTED;
        case 2: // WINDOW_TO_TRANSFERRED
          return WINDOW_TO_TRANSFERRED;
        case 3: // WINDOW_TO_COMPLETE_LATENCIES_MS
          return WINDOW_TO_COMPLETE_LATENCIES_MS;
        case 4: // WINDOW_TO_ACKED
          return WINDOW_TO_ACKED;
        case 5: // WINDOW_TO_FAILED
          return WINDOW_TO_FAILED;
        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 _Fields optionals[] = {_Fields.WINDOW_TO_EMITTED,_Fields.WINDOW_TO_TRANSFERRED,_Fields.WINDOW_TO_COMPLETE_LATENCIES_MS,_Fields.WINDOW_TO_ACKED,_Fields.WINDOW_TO_FAILED};
  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.WINDOW_TO_EMITTED, new org.apache.thrift.meta_data.FieldMetaData("window_to_emitted", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
    tmpMap.put(_Fields.WINDOW_TO_TRANSFERRED, new org.apache.thrift.meta_data.FieldMetaData("window_to_transferred", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
    tmpMap.put(_Fields.WINDOW_TO_COMPLETE_LATENCIES_MS, new org.apache.thrift.meta_data.FieldMetaData("window_to_complete_latencies_ms", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))));
    tmpMap.put(_Fields.WINDOW_TO_ACKED, new org.apache.thrift.meta_data.FieldMetaData("window_to_acked", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
    tmpMap.put(_Fields.WINDOW_TO_FAILED, new org.apache.thrift.meta_data.FieldMetaData("window_to_failed", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), 
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TopologyStats.class, metaDataMap);
  }

  public TopologyStats() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TopologyStats(TopologyStats other) {
    if (other.is_set_window_to_emitted()) {
      Map<String,Long> __this__window_to_emitted = new HashMap<String,Long>(other.window_to_emitted);
      this.window_to_emitted = __this__window_to_emitted;
    }
    if (other.is_set_window_to_transferred()) {
      Map<String,Long> __this__window_to_transferred = new HashMap<String,Long>(other.window_to_transferred);
      this.window_to_transferred = __this__window_to_transferred;
    }
    if (other.is_set_window_to_complete_latencies_ms()) {
      Map<String,Double> __this__window_to_complete_latencies_ms = new HashMap<String,Double>(other.window_to_complete_latencies_ms);
      this.window_to_complete_latencies_ms = __this__window_to_complete_latencies_ms;
    }
    if (other.is_set_window_to_acked()) {
      Map<String,Long> __this__window_to_acked = new HashMap<String,Long>(other.window_to_acked);
      this.window_to_acked = __this__window_to_acked;
    }
    if (other.is_set_window_to_failed()) {
      Map<String,Long> __this__window_to_failed = new HashMap<String,Long>(other.window_to_failed);
      this.window_to_failed = __this__window_to_failed;
    }
  }

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

  @Override
  public void clear() {
    this.window_to_emitted = null;
    this.window_to_transferred = null;
    this.window_to_complete_latencies_ms = null;
    this.window_to_acked = null;
    this.window_to_failed = null;
  }

  public int get_window_to_emitted_size() {
    return (this.window_to_emitted == null) ? 0 : this.window_to_emitted.size();
  }

  public void put_to_window_to_emitted(String key, long val) {
    if (this.window_to_emitted == null) {
      this.window_to_emitted = new HashMap<String,Long>();
    }
    this.window_to_emitted.put(key, val);
  }

  public Map<String,Long> get_window_to_emitted() {
    return this.window_to_emitted;
  }

  public void set_window_to_emitted(Map<String,Long> window_to_emitted) {
    this.window_to_emitted = window_to_emitted;
  }

  public void unset_window_to_emitted() {
    this.window_to_emitted = null;
  }

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

  public void set_window_to_emitted_isSet(boolean value) {
    if (!value) {
      this.window_to_emitted = null;
    }
  }

  public int get_window_to_transferred_size() {
    return (this.window_to_transferred == null) ? 0 : this.window_to_transferred.size();
  }

  public void put_to_window_to_transferred(String key, long val) {
    if (this.window_to_transferred == null) {
      this.window_to_transferred = new HashMap<String,Long>();
    }
    this.window_to_transferred.put(key, val);
  }

  public Map<String,Long> get_window_to_transferred() {
    return this.window_to_transferred;
  }

  public void set_window_to_transferred(Map<String,Long> window_to_transferred) {
    this.window_to_transferred = window_to_transferred;
  }

  public void unset_window_to_transferred() {
    this.window_to_transferred = null;
  }

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

  public void set_window_to_transferred_isSet(boolean value) {
    if (!value) {
      this.window_to_transferred = null;
    }
  }

  public int get_window_to_complete_latencies_ms_size() {
    return (this.window_to_complete_latencies_ms == null) ? 0 : this.window_to_complete_latencies_ms.size();
  }

  public void put_to_window_to_complete_latencies_ms(String key, double val) {
    if (this.window_to_complete_latencies_ms == null) {
      this.window_to_complete_latencies_ms = new HashMap<String,Double>();
    }
    this.window_to_complete_latencies_ms.put(key, val);
  }

  public Map<String,Double> get_window_to_complete_latencies_ms() {
    return this.window_to_complete_latencies_ms;
  }

  public void set_window_to_complete_latencies_ms(Map<String,Double> window_to_complete_latencies_ms) {
    this.window_to_complete_latencies_ms = window_to_complete_latencies_ms;
  }

  public void unset_window_to_complete_latencies_ms() {
    this.window_to_complete_latencies_ms = null;
  }

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

  public void set_window_to_complete_latencies_ms_isSet(boolean value) {
    if (!value) {
      this.window_to_complete_latencies_ms = null;
    }
  }

  public int get_window_to_acked_size() {
    return (this.window_to_acked == null) ? 0 : this.window_to_acked.size();
  }

  public void put_to_window_to_acked(String key, long val) {
    if (this.window_to_acked == null) {
      this.window_to_acked = new HashMap<String,Long>();
    }
    this.window_to_acked.put(key, val);
  }

  public Map<String,Long> get_window_to_acked() {
    return this.window_to_acked;
  }

  public void set_window_to_acked(Map<String,Long> window_to_acked) {
    this.window_to_acked = window_to_acked;
  }

  public void unset_window_to_acked() {
    this.window_to_acked = null;
  }

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

  public void set_window_to_acked_isSet(boolean value) {
    if (!value) {
      this.window_to_acked = null;
    }
  }

  public int get_window_to_failed_size() {
    return (this.window_to_failed == null) ? 0 : this.window_to_failed.size();
  }

  public void put_to_window_to_failed(String key, long val) {
    if (this.window_to_failed == null) {
      this.window_to_failed = new HashMap<String,Long>();
    }
    this.window_to_failed.put(key, val);
  }

  public Map<String,Long> get_window_to_failed() {
    return this.window_to_failed;
  }

  public void set_window_to_failed(Map<String,Long> window_to_failed) {
    this.window_to_failed = window_to_failed;
  }

  public void unset_window_to_failed() {
    this.window_to_failed = null;
  }

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

  public void set_window_to_failed_isSet(boolean value) {
    if (!value) {
      this.window_to_failed = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case WINDOW_TO_EMITTED:
      if (value == null) {
        unset_window_to_emitted();
      } else {
        set_window_to_emitted((Map<String,Long>)value);
      }
      break;

    case WINDOW_TO_TRANSFERRED:
      if (value == null) {
        unset_window_to_transferred();
      } else {
        set_window_to_transferred((Map<String,Long>)value);
      }
      break;

    case WINDOW_TO_COMPLETE_LATENCIES_MS:
      if (value == null) {
        unset_window_to_complete_latencies_ms();
      } else {
        set_window_to_complete_latencies_ms((Map<String,Double>)value);
      }
      break;

    case WINDOW_TO_ACKED:
      if (value == null) {
        unset_window_to_acked();
      } else {
        set_window_to_acked((Map<String,Long>)value);
      }
      break;

    case WINDOW_TO_FAILED:
      if (value == null) {
        unset_window_to_failed();
      } else {
        set_window_to_failed((Map<String,Long>)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case WINDOW_TO_EMITTED:
      return get_window_to_emitted();

    case WINDOW_TO_TRANSFERRED:
      return get_window_to_transferred();

    case WINDOW_TO_COMPLETE_LATENCIES_MS:
      return get_window_to_complete_latencies_ms();

    case WINDOW_TO_ACKED:
      return get_window_to_acked();

    case WINDOW_TO_FAILED:
      return get_window_to_failed();

    }
    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 WINDOW_TO_EMITTED:
      return is_set_window_to_emitted();
    case WINDOW_TO_TRANSFERRED:
      return is_set_window_to_transferred();
    case WINDOW_TO_COMPLETE_LATENCIES_MS:
      return is_set_window_to_complete_latencies_ms();
    case WINDOW_TO_ACKED:
      return is_set_window_to_acked();
    case WINDOW_TO_FAILED:
      return is_set_window_to_failed();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_window_to_emitted = true && this.is_set_window_to_emitted();
    boolean that_present_window_to_emitted = true && that.is_set_window_to_emitted();
    if (this_present_window_to_emitted || that_present_window_to_emitted) {
      if (!(this_present_window_to_emitted && that_present_window_to_emitted))
        return false;
      if (!this.window_to_emitted.equals(that.window_to_emitted))
        return false;
    }

    boolean this_present_window_to_transferred = true && this.is_set_window_to_transferred();
    boolean that_present_window_to_transferred = true && that.is_set_window_to_transferred();
    if (this_present_window_to_transferred || that_present_window_to_transferred) {
      if (!(this_present_window_to_transferred && that_present_window_to_transferred))
        return false;
      if (!this.window_to_transferred.equals(that.window_to_transferred))
        return false;
    }

    boolean this_present_window_to_complete_latencies_ms = true && this.is_set_window_to_complete_latencies_ms();
    boolean that_present_window_to_complete_latencies_ms = true && that.is_set_window_to_complete_latencies_ms();
    if (this_present_window_to_complete_latencies_ms || that_present_window_to_complete_latencies_ms) {
      if (!(this_present_window_to_complete_latencies_ms && that_present_window_to_complete_latencies_ms))
        return false;
      if (!this.window_to_complete_latencies_ms.equals(that.window_to_complete_latencies_ms))
        return false;
    }

    boolean this_present_window_to_acked = true && this.is_set_window_to_acked();
    boolean that_present_window_to_acked = true && that.is_set_window_to_acked();
    if (this_present_window_to_acked || that_present_window_to_acked) {
      if (!(this_present_window_to_acked && that_present_window_to_acked))
        return false;
      if (!this.window_to_acked.equals(that.window_to_acked))
        return false;
    }

    boolean this_present_window_to_failed = true && this.is_set_window_to_failed();
    boolean that_present_window_to_failed = true && that.is_set_window_to_failed();
    if (this_present_window_to_failed || that_present_window_to_failed) {
      if (!(this_present_window_to_failed && that_present_window_to_failed))
        return false;
      if (!this.window_to_failed.equals(that.window_to_failed))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List<Object> list = new ArrayList<Object>();

    boolean present_window_to_emitted = true && (is_set_window_to_emitted());
    list.add(present_window_to_emitted);
    if (present_window_to_emitted)
      list.add(window_to_emitted);

    boolean present_window_to_transferred = true && (is_set_window_to_transferred());
    list.add(present_window_to_transferred);
    if (present_window_to_transferred)
      list.add(window_to_transferred);

    boolean present_window_to_complete_latencies_ms = true && (is_set_window_to_complete_latencies_ms());
    list.add(present_window_to_complete_latencies_ms);
    if (present_window_to_complete_latencies_ms)
      list.add(window_to_complete_latencies_ms);

    boolean present_window_to_acked = true && (is_set_window_to_acked());
    list.add(present_window_to_acked);
    if (present_window_to_acked)
      list.add(window_to_acked);

    boolean present_window_to_failed = true && (is_set_window_to_failed());
    list.add(present_window_to_failed);
    if (present_window_to_failed)
      list.add(window_to_failed);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(is_set_window_to_emitted()).compareTo(other.is_set_window_to_emitted());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_window_to_emitted()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.window_to_emitted, other.window_to_emitted);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_window_to_transferred()).compareTo(other.is_set_window_to_transferred());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_window_to_transferred()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.window_to_transferred, other.window_to_transferred);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_window_to_complete_latencies_ms()).compareTo(other.is_set_window_to_complete_latencies_ms());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_window_to_complete_latencies_ms()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.window_to_complete_latencies_ms, other.window_to_complete_latencies_ms);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_window_to_acked()).compareTo(other.is_set_window_to_acked());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_window_to_acked()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.window_to_acked, other.window_to_acked);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_window_to_failed()).compareTo(other.is_set_window_to_failed());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_window_to_failed()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.window_to_failed, other.window_to_failed);
      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("TopologyStats(");
    boolean first = true;

    if (is_set_window_to_emitted()) {
      sb.append("window_to_emitted:");
      if (this.window_to_emitted == null) {
        sb.append("null");
      } else {
        sb.append(this.window_to_emitted);
      }
      first = false;
    }
    if (is_set_window_to_transferred()) {
      if (!first) sb.append(", ");
      sb.append("window_to_transferred:");
      if (this.window_to_transferred == null) {
        sb.append("null");
      } else {
        sb.append(this.window_to_transferred);
      }
      first = false;
    }
    if (is_set_window_to_complete_latencies_ms()) {
      if (!first) sb.append(", ");
      sb.append("window_to_complete_latencies_ms:");
      if (this.window_to_complete_latencies_ms == null) {
        sb.append("null");
      } else {
        sb.append(this.window_to_complete_latencies_ms);
      }
      first = false;
    }
    if (is_set_window_to_acked()) {
      if (!first) sb.append(", ");
      sb.append("window_to_acked:");
      if (this.window_to_acked == null) {
        sb.append("null");
      } else {
        sb.append(this.window_to_acked);
      }
      first = false;
    }
    if (is_set_window_to_failed()) {
      if (!first) sb.append(", ");
      sb.append("window_to_failed:");
      if (this.window_to_failed == null) {
        sb.append("null");
      } else {
        sb.append(this.window_to_failed);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

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

  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 {
      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 TopologyStatsStandardSchemeFactory implements SchemeFactory {
    public TopologyStatsStandardScheme getScheme() {
      return new TopologyStatsStandardScheme();
    }
  }

  private static class TopologyStatsStandardScheme extends StandardScheme<TopologyStats> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TopologyStats 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: // WINDOW_TO_EMITTED
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map378 = iprot.readMapBegin();
                struct.window_to_emitted = new HashMap<String,Long>(2*_map378.size);
                String _key379;
                long _val380;
                for (int _i381 = 0; _i381 < _map378.size; ++_i381)
                {
                  _key379 = iprot.readString();
                  _val380 = iprot.readI64();
                  struct.window_to_emitted.put(_key379, _val380);
                }
                iprot.readMapEnd();
              }
              struct.set_window_to_emitted_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // WINDOW_TO_TRANSFERRED
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map382 = iprot.readMapBegin();
                struct.window_to_transferred = new HashMap<String,Long>(2*_map382.size);
                String _key383;
                long _val384;
                for (int _i385 = 0; _i385 < _map382.size; ++_i385)
                {
                  _key383 = iprot.readString();
                  _val384 = iprot.readI64();
                  struct.window_to_transferred.put(_key383, _val384);
                }
                iprot.readMapEnd();
              }
              struct.set_window_to_transferred_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // WINDOW_TO_COMPLETE_LATENCIES_MS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map386 = iprot.readMapBegin();
                struct.window_to_complete_latencies_ms = new HashMap<String,Double>(2*_map386.size);
                String _key387;
                double _val388;
                for (int _i389 = 0; _i389 < _map386.size; ++_i389)
                {
                  _key387 = iprot.readString();
                  _val388 = iprot.readDouble();
                  struct.window_to_complete_latencies_ms.put(_key387, _val388);
                }
                iprot.readMapEnd();
              }
              struct.set_window_to_complete_latencies_ms_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // WINDOW_TO_ACKED
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map390 = iprot.readMapBegin();
                struct.window_to_acked = new HashMap<String,Long>(2*_map390.size);
                String _key391;
                long _val392;
                for (int _i393 = 0; _i393 < _map390.size; ++_i393)
                {
                  _key391 = iprot.readString();
                  _val392 = iprot.readI64();
                  struct.window_to_acked.put(_key391, _val392);
                }
                iprot.readMapEnd();
              }
              struct.set_window_to_acked_isSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // WINDOW_TO_FAILED
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map394 = iprot.readMapBegin();
                struct.window_to_failed = new HashMap<String,Long>(2*_map394.size);
                String _key395;
                long _val396;
                for (int _i397 = 0; _i397 < _map394.size; ++_i397)
                {
                  _key395 = iprot.readString();
                  _val396 = iprot.readI64();
                  struct.window_to_failed.put(_key395, _val396);
                }
                iprot.readMapEnd();
              }
              struct.set_window_to_failed_isSet(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();
      struct.validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.window_to_emitted != null) {
        if (struct.is_set_window_to_emitted()) {
          oprot.writeFieldBegin(WINDOW_TO_EMITTED_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, struct.window_to_emitted.size()));
            for (Map.Entry<String, Long> _iter398 : struct.window_to_emitted.entrySet())
            {
              oprot.writeString(_iter398.getKey());
              oprot.writeI64(_iter398.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.window_to_transferred != null) {
        if (struct.is_set_window_to_transferred()) {
          oprot.writeFieldBegin(WINDOW_TO_TRANSFERRED_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, struct.window_to_transferred.size()));
            for (Map.Entry<String, Long> _iter399 : struct.window_to_transferred.entrySet())
            {
              oprot.writeString(_iter399.getKey());
              oprot.writeI64(_iter399.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.window_to_complete_latencies_ms != null) {
        if (struct.is_set_window_to_complete_latencies_ms()) {
          oprot.writeFieldBegin(WINDOW_TO_COMPLETE_LATENCIES_MS_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.DOUBLE, struct.window_to_complete_latencies_ms.size()));
            for (Map.Entry<String, Double> _iter400 : struct.window_to_complete_latencies_ms.entrySet())
            {
              oprot.writeString(_iter400.getKey());
              oprot.writeDouble(_iter400.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.window_to_acked != null) {
        if (struct.is_set_window_to_acked()) {
          oprot.writeFieldBegin(WINDOW_TO_ACKED_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, struct.window_to_acked.size()));
            for (Map.Entry<String, Long> _iter401 : struct.window_to_acked.entrySet())
            {
              oprot.writeString(_iter401.getKey());
              oprot.writeI64(_iter401.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.window_to_failed != null) {
        if (struct.is_set_window_to_failed()) {
          oprot.writeFieldBegin(WINDOW_TO_FAILED_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, struct.window_to_failed.size()));
            for (Map.Entry<String, Long> _iter402 : struct.window_to_failed.entrySet())
            {
              oprot.writeString(_iter402.getKey());
              oprot.writeI64(_iter402.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TopologyStatsTupleSchemeFactory implements SchemeFactory {
    public TopologyStatsTupleScheme getScheme() {
      return new TopologyStatsTupleScheme();
    }
  }

  private static class TopologyStatsTupleScheme extends TupleScheme<TopologyStats> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TopologyStats struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.is_set_window_to_emitted()) {
        optionals.set(0);
      }
      if (struct.is_set_window_to_transferred()) {
        optionals.set(1);
      }
      if (struct.is_set_window_to_complete_latencies_ms()) {
        optionals.set(2);
      }
      if (struct.is_set_window_to_acked()) {
        optionals.set(3);
      }
      if (struct.is_set_window_to_failed()) {
        optionals.set(4);
      }
      oprot.writeBitSet(optionals, 5);
      if (struct.is_set_window_to_emitted()) {
        {
          oprot.writeI32(struct.window_to_emitted.size());
          for (Map.Entry<String, Long> _iter403 : struct.window_to_emitted.entrySet())
          {
            oprot.writeString(_iter403.getKey());
            oprot.writeI64(_iter403.getValue());
          }
        }
      }
      if (struct.is_set_window_to_transferred()) {
        {
          oprot.writeI32(struct.window_to_transferred.size());
          for (Map.Entry<String, Long> _iter404 : struct.window_to_transferred.entrySet())
          {
            oprot.writeString(_iter404.getKey());
            oprot.writeI64(_iter404.getValue());
          }
        }
      }
      if (struct.is_set_window_to_complete_latencies_ms()) {
        {
          oprot.writeI32(struct.window_to_complete_latencies_ms.size());
          for (Map.Entry<String, Double> _iter405 : struct.window_to_complete_latencies_ms.entrySet())
          {
            oprot.writeString(_iter405.getKey());
            oprot.writeDouble(_iter405.getValue());
          }
        }
      }
      if (struct.is_set_window_to_acked()) {
        {
          oprot.writeI32(struct.window_to_acked.size());
          for (Map.Entry<String, Long> _iter406 : struct.window_to_acked.entrySet())
          {
            oprot.writeString(_iter406.getKey());
            oprot.writeI64(_iter406.getValue());
          }
        }
      }
      if (struct.is_set_window_to_failed()) {
        {
          oprot.writeI32(struct.window_to_failed.size());
          for (Map.Entry<String, Long> _iter407 : struct.window_to_failed.entrySet())
          {
            oprot.writeString(_iter407.getKey());
            oprot.writeI64(_iter407.getValue());
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TopologyStats struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(5);
      if (incoming.get(0)) {
        {
          org.apache.thrift.protocol.TMap _map408 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, iprot.readI32());
          struct.window_to_emitted = new HashMap<String,Long>(2*_map408.size);
          String _key409;
          long _val410;
          for (int _i411 = 0; _i411 < _map408.size; ++_i411)
          {
            _key409 = iprot.readString();
            _val410 = iprot.readI64();
            struct.window_to_emitted.put(_key409, _val410);
          }
        }
        struct.set_window_to_emitted_isSet(true);
      }
      if (incoming.get(1)) {
        {
          org.apache.thrift.protocol.TMap _map412 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, iprot.readI32());
          struct.window_to_transferred = new HashMap<String,Long>(2*_map412.size);
          String _key413;
          long _val414;
          for (int _i415 = 0; _i415 < _map412.size; ++_i415)
          {
            _key413 = iprot.readString();
            _val414 = iprot.readI64();
            struct.window_to_transferred.put(_key413, _val414);
          }
        }
        struct.set_window_to_transferred_isSet(true);
      }
      if (incoming.get(2)) {
        {
          org.apache.thrift.protocol.TMap _map416 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.DOUBLE, iprot.readI32());
          struct.window_to_complete_latencies_ms = new HashMap<String,Double>(2*_map416.size);
          String _key417;
          double _val418;
          for (int _i419 = 0; _i419 < _map416.size; ++_i419)
          {
            _key417 = iprot.readString();
            _val418 = iprot.readDouble();
            struct.window_to_complete_latencies_ms.put(_key417, _val418);
          }
        }
        struct.set_window_to_complete_latencies_ms_isSet(true);
      }
      if (incoming.get(3)) {
        {
          org.apache.thrift.protocol.TMap _map420 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, iprot.readI32());
          struct.window_to_acked = new HashMap<String,Long>(2*_map420.size);
          String _key421;
          long _val422;
          for (int _i423 = 0; _i423 < _map420.size; ++_i423)
          {
            _key421 = iprot.readString();
            _val422 = iprot.readI64();
            struct.window_to_acked.put(_key421, _val422);
          }
        }
        struct.set_window_to_acked_isSet(true);
      }
      if (incoming.get(4)) {
        {
          org.apache.thrift.protocol.TMap _map424 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.I64, iprot.readI32());
          struct.window_to_failed = new HashMap<String,Long>(2*_map424.size);
          String _key425;
          long _val426;
          for (int _i427 = 0; _i427 < _map424.size; ++_i427)
          {
            _key425 = iprot.readString();
            _val426 = iprot.readI64();
            struct.window_to_failed.put(_key425, _val426);
          }
        }
        struct.set_window_to_failed_isSet(true);
      }
    }
  }

}

