You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2019/01/23 06:05:12 UTC

[GitHub] qiuchenjian commented on a change in pull request #3095: [CARBONDATA-3265] Fixed memory Leak and Query performance issue in Range Partition

qiuchenjian commented on a change in pull request #3095: [CARBONDATA-3265] Fixed memory Leak and Query performance issue in Range Partition
URL: https://github.com/apache/carbondata/pull/3095#discussion_r250064768
 
 

 ##########
 File path: integration/spark-common/src/main/scala/org/apache/carbondata/spark/load/DataLoadProcessBuilderOnSpark.scala
 ##########
 @@ -221,9 +247,32 @@ object DataLoadProcessBuilderOnSpark {
       .map(_._2)
 
     // 4. Sort and Write data
-    sc.runJob(rangeRDD, (context: TaskContext, rows: Iterator[CarbonRow]) =>
+    sc.runJob(rangeRDD, (context: TaskContext, rows: Iterator[CarbonRow]) => {
+      TaskContext.get.addTaskCompletionListener(_ => ThreadLocalSessionInfo.unsetAll())
+      val carbonSessionInfo: CarbonSessionInfo = {
+        var info = ThreadLocalSessionInfo.getCarbonSessionInfo
+        if (info == null || null == info.getSessionParams) {
+          info = new CarbonSessionInfo
+          info.setSessionParams(new SessionParams())
+        }
+        info.getSessionParams.addProps(CarbonProperties.getInstance().getAddedProperty)
+        info
+      }
+      carbonSessionInfo.getNonSerializableExtraInfo.put("carbonConf", conf.value.value)
+      TaskContext.get.addTaskCompletionListener { _ =>
+        CommonUtil.clearUnsafeMemory(ThreadLocalTaskInfo.getCarbonTaskInfo.getTaskId)
+      }
+      ThreadLocalSessionInfo.setCarbonSessionInfo(carbonSessionInfo)
+      TaskMetricsMap.threadLocal.set(Thread.currentThread().getId)
+      val carbonTaskInfo = new CarbonTaskInfo
+      carbonTaskInfo.setTaskId(CarbonUtil.generateUUID())
+      ThreadLocalTaskInfo.setCarbonTaskInfo(carbonTaskInfo)
+      carbonSessionInfo.getSessionParams.getAddedProps.asScala.map {
+        f => CarbonProperties.getInstance().addProperty(f._1, f._2)
+      }
 
 Review comment:
   seems that two pieces of code are the sameļ¼Œ better to use a method

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services