|
30 | 30 | import java.util.Optional; |
31 | 31 | import java.util.PrimitiveIterator; |
32 | 32 | import java.util.Set; |
33 | | -import java.util.stream.LongStream; |
34 | 33 | import org.apache.hadoop.conf.Configuration; |
35 | 34 | import org.apache.parquet.ParquetReadOptions; |
36 | 35 | import org.apache.parquet.column.page.PageReadStore; |
@@ -320,21 +319,42 @@ private void resetRowIndexIterator(PageReadStore pages) { |
320 | 319 | if (pages.getRowIndexes().isPresent()) { |
321 | 320 | rowIdxInRowGroupItr = pages.getRowIndexes().get(); |
322 | 321 | } else { |
323 | | - rowIdxInRowGroupItr = LongStream.range(0, pages.getRowCount()).iterator(); |
| 322 | + rowIdxInRowGroupItr = new LongIterator(pages.getRowCount()); |
324 | 323 | } |
325 | 324 | // Adjust the row group offset in the `rowIndexWithinRowGroupIterator` iterator. |
| 325 | + final long rowGroupRowIdxOffsetValue = rowGroupRowIdxOffset.get(); |
326 | 326 | this.rowIdxInFileItr = new PrimitiveIterator.OfLong() { |
327 | 327 | public long nextLong() { |
328 | | - return rowGroupRowIdxOffset.get() + rowIdxInRowGroupItr.nextLong(); |
| 328 | + return rowGroupRowIdxOffsetValue + rowIdxInRowGroupItr.nextLong(); |
329 | 329 | } |
330 | 330 |
|
331 | 331 | public boolean hasNext() { |
332 | 332 | return rowIdxInRowGroupItr.hasNext(); |
333 | 333 | } |
334 | 334 |
|
335 | 335 | public Long next() { |
336 | | - return rowGroupRowIdxOffset.get() + rowIdxInRowGroupItr.next(); |
| 336 | + return rowGroupRowIdxOffsetValue + rowIdxInRowGroupItr.next(); |
337 | 337 | } |
338 | 338 | }; |
339 | 339 | } |
| 340 | + |
| 341 | + private static class LongIterator implements PrimitiveIterator.OfLong { |
| 342 | + |
| 343 | + private final long maxValue; |
| 344 | + private long currentValue = 0; |
| 345 | + |
| 346 | + public LongIterator(long maxValue) { |
| 347 | + this.maxValue = maxValue; |
| 348 | + } |
| 349 | + |
| 350 | + @Override |
| 351 | + public long nextLong() { |
| 352 | + return currentValue++; |
| 353 | + } |
| 354 | + |
| 355 | + @Override |
| 356 | + public boolean hasNext() { |
| 357 | + return currentValue < maxValue; |
| 358 | + } |
| 359 | + } |
340 | 360 | } |
0 commit comments