chenjunjiedada commented on a change in pull request #1474:
URL: https://github.com/apache/iceberg/pull/1474#discussion_r490628655



##########
File path: parquet/src/main/java/org/apache/iceberg/parquet/ReadConf.java
##########
@@ -166,17 +167,22 @@ ParquetFileReader reader() {
   }
 
   private Map<Long, Long> generateOffsetToStartPos() {
-    ParquetFileReader fileReader = newReader(this.file, 
ParquetReadOptions.builder().build());
-    Map<Long, Long> offsetToStartPos = new HashMap<>();
-    long curRowCount = 0;
-    for (int i = 0; i < fileReader.getRowGroups().size(); i += 1) {
-      BlockMetaData meta = fileReader.getRowGroups().get(i);
-      offsetToStartPos.put(meta.getStartingPos(), curRowCount);
-      curRowCount += meta.getRowCount();
-    }
+      try (ParquetFileReader fileReader = newReader(file, 
ParquetReadOptions.builder().build())) {
+        Map<Long, Long> offsetToStartPos = new HashMap<>();
 
-    return offsetToStartPos;
-  }
+        long curRowCount = 0;
+        for (int i = 0; i < fileReader.getRowGroups().size(); i += 1) {
+          BlockMetaData meta = fileReader.getRowGroups().get(i);
+          offsetToStartPos.put(meta.getStartingPos(), curRowCount);
+          curRowCount += meta.getRowCount();
+        }
+
+        return offsetToStartPos;
+
+      } catch (IOException e) {
+        throw new UncheckedIOException("Failed to close reader for file: " + 
file, e);

Review comment:
       The message may be "failed to create reader"?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to