Hi !

I'm not able to use getters and setters of Types.php generated by Thrift.

My Thrift structure :

typedef i32 intstruct Creation {
   1: int a_iso,
   2: int date}

I did :
$objetcree = new Creation(); $objetcree->a_iso = 45;

Ok but I don't want use like that.
$objetcree->read($input);

How has to be $input if I want to write just the a_iso field ?

Thank you very much !!!


Just to know :  I want to convert my XML files in thrift binary to
store them into HDFS.

I parse my XML files in SimpleXMLObject and I convert this object in
Thrift object.

Afterwards, I serialize and I store in file. (I could process with
Hbase, Impala etc..)
I'm in an internship and my boss want to store many many xml files
which (valid the structure and adapt to changes)

Right ?


My Thrift file generated :

########################################
class Creation {
  static $_TSPEC;

  public $a_iso = null;
  public $date = null;

                  public function __construct($vals=null) {
                        if (!isset(self::$_TSPEC)) {
                          self::$_TSPEC = array(
                                1 => array(
                                  'var' => 'a_iso',
                                  'type' => TType::I32,
                                  ),
                                2 => array(
                                  'var' => 'date',
                                  'type' => TType::I32,
                                  ),
                                );
                        }
                        if (is_array($vals)) {
                          if (isset($vals['a_iso'])) {
                                $this->a_iso = $vals['a_iso'];
                          }
                          if (isset($vals['date'])) {
                                $this->date = $vals['date'];
                          }
                        }
                  }

                  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::I32) {
                                        $xfer += $input->readI32($this->a_iso);
                                  } else {
                                        $xfer += $input->skip($ftype);
                                  }
                                  break;
                                case 2:
                                  if ($ftype == TType::I32) {
                                        $xfer += $input->readI32($this->date);
                                  } 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('Creation');
                        if ($this->a_iso !== null) {
                          $xfer += $output->writeFieldBegin('a_iso',
TType::I32, 1);
                          $xfer += $output->writeI32($this->a_iso);
                          $xfer += $output->writeFieldEnd();
                        }
                        if ($this->date !== null) {
                          $xfer += $output->writeFieldBegin('date',
TType::I32, 2);
                          $xfer += $output->writeI32($this->date);
                          $xfer += $output->writeFieldEnd();
                        }
                        $xfer += $output->writeFieldStop();
                        $xfer += $output->writeStructEnd();
                        return $xfer;
                  }}
########################################

Reply via email to