Skip to content

Commit 074a7f9

Browse files
maropuhvanhovell
authored andcommitted
[SPARK-23588][SQL][FOLLOW-UP] Resolve a map builder method per execution in CatalystToExternalMap
## What changes were proposed in this pull request? This pr is a follow-up pr of apache#20979 and fixes code to resolve a map builder method per execution instead of per row in `CatalystToExternalMap`. ## How was this patch tested? Existing tests. Author: Takeshi Yamamuro <[email protected]> Closes apache#21112 from maropu/SPARK-23588-FOLLOWUP.
1 parent e6b4660 commit 074a7f9

File tree

1 file changed

+6
-4
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects

1 file changed

+6
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,11 +1040,13 @@ case class CatalystToExternalMap private(
10401040
private lazy val valueConverter =
10411041
CatalystTypeConverters.createToScalaConverter(inputMapType.valueType)
10421042

1043-
private def newMapBuilder(): Builder[AnyRef, AnyRef] = {
1043+
private lazy val (newMapBuilderMethod, moduleField) = {
10441044
val clazz = Utils.classForName(collClass.getCanonicalName + "$")
1045-
val module = clazz.getField("MODULE$").get(null)
1046-
val method = clazz.getMethod("newBuilder")
1047-
method.invoke(module).asInstanceOf[Builder[AnyRef, AnyRef]]
1045+
(clazz.getMethod("newBuilder"), clazz.getField("MODULE$").get(null))
1046+
}
1047+
1048+
private def newMapBuilder(): Builder[AnyRef, AnyRef] = {
1049+
newMapBuilderMethod.invoke(moduleField).asInstanceOf[Builder[AnyRef, AnyRef]]
10481050
}
10491051

10501052
override def eval(input: InternalRow): Any = {

0 commit comments

Comments
 (0)