public function runQuery(QueryInterface $query, array $options = [])
{
$options += ['className' => null, 'namespaceId' => $this->namespaceId];
$moreResults = true;
do {
$request = $options + $this->readOptions($options) + ['projectId' => $this->projectId, 'partitionId' => $this->partitionId($this->projectId, $options['namespaceId']), $query->queryKey() => $query->queryObject()];
$res = $this->connection->runQuery($request);
if (isset($res['batch']['entityResults']) && is_array($res['batch']['entityResults'])) {
$results = $this->mapEntityResult($res['batch']['entityResults'], $options['className']);
foreach ($results as $result) {
(yield $result);
}
if ($query->canPaginate() && $res['batch']['moreResults'] === 'NOT_FINISHED') {
$query->start($res['batch']['endCursor']);
} else {
$moreResults = false;
}
} else {
$moreResults = false;
}
} while ($moreResults);
}