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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Optional;
import java.util.PrimitiveIterator;
import java.util.Set;
import java.util.stream.LongStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.parquet.ParquetReadOptions;
import org.apache.parquet.column.page.PageReadStore;
Expand Down Expand Up @@ -320,21 +319,42 @@ private void resetRowIndexIterator(PageReadStore pages) {
if (pages.getRowIndexes().isPresent()) {
rowIdxInRowGroupItr = pages.getRowIndexes().get();
} else {
rowIdxInRowGroupItr = LongStream.range(0, pages.getRowCount()).iterator();
rowIdxInRowGroupItr = new LongIterator(pages.getRowCount());
}
// Adjust the row group offset in the `rowIndexWithinRowGroupIterator` iterator.
final long rowGroupRowIdxOffsetValue = rowGroupRowIdxOffset.get();
this.rowIdxInFileItr = new PrimitiveIterator.OfLong() {
public long nextLong() {
return rowGroupRowIdxOffset.get() + rowIdxInRowGroupItr.nextLong();
return rowGroupRowIdxOffsetValue + rowIdxInRowGroupItr.nextLong();
}

public boolean hasNext() {
return rowIdxInRowGroupItr.hasNext();
}

public Long next() {
return rowGroupRowIdxOffset.get() + rowIdxInRowGroupItr.next();
return rowGroupRowIdxOffsetValue + rowIdxInRowGroupItr.next();
}
};
}

private static class LongIterator implements PrimitiveIterator.OfLong {

private final long maxValue;
private long currentValue = 0;

public LongIterator(long maxValue) {
this.maxValue = maxValue;
}

@Override
public long nextLong() {
return currentValue++;
}

@Override
public boolean hasNext() {
return currentValue < maxValue;
}
}
}