Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ class ParquetCursor {
this.columnList = columnList;
this.rowGroup = [];
this.rowGroupIndex = 0;
this.cursorIndex = 0;
}

/**
* Retrieve the next row from the cursor. Returns a row or NULL if the end
* of the file was reached
*/
async next() {
if (this.rowGroup.length === 0) {
if (this.cursorIndex >= this.rowGroup.length) {
if (this.rowGroupIndex >= this.metadata.row_groups.length) {
return null;
}
Expand All @@ -61,9 +62,10 @@ class ParquetCursor {

this.rowGroup = parquet_shredder.materializeRecords(this.schema, rowBuffer);
this.rowGroupIndex++;
this.cursorIndex = 0;
}

return this.rowGroup.shift();
return this.rowGroup[this.cursorIndex++];
}

/**
Expand Down Expand Up @@ -137,7 +139,7 @@ class ParquetReader {
columnList = columnList.map((x) => x.constructor === Array ? x : [x]);

return new ParquetCursor(
this.metadata,
this.metadata,
this.envelopeReader,
this.schema,
columnList);
Expand Down