Skip to content

Commit

Permalink
[SPARK-23588][SQL][FOLLOW-UP] Resolve a map builder method per execut…
Browse files Browse the repository at this point in the history
…ion 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 <yamamuro@apache.org>

Closes apache#21112 from maropu/SPARK-23588-FOLLOWUP.
  • Loading branch information
maropu authored and hvanhovell committed Apr 20, 2018
1 parent e6b4660 commit 074a7f9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1040,11 +1040,13 @@ case class CatalystToExternalMap private(
private lazy val valueConverter =
CatalystTypeConverters.createToScalaConverter(inputMapType.valueType)

private def newMapBuilder(): Builder[AnyRef, AnyRef] = {
private lazy val (newMapBuilderMethod, moduleField) = {
val clazz = Utils.classForName(collClass.getCanonicalName + "$")
val module = clazz.getField("MODULE$").get(null)
val method = clazz.getMethod("newBuilder")
method.invoke(module).asInstanceOf[Builder[AnyRef, AnyRef]]
(clazz.getMethod("newBuilder"), clazz.getField("MODULE$").get(null))
}

private def newMapBuilder(): Builder[AnyRef, AnyRef] = {
newMapBuilderMethod.invoke(moduleField).asInstanceOf[Builder[AnyRef, AnyRef]]
}

override def eval(input: InternalRow): Any = {
Expand Down

0 comments on commit 074a7f9

Please sign in to comment.