Don't segfault on full table scan
This commit is contained in:
parent
7edb5e472f
commit
4c54ab89ae
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ParquetCursor {
|
|||
int numRowGroups;
|
||||
int rowsLeftInRowGroup;
|
||||
|
||||
void nextRowGroup();
|
||||
bool nextRowGroup();
|
||||
|
||||
public:
|
||||
ParquetCursor(ParquetTable* table);
|
||||
|
|
Loading…
Reference in New Issue