CassandraDataIterator error when lots of empty rows
LordStephen opened this issue · 0 comments
LordStephen commented
In the function CassandraDataIterator::next(), the next() function is recursivly called until it find a valid value.
Depending on the data this function can pass the maximum nesting level throwing this error:
Fatal error: Maximum function nesting level of '100' reached, aborting!
I coded this fix :
public function next() {
$value = null;
$beyondLastRow = false;
if (!empty($this->buffer)) {
$this->nextStartKey = key($this->buffer);
$value = next($this->buffer);
if (count(current($this->buffer)) == 0) {
$value = $this->findNextValidValue();
}
$key = key($this->buffer);
if (isset($key)) {
$this->rowsSeen++;
if (
$this->rowCountLimit !== null
&& $this->rowsSeen > $this->rowCountLimit
) {
$this->isValid = false;
return null;
}
} else {
$beyondLastRow = true;
}
} else {
$beyondLastRow = true;
}
if ($beyondLastRow) {
if ($this->currentPageSize < $this->expectedPageSize) {
$this->isValid = false;
} else {
$this->updateBuffer();
if (count($this->buffer) == 1) {
$this->isValid = false;
} else {
$this->next();
}
}
}
return $value;
}
private function findNextValidValue(){
$value = next($this->buffer);
while (count(current($this->buffer)) == 0) {
$value = next($this->buffer);
}
return $value;
}