You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/26 20:01:42 UTC

[GitHub] [spark] viirya commented on a change in pull request #27013: [SPARK-30356][SQL] Codegen support for the function str_to_map

viirya commented on a change in pull request #27013: [SPARK-30356][SQL] Codegen support for the function str_to_map
URL: https://github.com/apache/spark/pull/27013#discussion_r361523532
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
 ##########
 @@ -451,5 +452,25 @@ case class StringToMap(text: Expression, pairDelim: Expression, keyValueDelim: E
     mapBuilder.build()
   }
 
+  override protected def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
+    val builderTerm = ctx.addReferenceObj("mapBuilder", mapBuilder)
+    val keyValues = ctx.freshName("kvs")
+    val idx = ctx.freshName("i")
+    val kv = ctx.freshName("kv")
+
+    nullSafeCodeGen(ctx, ev, (text, pd, kvd) =>
+      s"""
+         |int $idx = 0;
+         |UTF8String[] $keyValues = $text.split($pd, -1);
+         |while ($idx < $keyValues.length) {
+         |  UTF8String[] $kv = $keyValues[$idx].split($kvd, 2);
 
 Review comment:
   nit: we don't need create fresh name for kv. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org