<?php
namespace metastore;

/**
 * Autogenerated by Thrift Compiler (0.16.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;

class PartitionsStatsResult
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'partStats',
            'isRequired' => true,
            'type' => TType::MAP,
            'ktype' => TType::STRING,
            'vtype' => TType::LST,
            'key' => array(
                'type' => TType::STRING,
            ),
            'val' => array(
                'type' => TType::LST,
                'etype' => TType::STRUCT,
                'elem' => array(
                    'type' => TType::STRUCT,
                    'class' => '\metastore\ColumnStatisticsObj',
                    ),
                ),
        ),
    );

    /**
     * @var array
     */
    public $partStats = null;

    public function __construct($vals = null)
    {
        if (is_array($vals)) {
            if (isset($vals['partStats'])) {
                $this->partStats = $vals['partStats'];
            }
        }
    }

    public function getName()
    {
        return 'PartitionsStatsResult';
    }


    public function read($input)
    {
        $xfer = 0;
        $fname = null;
        $ftype = 0;
        $fid = 0;
        $xfer += $input->readStructBegin($fname);
        while (true) {
            $xfer += $input->readFieldBegin($fname, $ftype, $fid);
            if ($ftype == TType::STOP) {
                break;
            }
            switch ($fid) {
                case 1:
                    if ($ftype == TType::MAP) {
                        $this->partStats = array();
                        $_size381 = 0;
                        $_ktype382 = 0;
                        $_vtype383 = 0;
                        $xfer += $input->readMapBegin($_ktype382, $_vtype383, $_size381);
                        for ($_i385 = 0; $_i385 < $_size381; ++$_i385) {
                            $key386 = '';
                            $val387 = array();
                            $xfer += $input->readString($key386);
                            $val387 = array();
                            $_size388 = 0;
                            $_etype391 = 0;
                            $xfer += $input->readListBegin($_etype391, $_size388);
                            for ($_i392 = 0; $_i392 < $_size388; ++$_i392) {
                                $elem393 = null;
                                $elem393 = new \metastore\ColumnStatisticsObj();
                                $xfer += $elem393->read($input);
                                $val387 []= $elem393;
                            }
                            $xfer += $input->readListEnd();
                            $this->partStats[$key386] = $val387;
                        }
                        $xfer += $input->readMapEnd();
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                default:
                    $xfer += $input->skip($ftype);
                    break;
            }
            $xfer += $input->readFieldEnd();
        }
        $xfer += $input->readStructEnd();
        return $xfer;
    }

    public function write($output)
    {
        $xfer = 0;
        $xfer += $output->writeStructBegin('PartitionsStatsResult');
        if ($this->partStats !== null) {
            if (!is_array($this->partStats)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('partStats', TType::MAP, 1);
            $output->writeMapBegin(TType::STRING, TType::LST, count($this->partStats));
            foreach ($this->partStats as $kiter394 => $viter395) {
                $xfer += $output->writeString($kiter394);
                $output->writeListBegin(TType::STRUCT, count($viter395));
                foreach ($viter395 as $iter396) {
                    $xfer += $iter396->write($output);
                }
                $output->writeListEnd();
            }
            $output->writeMapEnd();
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
