#
# Autogenerated by Thrift Compiler (0.16.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py:new_style,no_utf8strings
#

from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
from thrift.protocol.TProtocol import TProtocolException
from thrift.TRecursive import fix_spec

import impala._thrift_gen.ExecStats.ttypes
import impala._thrift_gen.Metrics.ttypes
import impala._thrift_gen.Types.ttypes

from thrift.transport import TTransport
all_structs = []


class TRuntimeProfileFormat(object):
    STRING = 0
    BASE64 = 1
    THRIFT = 2

    _VALUES_TO_NAMES = {
        0: "STRING",
        1: "BASE64",
        2: "THRIFT",
    }

    _NAMES_TO_VALUES = {
        "STRING": 0,
        "BASE64": 1,
        "THRIFT": 2,
    }


class TCounter(object):
    """
    Attributes:
     - name
     - unit
     - value

    """


    def __init__(self, name=None, unit=None, value=None,):
        self.name = name
        self.unit = unit
        self.value = value

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.name = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.unit = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I64:
                    self.value = iprot.readI64()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TCounter')
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 1)
            oprot.writeString(self.name)
            oprot.writeFieldEnd()
        if self.unit is not None:
            oprot.writeFieldBegin('unit', TType.I32, 2)
            oprot.writeI32(self.unit)
            oprot.writeFieldEnd()
        if self.value is not None:
            oprot.writeFieldBegin('value', TType.I64, 3)
            oprot.writeI64(self.value)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.name is None:
            raise TProtocolException(message='Required field name is unset!')
        if self.unit is None:
            raise TProtocolException(message='Required field unit is unset!')
        if self.value is None:
            raise TProtocolException(message='Required field value is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TEventSequence(object):
    """
    Attributes:
     - name
     - timestamps
     - labels

    """


    def __init__(self, name=None, timestamps=None, labels=None,):
        self.name = name
        self.timestamps = timestamps
        self.labels = labels

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.name = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.LIST:
                    self.timestamps = []
                    (_etype3, _size0) = iprot.readListBegin()
                    for _i4 in range(_size0):
                        _elem5 = iprot.readI64()
                        self.timestamps.append(_elem5)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.LIST:
                    self.labels = []
                    (_etype9, _size6) = iprot.readListBegin()
                    for _i10 in range(_size6):
                        _elem11 = iprot.readString()
                        self.labels.append(_elem11)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TEventSequence')
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 1)
            oprot.writeString(self.name)
            oprot.writeFieldEnd()
        if self.timestamps is not None:
            oprot.writeFieldBegin('timestamps', TType.LIST, 2)
            oprot.writeListBegin(TType.I64, len(self.timestamps))
            for iter12 in self.timestamps:
                oprot.writeI64(iter12)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.labels is not None:
            oprot.writeFieldBegin('labels', TType.LIST, 3)
            oprot.writeListBegin(TType.STRING, len(self.labels))
            for iter13 in self.labels:
                oprot.writeString(iter13)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.name is None:
            raise TProtocolException(message='Required field name is unset!')
        if self.timestamps is None:
            raise TProtocolException(message='Required field timestamps is unset!')
        if self.labels is None:
            raise TProtocolException(message='Required field labels is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TTimeSeriesCounter(object):
    """
    Attributes:
     - name
     - unit
     - period_ms
     - values
     - start_index

    """


    def __init__(self, name=None, unit=None, period_ms=None, values=None, start_index=None,):
        self.name = name
        self.unit = unit
        self.period_ms = period_ms
        self.values = values
        self.start_index = start_index

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.name = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.unit = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I32:
                    self.period_ms = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.LIST:
                    self.values = []
                    (_etype17, _size14) = iprot.readListBegin()
                    for _i18 in range(_size14):
                        _elem19 = iprot.readI64()
                        self.values.append(_elem19)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.I64:
                    self.start_index = iprot.readI64()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TTimeSeriesCounter')
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 1)
            oprot.writeString(self.name)
            oprot.writeFieldEnd()
        if self.unit is not None:
            oprot.writeFieldBegin('unit', TType.I32, 2)
            oprot.writeI32(self.unit)
            oprot.writeFieldEnd()
        if self.period_ms is not None:
            oprot.writeFieldBegin('period_ms', TType.I32, 3)
            oprot.writeI32(self.period_ms)
            oprot.writeFieldEnd()
        if self.values is not None:
            oprot.writeFieldBegin('values', TType.LIST, 4)
            oprot.writeListBegin(TType.I64, len(self.values))
            for iter20 in self.values:
                oprot.writeI64(iter20)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.start_index is not None:
            oprot.writeFieldBegin('start_index', TType.I64, 5)
            oprot.writeI64(self.start_index)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.name is None:
            raise TProtocolException(message='Required field name is unset!')
        if self.unit is None:
            raise TProtocolException(message='Required field unit is unset!')
        if self.period_ms is None:
            raise TProtocolException(message='Required field period_ms is unset!')
        if self.values is None:
            raise TProtocolException(message='Required field values is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TSummaryStatsCounter(object):
    """
    Attributes:
     - name
     - unit
     - sum
     - total_num_values
     - min_value
     - max_value

    """


    def __init__(self, name=None, unit=None, sum=None, total_num_values=None, min_value=None, max_value=None,):
        self.name = name
        self.unit = unit
        self.sum = sum
        self.total_num_values = total_num_values
        self.min_value = min_value
        self.max_value = max_value

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.name = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.unit = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I64:
                    self.sum = iprot.readI64()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.I64:
                    self.total_num_values = iprot.readI64()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.I64:
                    self.min_value = iprot.readI64()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.I64:
                    self.max_value = iprot.readI64()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TSummaryStatsCounter')
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 1)
            oprot.writeString(self.name)
            oprot.writeFieldEnd()
        if self.unit is not None:
            oprot.writeFieldBegin('unit', TType.I32, 2)
            oprot.writeI32(self.unit)
            oprot.writeFieldEnd()
        if self.sum is not None:
            oprot.writeFieldBegin('sum', TType.I64, 3)
            oprot.writeI64(self.sum)
            oprot.writeFieldEnd()
        if self.total_num_values is not None:
            oprot.writeFieldBegin('total_num_values', TType.I64, 4)
            oprot.writeI64(self.total_num_values)
            oprot.writeFieldEnd()
        if self.min_value is not None:
            oprot.writeFieldBegin('min_value', TType.I64, 5)
            oprot.writeI64(self.min_value)
            oprot.writeFieldEnd()
        if self.max_value is not None:
            oprot.writeFieldBegin('max_value', TType.I64, 6)
            oprot.writeI64(self.max_value)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.name is None:
            raise TProtocolException(message='Required field name is unset!')
        if self.unit is None:
            raise TProtocolException(message='Required field unit is unset!')
        if self.sum is None:
            raise TProtocolException(message='Required field sum is unset!')
        if self.total_num_values is None:
            raise TProtocolException(message='Required field total_num_values is unset!')
        if self.min_value is None:
            raise TProtocolException(message='Required field min_value is unset!')
        if self.max_value is None:
            raise TProtocolException(message='Required field max_value is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TRuntimeProfileNodeMetadata(object):
    """
    Attributes:
     - plan_node_id
     - data_sink_id

    """


    def __init__(self, plan_node_id=None, data_sink_id=None,):
        self.plan_node_id = plan_node_id
        self.data_sink_id = data_sink_id

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.I32:
                    self.plan_node_id = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.data_sink_id = iprot.readI32()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TRuntimeProfileNodeMetadata')
        if self.plan_node_id is not None:
            oprot.writeFieldBegin('plan_node_id', TType.I32, 1)
            oprot.writeI32(self.plan_node_id)
            oprot.writeFieldEnd()
        if self.data_sink_id is not None:
            oprot.writeFieldBegin('data_sink_id', TType.I32, 2)
            oprot.writeI32(self.data_sink_id)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TRuntimeProfileNode(object):
    """
    Attributes:
     - name
     - num_children
     - counters
     - metadata
     - indent
     - info_strings
     - info_strings_display_order
     - child_counters_map
     - event_sequences
     - time_series_counters
     - summary_stats_counters
     - node_metadata

    """


    def __init__(self, name=None, num_children=None, counters=None, metadata=None, indent=None, info_strings=None, info_strings_display_order=None, child_counters_map=None, event_sequences=None, time_series_counters=None, summary_stats_counters=None, node_metadata=None,):
        self.name = name
        self.num_children = num_children
        self.counters = counters
        self.metadata = metadata
        self.indent = indent
        self.info_strings = info_strings
        self.info_strings_display_order = info_strings_display_order
        self.child_counters_map = child_counters_map
        self.event_sequences = event_sequences
        self.time_series_counters = time_series_counters
        self.summary_stats_counters = summary_stats_counters
        self.node_metadata = node_metadata

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.name = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.num_children = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.LIST:
                    self.counters = []
                    (_etype24, _size21) = iprot.readListBegin()
                    for _i25 in range(_size21):
                        _elem26 = TCounter()
                        _elem26.read(iprot)
                        self.counters.append(_elem26)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.I64:
                    self.metadata = iprot.readI64()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.BOOL:
                    self.indent = iprot.readBool()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.MAP:
                    self.info_strings = {}
                    (_ktype28, _vtype29, _size27) = iprot.readMapBegin()
                    for _i31 in range(_size27):
                        _key32 = iprot.readString()
                        _val33 = iprot.readString()
                        self.info_strings[_key32] = _val33
                    iprot.readMapEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 7:
                if ftype == TType.LIST:
                    self.info_strings_display_order = []
                    (_etype37, _size34) = iprot.readListBegin()
                    for _i38 in range(_size34):
                        _elem39 = iprot.readString()
                        self.info_strings_display_order.append(_elem39)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 8:
                if ftype == TType.MAP:
                    self.child_counters_map = {}
                    (_ktype41, _vtype42, _size40) = iprot.readMapBegin()
                    for _i44 in range(_size40):
                        _key45 = iprot.readString()
                        _val46 = set()
                        (_etype50, _size47) = iprot.readSetBegin()
                        for _i51 in range(_size47):
                            _elem52 = iprot.readString()
                            _val46.add(_elem52)
                        iprot.readSetEnd()
                        self.child_counters_map[_key45] = _val46
                    iprot.readMapEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 9:
                if ftype == TType.LIST:
                    self.event_sequences = []
                    (_etype56, _size53) = iprot.readListBegin()
                    for _i57 in range(_size53):
                        _elem58 = TEventSequence()
                        _elem58.read(iprot)
                        self.event_sequences.append(_elem58)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 10:
                if ftype == TType.LIST:
                    self.time_series_counters = []
                    (_etype62, _size59) = iprot.readListBegin()
                    for _i63 in range(_size59):
                        _elem64 = TTimeSeriesCounter()
                        _elem64.read(iprot)
                        self.time_series_counters.append(_elem64)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 11:
                if ftype == TType.LIST:
                    self.summary_stats_counters = []
                    (_etype68, _size65) = iprot.readListBegin()
                    for _i69 in range(_size65):
                        _elem70 = TSummaryStatsCounter()
                        _elem70.read(iprot)
                        self.summary_stats_counters.append(_elem70)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 12:
                if ftype == TType.STRUCT:
                    self.node_metadata = TRuntimeProfileNodeMetadata()
                    self.node_metadata.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TRuntimeProfileNode')
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 1)
            oprot.writeString(self.name)
            oprot.writeFieldEnd()
        if self.num_children is not None:
            oprot.writeFieldBegin('num_children', TType.I32, 2)
            oprot.writeI32(self.num_children)
            oprot.writeFieldEnd()
        if self.counters is not None:
            oprot.writeFieldBegin('counters', TType.LIST, 3)
            oprot.writeListBegin(TType.STRUCT, len(self.counters))
            for iter71 in self.counters:
                iter71.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.metadata is not None:
            oprot.writeFieldBegin('metadata', TType.I64, 4)
            oprot.writeI64(self.metadata)
            oprot.writeFieldEnd()
        if self.indent is not None:
            oprot.writeFieldBegin('indent', TType.BOOL, 5)
            oprot.writeBool(self.indent)
            oprot.writeFieldEnd()
        if self.info_strings is not None:
            oprot.writeFieldBegin('info_strings', TType.MAP, 6)
            oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.info_strings))
            for kiter72, viter73 in self.info_strings.items():
                oprot.writeString(kiter72)
                oprot.writeString(viter73)
            oprot.writeMapEnd()
            oprot.writeFieldEnd()
        if self.info_strings_display_order is not None:
            oprot.writeFieldBegin('info_strings_display_order', TType.LIST, 7)
            oprot.writeListBegin(TType.STRING, len(self.info_strings_display_order))
            for iter74 in self.info_strings_display_order:
                oprot.writeString(iter74)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.child_counters_map is not None:
            oprot.writeFieldBegin('child_counters_map', TType.MAP, 8)
            oprot.writeMapBegin(TType.STRING, TType.SET, len(self.child_counters_map))
            for kiter75, viter76 in self.child_counters_map.items():
                oprot.writeString(kiter75)
                oprot.writeSetBegin(TType.STRING, len(viter76))
                for iter77 in viter76:
                    oprot.writeString(iter77)
                oprot.writeSetEnd()
            oprot.writeMapEnd()
            oprot.writeFieldEnd()
        if self.event_sequences is not None:
            oprot.writeFieldBegin('event_sequences', TType.LIST, 9)
            oprot.writeListBegin(TType.STRUCT, len(self.event_sequences))
            for iter78 in self.event_sequences:
                iter78.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.time_series_counters is not None:
            oprot.writeFieldBegin('time_series_counters', TType.LIST, 10)
            oprot.writeListBegin(TType.STRUCT, len(self.time_series_counters))
            for iter79 in self.time_series_counters:
                iter79.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.summary_stats_counters is not None:
            oprot.writeFieldBegin('summary_stats_counters', TType.LIST, 11)
            oprot.writeListBegin(TType.STRUCT, len(self.summary_stats_counters))
            for iter80 in self.summary_stats_counters:
                iter80.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.node_metadata is not None:
            oprot.writeFieldBegin('node_metadata', TType.STRUCT, 12)
            self.node_metadata.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.name is None:
            raise TProtocolException(message='Required field name is unset!')
        if self.num_children is None:
            raise TProtocolException(message='Required field num_children is unset!')
        if self.counters is None:
            raise TProtocolException(message='Required field counters is unset!')
        if self.metadata is None:
            raise TProtocolException(message='Required field metadata is unset!')
        if self.indent is None:
            raise TProtocolException(message='Required field indent is unset!')
        if self.info_strings is None:
            raise TProtocolException(message='Required field info_strings is unset!')
        if self.info_strings_display_order is None:
            raise TProtocolException(message='Required field info_strings_display_order is unset!')
        if self.child_counters_map is None:
            raise TProtocolException(message='Required field child_counters_map is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TRuntimeProfileTree(object):
    """
    Attributes:
     - nodes
     - exec_summary

    """


    def __init__(self, nodes=None, exec_summary=None,):
        self.nodes = nodes
        self.exec_summary = exec_summary

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.LIST:
                    self.nodes = []
                    (_etype84, _size81) = iprot.readListBegin()
                    for _i85 in range(_size81):
                        _elem86 = TRuntimeProfileNode()
                        _elem86.read(iprot)
                        self.nodes.append(_elem86)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.exec_summary = impala._thrift_gen.ExecStats.ttypes.TExecSummary()
                    self.exec_summary.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TRuntimeProfileTree')
        if self.nodes is not None:
            oprot.writeFieldBegin('nodes', TType.LIST, 1)
            oprot.writeListBegin(TType.STRUCT, len(self.nodes))
            for iter87 in self.nodes:
                iter87.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.exec_summary is not None:
            oprot.writeFieldBegin('exec_summary', TType.STRUCT, 2)
            self.exec_summary.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.nodes is None:
            raise TProtocolException(message='Required field nodes is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class TRuntimeProfileForest(object):
    """
    Attributes:
     - profile_trees
     - host_profile

    """


    def __init__(self, profile_trees=None, host_profile=None,):
        self.profile_trees = profile_trees
        self.host_profile = host_profile

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.LIST:
                    self.profile_trees = []
                    (_etype91, _size88) = iprot.readListBegin()
                    for _i92 in range(_size88):
                        _elem93 = TRuntimeProfileTree()
                        _elem93.read(iprot)
                        self.profile_trees.append(_elem93)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.host_profile = TRuntimeProfileTree()
                    self.host_profile.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TRuntimeProfileForest')
        if self.profile_trees is not None:
            oprot.writeFieldBegin('profile_trees', TType.LIST, 1)
            oprot.writeListBegin(TType.STRUCT, len(self.profile_trees))
            for iter94 in self.profile_trees:
                iter94.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.host_profile is not None:
            oprot.writeFieldBegin('host_profile', TType.STRUCT, 2)
            self.host_profile.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.profile_trees is None:
            raise TProtocolException(message='Required field profile_trees is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)
all_structs.append(TCounter)
TCounter.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', None, None, ),  # 1
    (2, TType.I32, 'unit', None, None, ),  # 2
    (3, TType.I64, 'value', None, None, ),  # 3
)
all_structs.append(TEventSequence)
TEventSequence.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', None, None, ),  # 1
    (2, TType.LIST, 'timestamps', (TType.I64, None, False), None, ),  # 2
    (3, TType.LIST, 'labels', (TType.STRING, None, False), None, ),  # 3
)
all_structs.append(TTimeSeriesCounter)
TTimeSeriesCounter.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', None, None, ),  # 1
    (2, TType.I32, 'unit', None, None, ),  # 2
    (3, TType.I32, 'period_ms', None, None, ),  # 3
    (4, TType.LIST, 'values', (TType.I64, None, False), None, ),  # 4
    (5, TType.I64, 'start_index', None, None, ),  # 5
)
all_structs.append(TSummaryStatsCounter)
TSummaryStatsCounter.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', None, None, ),  # 1
    (2, TType.I32, 'unit', None, None, ),  # 2
    (3, TType.I64, 'sum', None, None, ),  # 3
    (4, TType.I64, 'total_num_values', None, None, ),  # 4
    (5, TType.I64, 'min_value', None, None, ),  # 5
    (6, TType.I64, 'max_value', None, None, ),  # 6
)
all_structs.append(TRuntimeProfileNodeMetadata)
TRuntimeProfileNodeMetadata.thrift_spec = (
    None,  # 0
    (1, TType.I32, 'plan_node_id', None, None, ),  # 1
    (2, TType.I32, 'data_sink_id', None, None, ),  # 2
)
all_structs.append(TRuntimeProfileNode)
TRuntimeProfileNode.thrift_spec = (
    None,  # 0
    (1, TType.STRING, 'name', None, None, ),  # 1
    (2, TType.I32, 'num_children', None, None, ),  # 2
    (3, TType.LIST, 'counters', (TType.STRUCT, [TCounter, None], False), None, ),  # 3
    (4, TType.I64, 'metadata', None, None, ),  # 4
    (5, TType.BOOL, 'indent', None, None, ),  # 5
    (6, TType.MAP, 'info_strings', (TType.STRING, None, TType.STRING, None, False), None, ),  # 6
    (7, TType.LIST, 'info_strings_display_order', (TType.STRING, None, False), None, ),  # 7
    (8, TType.MAP, 'child_counters_map', (TType.STRING, None, TType.SET, (TType.STRING, None, False), False), None, ),  # 8
    (9, TType.LIST, 'event_sequences', (TType.STRUCT, [TEventSequence, None], False), None, ),  # 9
    (10, TType.LIST, 'time_series_counters', (TType.STRUCT, [TTimeSeriesCounter, None], False), None, ),  # 10
    (11, TType.LIST, 'summary_stats_counters', (TType.STRUCT, [TSummaryStatsCounter, None], False), None, ),  # 11
    (12, TType.STRUCT, 'node_metadata', [TRuntimeProfileNodeMetadata, None], None, ),  # 12
)
all_structs.append(TRuntimeProfileTree)
TRuntimeProfileTree.thrift_spec = (
    None,  # 0
    (1, TType.LIST, 'nodes', (TType.STRUCT, [TRuntimeProfileNode, None], False), None, ),  # 1
    (2, TType.STRUCT, 'exec_summary', [impala._thrift_gen.ExecStats.ttypes.TExecSummary, None], None, ),  # 2
)
all_structs.append(TRuntimeProfileForest)
TRuntimeProfileForest.thrift_spec = (
    None,  # 0
    (1, TType.LIST, 'profile_trees', (TType.STRUCT, [TRuntimeProfileTree, None], False), None, ),  # 1
    (2, TType.STRUCT, 'host_profile', [TRuntimeProfileTree, None], None, ),  # 2
)
fix_spec(all_structs)
del all_structs
