Indhumathi27 commented on a change in pull request #3622: [CARBONDATA-3702]
Clean temp index files in parallel in merge index flow
URL: https://github.com/apache/carbondata/pull/3622#discussion_r382525290
##########
File path:
integration/spark-common/src/main/scala/org/apache/spark/rdd/CarbonMergeFilesRDD.scala
##########
@@ -157,21 +157,23 @@ object CarbonMergeFilesRDD {
if (carbonTable.isHivePartitionTable &&
!StringUtils.isEmpty(tempFolderPath)) {
// remove all tmp folder of index files
val startDelete = System.currentTimeMillis()
- val numThreads = Math.min(Math.max(partitionInfo.size(), 1), 10)
- val executorService = Executors.newFixedThreadPool(numThreads)
- val carbonSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo
+ // get all files in all folder of index files
+ val allTmpFiles = partitionInfo
+ .asScala
+ .map { partitionPath =>
+ FileFactory.getCarbonFile(partitionPath + "/" + tempFolderPath)
+ .listFiles().toList
+ }.toList.flatten.map(_.getAbsolutePath)
+ // delete files in parallel
+ sparkSession.sparkContext.parallelize(allTmpFiles).map {
+ deleteFileWithRetry(_, 3)
+ }.collect()
+ // delete dirs
partitionInfo
.asScala
.map { partitionPath =>
- executorService.submit(new Runnable {
- override def run(): Unit = {
- ThreadLocalSessionInfo.setCarbonSessionInfo(carbonSessionInfo)
- FileFactory.deleteAllCarbonFilesOfDir(
- FileFactory.getCarbonFile(partitionPath + "/" +
tempFolderPath))
- }
- })
+ FileFactory.deleteFile(partitionPath + "/" + tempFolderPath)
Review comment:
Can use CarbonCommonConstants.FILE_SEPARATOR instead of "/"
----------------------------------------------------------------
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]
With regards,
Apache Git Services