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; }
/** * @depends testRadosWrite */ public function testRadosRead($info) { $buf = rados_read($info['ioctx'], $info['oid'], strlen($info['buf'])); $this->assertEquals($buf, $info['buf']); return $info; }
/** * @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; }