Skip to content

Commit

Permalink
[Core] Data Stream iterator fix (#7294)
Browse files Browse the repository at this point in the history
Fix two problems found on the datastream iterator.

- the first row of the stream was always skipped
- an empty row was added at the end
  • Loading branch information
laemtl committed Feb 15, 2021
1 parent e2ae079 commit 2ec4dfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion jslib/fetchDataStream.js
Expand Up @@ -35,7 +35,6 @@ async function processLines(data, rowcb, endstreamcb) {
row = [];
continue;
case 0x04: // end of stream
rowcb(row);
endstreamcb(row);
return {remainder: [], eos: true};
}
Expand Down
6 changes: 4 additions & 2 deletions src/Http/DataIteratorBinaryStream.php
Expand Up @@ -183,15 +183,17 @@ public function read($length)
if ($this->eof) {
return "";
}
$this->rowgen->next();
$row = $this->rowgen->current();
if (!$this->rowgen->valid()) {
$this->eof = true;
return chr(0x04);
}
$row = $this->rowgen->current();
$this->rowgen->next();

$rowArray = array_values(json_decode(json_encode($row), true));
$rowVal = join(chr(0x1e), $rowArray) . chr(0x1f);
$this->position += strlen($rowVal);

return $rowVal;
}

Expand Down

0 comments on commit 2ec4dfa

Please sign in to comment.