File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen
core/src/main/scala/org/apache/spark/sql/execution/aggregate Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -318,6 +318,20 @@ class CodegenContext {
318318 }
319319 }
320320
321+ /**
322+ * Returns the code to update a variable for a given DataType.
323+ */
324+ def setValue (target : String , dataType : DataType , value : String ): String = {
325+ val jt = javaType(dataType)
326+ val codes = dataType match {
327+ case _ if isPrimitiveType(jt) => value
328+ case StringType => s " $value.clone() "
329+ case _ : StructType | _ : ArrayType | _ : MapType => s " $value.copy() "
330+ case _ => value
331+ }
332+ s " $target = $codes"
333+ }
334+
321335 /**
322336 * Returns the specialized code to set a given value in a column vector for a given `DataType`.
323337 */
@@ -375,16 +389,6 @@ class CodegenContext {
375389 }
376390 }
377391
378- def copyValue (value : String , dataType : DataType ): String = {
379- val jt = javaType(dataType)
380- val safeCopy = s " $value == null ? null : "
381- dataType match {
382- case _ if isPrimitiveType(jt) => value
383- case _ : StructType => s " $safeCopy $value.copy() "
384- case _ => s " $safeCopy $value.clone() "
385- }
386- }
387-
388392 /**
389393 * Returns the name used in accessor and setter for a Java primitive type.
390394 */
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ case class SortAggregateExec(
186186 s """
187187 | ${bufVars(i).isNull} = ${ev.isNull};
188188 | if ( ${bufVars(i).value} != ${ev.value})
189- | ${bufVars(i).value} = ${ctx.copyValue(ev.value , bufVarsType(i))};
189+ | ${ctx.setValue( bufVars(i).value, bufVarsType(i), ev.value )};
190190 """ .stripMargin
191191 }
192192 s """
You can’t perform that action at this time.
0 commit comments