sajjad-moradi commented on a change in pull request #6926:
URL: https://github.com/apache/incubator-pinot/pull/6926#discussion_r633900187



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/recommender/realtime/provisioning/MemoryEstimator.java
##########
@@ -519,21 +515,23 @@ private File generateData(Date now) {
         LOGGER.info("Successfully generated data file: {}", outputFile);
         return outputFile;
       } catch (Exception e) {
+        FileUtils.deleteQuietly(new File(outputDir));

Review comment:
       deleteQuietly takes a file object not string representing the path.

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/recommender/rules/impl/SegmentSizeRule.java
##########
@@ -82,20 +82,17 @@ public void run()
         && segmentSizeRuleParams.getNumRowsInActualSegment() == 
RecommenderConstants.SegmentSizeRule.NOT_PROVIDED) {
 
       // generate a segment
-      TableConfig tableConfig = createTableConfig(_input.getSchema());
-      int numRowsInGeneratedSegment = 
segmentSizeRuleParams.getNumRowsInGeneratedSegment();
-      File generatedSegmentDir =
-          new MemoryEstimator.SegmentGenerator(_input._schemaWithMetaData, 
_input._schema, tableConfig,
-              numRowsInGeneratedSegment, true).generate();
-      segmentSize = Math.round(FileUtils.sizeOfDirectory(generatedSegmentDir)
-          * 
RecommenderConstants.SegmentSizeRule.INDEX_OVERHEAD_RATIO_FOR_SEGMENT_SIZE);
-      numRows = numRowsInGeneratedSegment;
-
-      // cleanup
+      File workingDir = Files.createTempDir();
       try {
-        FileUtils.deleteDirectory(generatedSegmentDir);
-      } catch (IOException e) {
-        throw new RuntimeException("Cannot delete the generated segment 
directory", e);
+        TableConfig tableConfig = createTableConfig(_input.getSchema());
+        int numRowsInGeneratedSegment = 
segmentSizeRuleParams.getNumRowsInGeneratedSegment();
+        File generatedSegmentDir =
+            new MemoryEstimator.SegmentGenerator(_input._schemaWithMetaData, 
_input._schema, tableConfig,
+                numRowsInGeneratedSegment, true, workingDir).generate();
+        segmentSize = 
Math.round(FileUtils.sizeOfDirectory(generatedSegmentDir) * 
RecommenderConstants.SegmentSizeRule.INDEX_OVERHEAD_RATIO_FOR_SEGMENT_SIZE);
+        numRows = numRowsInGeneratedSegment;
+      } finally {
+        FileUtils.deleteQuietly(workingDir);

Review comment:
       Please refer to previous comments.




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