<?php
namespace codename\parquet\format;

/**
 * Autogenerated by Thrift Compiler (0.15.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 EncryptionWithColumnKey
{
    static public $isValidate = false;

    static public $_TSPEC = array(
        1 => array(
            'var' => 'path_in_schema',
            'isRequired' => true,
            'type' => TType::LST,
            'etype' => TType::STRING,
            'elem' => array(
                'type' => TType::STRING,
                ),
        ),
        2 => array(
            'var' => 'key_metadata',
            'isRequired' => false,
            'type' => TType::STRING,
        ),
    );

    /**
     * Column path in schema *
     * 
     * @var string[]
     */
    public $path_in_schema = null;
    /**
     * Retrieval metadata of column encryption key *
     * 
     * @var string
     */
    public $key_metadata = null;

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

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


    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::LST) {
                        $this->path_in_schema = array();
                        $_size28 = 0;
                        $_etype31 = 0;
                        $xfer += $input->readListBegin($_etype31, $_size28);
                        for ($_i32 = 0; $_i32 < $_size28; ++$_i32) {
                            $elem33 = null;
                            $xfer += $input->readString($elem33);
                            $this->path_in_schema []= $elem33;
                        }
                        $xfer += $input->readListEnd();
                    } else {
                        $xfer += $input->skip($ftype);
                    }
                    break;
                case 2:
                    if ($ftype == TType::STRING) {
                        $xfer += $input->readString($this->key_metadata);
                    } 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('EncryptionWithColumnKey');
        if ($this->path_in_schema !== null) {
            if (!is_array($this->path_in_schema)) {
                throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
            }
            $xfer += $output->writeFieldBegin('path_in_schema', TType::LST, 1);
            $output->writeListBegin(TType::STRING, count($this->path_in_schema));
            foreach ($this->path_in_schema as $iter34) {
                $xfer += $output->writeString($iter34);
            }
            $output->writeListEnd();
            $xfer += $output->writeFieldEnd();
        }
        if ($this->key_metadata !== null) {
            $xfer += $output->writeFieldBegin('key_metadata', TType::STRING, 2);
            $xfer += $output->writeString($this->key_metadata);
            $xfer += $output->writeFieldEnd();
        }
        $xfer += $output->writeFieldStop();
        $xfer += $output->writeStructEnd();
        return $xfer;
    }
}
