PhpOrient\Protocols\Binary\Transaction\TxCommit::_read PHP Method

_read() protected method

Read the response from the socket.
protected _read ( ) : mixed
return mixed the response.
    protected function _read()
    {
        $result = ['created' => [], 'updated' => [], 'changes' => []];
        $items = $this->_readInt();
        for ($x = 0; $x < $items; $x++) {
            # (created-record-count:int)
            # [
            #     (client-specified-cluster-id:short)
            #     (client-specified-cluster-position:long)
            #     (created-cluster-id:short)
            #     (created-cluster-position:long)
            # ]*
            $lastCreated = ['client_c_id' => $this->_readShort(), 'client_c_pos' => $this->_readLong(), 'created_c_id' => $this->_readShort(), 'created_c_pos' => $this->_readLong()];
            $result['created'][] = $lastCreated;
            /**
             * @var RecordCreate $operation
             */
            $operation = $this->_pre_operation_records[(new ID($lastCreated['client_c_id'], $lastCreated['client_c_pos']))->__toString()];
            $rid = new ID($lastCreated['created_c_id'], $lastCreated['created_c_pos']);
            $operation->record->setVersion(1)->setRid($rid);
            $this->_operation_records[$rid->__toString()] = $operation->record;
        }
        $items = $this->_readInt();
        for ($x = 0; $x < $items; $x++) {
            # (updated-record-count:int)
            # [
            # (updated-cluster-id:short)
            #     (updated-cluster-position:long)
            #     (new-record-version:int)
            # ]*
            $lastUpdated = ['updated_c_id' => $this->_readShort(), 'updated_c_pos' => $this->_readLong(), 'new_version' => $this->_readInt()];
            # Continue, server send in the updated records
            # even the new the new created ones
            if (!isset($this->_pre_operation_records[(new ID($lastUpdated['updated_c_id'], $lastUpdated['updated_c_pos']))->__toString()])) {
                continue;
            }
            /**
             * @var RecordUpdate $operation
             */
            $operation = $this->_pre_operation_records[(new ID($lastUpdated['updated_c_id'], $lastUpdated['updated_c_pos']))->__toString()];
            $rid = new ID($lastUpdated['updated_c_id'], $lastUpdated['updated_c_pos']);
            $operation->record->setVersion($lastUpdated['new_version'])->setRid($rid);
            $this->_operation_records[$rid->__toString()] = $operation->record;
        }
        if ($this->_transport->getProtocolVersion() > 23) {
            $items = $this->_readInt();
            for ($x = 0; $x < $items; $x++) {
                # (count-of-collection-changes:int)
                # [
                # (uuid-most-sig-bits:long)
                #     (uuid-least-sig-bits:long)
                #     (updated-file-id:long)
                #     (updated-page-index:long)
                #     (updated-page-offset:int)
                # ]*
                $result['updated'][] = ['uuid_high' => $this->_readLong(), 'uuid_low' => $this->_readLong(), 'file_id' => $this->_readLong(), 'page_index' => $this->_readLong(), 'page_offset' => $this->_readLong()];
            }
        }
        return $this->_operation_records;
    }