protected function _read_prefetch_record()
{
$resultSet = [];
$status = $this->_readByte();
while ($status != 0) {
$payload = $this->_readRecord();
$record = Record::fromConfig($payload);
/**
* @var Closure|string $_callback
*/
if (!is_callable($this->_callback, true)) {
throw new PhpOrientBadMethodCallException("'{$this->_callback}' is not a callable function");
}
/**
* async-result-type byte as trailing byte of a record can be:
* 0: no records remain to be fetched
* 1: a record is returned as a result set
* 2: a record is returned as pre-fetched to be loaded in client's
* cache only. It's not part of the result set but the client
* knows that it's available for later access
*/
if ($status == 1) {
# a record is returned as a result set
$resultSet[] = $record;
} elseif ($status == 2) {
# save in cache
call_user_func($this->_callback, $record);
}
$status = $this->_readByte();
}
return $resultSet;
}