jackylk commented on a change in pull request #3535: [WIP] Refactory data
loading for partition table
URL: https://github.com/apache/carbondata/pull/3535#discussion_r361857628
##########
File path:
integration/spark2/src/main/scala/org/apache/spark/sql/execution/datasources/SparkCarbonTableFormat.scala
##########
@@ -206,16 +215,193 @@ with Serializable {
case class CarbonSQLHadoopMapReduceCommitProtocol(jobId: String, path: String,
isAppend: Boolean)
extends SQLHadoopMapReduceCommitProtocol(jobId, path, isAppend) {
+
+ override def setupTask(taskContext: TaskAttemptContext): Unit = {
+ if (isCarbonDataFlow(taskContext.getConfiguration)) {
+
ThreadLocalSessionInfo.setConfigurationToCurrentThread(taskContext.getConfiguration)
+ }
+ super.setupTask(taskContext)
+ }
+
+ override def commitJob(jobContext: JobContext,
+ taskCommits: Seq[TaskCommitMessage]): Unit = {
+ if (isCarbonDataFlow(jobContext.getConfiguration)) {
+ var dataSize = 0L
+ val partitions =
+ taskCommits
+ .flatMap { taskCommit =>
+ taskCommit.obj match {
+ case (map: Map[String, String], _) =>
+ val partition = map.get("carbon.partitions")
+ val size = map.get("carbon.datasize")
+ if (size.isDefined) {
+ dataSize = dataSize + java.lang.Long.parseLong(size.get)
+ }
+ if (partition.isDefined) {
+ ObjectSerializationUtil
+ .convertStringToObject(partition.get)
+ .asInstanceOf[util.ArrayList[String]]
+ .asScala
+ } else {
+ Array.empty[String]
+ }
+ case _ => Array.empty[String]
+ }
+ }
+ .distinct
+ .toList
+ .asJava
+
+ jobContext.getConfiguration.set(
+ "carbon.output.partitions.name",
+ ObjectSerializationUtil.convertObjectToString(partitions))
+ jobContext.getConfiguration.set("carbon.datasize", dataSize.toString)
+
+ val newTaskCommits = taskCommits.map { taskCommit =>
+ taskCommit.obj match {
+ case (map: Map[String, String], set) =>
+ new TaskCommitMessage(
+ map
+ .filterNot(e => "carbon.partitions".equals(e._1) ||
"carbon.datasize".equals(e._1)),
+ set)
+ case _ => taskCommit
+ }
+ }
+ super
+ .commitJob(jobContext, newTaskCommits)
+ } else {
+ super
+ .commitJob(jobContext, taskCommits)
+ }
+ }
+
+ override def commitTask(
Review comment:
add description
----------------------------------------------------------------
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