Don't segfault on full table scan

This commit is contained in:
Colin Dellow 2018-03-04 17:49:19 -05:00
parent 7edb5e472f
commit 4c54ab89ae
2 changed files with 14 additions and 6 deletions

View File

@ -16,10 +16,10 @@ ParquetCursor::ParquetCursor(ParquetTable* table) {
this->numRowGroups = reader->metadata()->num_row_groups();
}
void ParquetCursor::nextRowGroup() {
bool ParquetCursor::nextRowGroup() {
// TODO: skip row groups that cannot satisfy the constraints
if(this->rowGroupId >= this->numRowGroups)
return;
if((this->rowGroupId + 1) >= this->numRowGroups)
return false;
rowGroupId++;
rowGroupMetadata = this->reader->metadata()->RowGroup(0);
@ -40,11 +40,19 @@ void ParquetCursor::nextRowGroup() {
types[i] = rowGroupMetadata->schema()->Column(i)->physical_type();
logicalTypes[i] = rowGroupMetadata->schema()->Column(i)->logical_type();
}
return true;
}
void ParquetCursor::next() {
if(rowsLeftInRowGroup == 0)
nextRowGroup();
if(rowsLeftInRowGroup == 0) {
if(!nextRowGroup()) {
// put rowId over the edge so eof returns true
rowId++;
return;
}
}
rowsLeftInRowGroup--;
rowId++;
}

View File

@ -26,7 +26,7 @@ class ParquetCursor {
int numRowGroups;
int rowsLeftInRowGroup;
void nextRowGroup();
bool nextRowGroup();
public:
ParquetCursor(ParquetTable* table);