walterddr commented on code in PR #9797:
URL: https://github.com/apache/pinot/pull/9797#discussion_r1023207885


##########
pinot-core/src/main/java/org/apache/pinot/core/segment/processing/framework/SegmentProcessorFramework.java:
##########
@@ -142,28 +142,31 @@ public List<File> process()
     for (Map.Entry<String, GenericRowFileManager> entry : 
partitionToFileManagerMap.entrySet()) {
       String partitionId = entry.getKey();
       GenericRowFileManager fileManager = entry.getValue();
-      GenericRowFileReader fileReader = fileManager.getFileReader();
-      int numRows = fileReader.getNumRows();
-      int numSortFields = fileReader.getNumSortFields();
-      LOGGER.info("Start creating segments on partition: {}, numRows: {}, 
numSortFields: {}", partitionId, numRows,
-          numSortFields);
-      GenericRowFileRecordReader recordReader = fileReader.getRecordReader();
-      for (int startRowId = 0; startRowId < numRows; startRowId += 
maxNumRecordsPerSegment, sequenceId++) {
-        int endRowId = Math.min(startRowId + maxNumRecordsPerSegment, numRows);
-        LOGGER.info("Start creating segment of sequenceId: {} with row range: 
{} to {}", sequenceId, startRowId,
-            endRowId);
-        observer.accept(String.format(
-            "Creating segment of sequentId: %d with data from partition: %s 
and row range: [%d, %d) out of [0, %d)",
-            sequenceId, partitionId, startRowId, endRowId, numRows));
-        generatorConfig.setSequenceId(sequenceId);
-        GenericRowFileRecordReader recordReaderForRange = 
recordReader.getRecordReaderForRange(startRowId, endRowId);
-        SegmentIndexCreationDriverImpl driver = new 
SegmentIndexCreationDriverImpl();
-        driver.init(generatorConfig, new 
RecordReaderSegmentCreationDataSource(recordReaderForRange),
-            TransformPipeline.getPassThroughPipeline());
-        driver.build();
-        outputSegmentDirs.add(driver.getOutputDirectory());
+      try {
+        GenericRowFileReader fileReader = fileManager.getFileReader();
+        int numRows = fileReader.getNumRows();
+        int numSortFields = fileReader.getNumSortFields();
+        LOGGER.info("Start creating segments on partition: {}, numRows: {}, 
numSortFields: {}", partitionId, numRows,
+            numSortFields);
+        GenericRowFileRecordReader recordReader = fileReader.getRecordReader();
+        for (int startRowId = 0; startRowId < numRows; startRowId += 
maxNumRecordsPerSegment, sequenceId++) {
+          int endRowId = Math.min(startRowId + maxNumRecordsPerSegment, 
numRows);
+          LOGGER.info("Start creating segment of sequenceId: {} with row 
range: {} to {}", sequenceId, startRowId,
+              endRowId);
+          observer.accept(String.format(
+              "Creating segment of sequentId: %d with data from partition: %s 
and row range: [%d, %d) out of [0, %d)",
+              sequenceId, partitionId, startRowId, endRowId, numRows));
+          generatorConfig.setSequenceId(sequenceId);
+          GenericRowFileRecordReader recordReaderForRange = 
recordReader.getRecordReaderForRange(startRowId, endRowId);
+          SegmentIndexCreationDriverImpl driver = new 
SegmentIndexCreationDriverImpl();
+          driver.init(generatorConfig, new 
RecordReaderSegmentCreationDataSource(recordReaderForRange),
+              TransformPipeline.getPassThroughPipeline());
+          driver.build();
+          outputSegmentDirs.add(driver.getOutputDirectory());
+        }
+      } finally {
+        fileManager.cleanUp();

Review Comment:
   looks like we can assert _mapperOutputDir is cleaned in 
`SegmentProcessorFramework` before calling 
`FileUtils.cleanDirectory(workingDir);`?



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to