예제 #1
0
파일: IO.php 프로젝트: shen2/rados
 public function read($objectId)
 {
     $stat = \rados_stat($this->_ioctx, $objectId);
     $seg = 8000000;
     if ($stat['psize'] <= $seg) {
         return \rados_read($this->_ioctx, $objectId, $stat['psize']);
     }
     $offset = 0;
     $result = '';
     do {
         $result .= \rados_read($this->_ioctx, $objectId, $stat['psize'] - $offset > $seg ? $seg : $stat['psize'] - $offset, $offset);
         $offset += $seg;
     } while ($offset < $stat['psize']);
     return $result;
 }
예제 #2
0
 /**
  * @depends testRadosWrite
  */
 public function testRadosRead($info)
 {
     $buf = rados_read($info['ioctx'], $info['oid'], strlen($info['buf']));
     $this->assertEquals($buf, $info['buf']);
     return $info;
 }
예제 #3
0
 /**
  * @param int $count
  * @return string
  */
 public function stream_read($count)
 {
     if ($count > $this->stat['psize'] - $this->pos) {
         $count = $this->stat['psize'] - $this->pos;
     }
     if ($this->stream_eof()) {
         return '';
     }
     $buf = \rados_read($this->ioctx, $this->stat['oid'], $count, $this->pos);
     //TODO check return type?
     $this->pos += $count;
     return $buf;
 }