Github user zsxwing commented on a diff in the pull request: https://github.com/apache/spark/pull/15512#discussion_r83697175 --- Diff: core/src/main/scala/org/apache/spark/scheduler/TaskResult.scala --- @@ -77,14 +78,12 @@ private[spark] class DirectTaskResult[T]( * * After the first time, `value()` is trivial and just returns the deserialized `valueObject`. */ - def value(): T = { + def value(resultSer: SerializerInstance = null): T = { if (valueObjectDeserialized) { valueObject } else { - // This should not run when holding a lock because it may cost dozens of seconds for a large - // value. - val resultSer = SparkEnv.get.serializer.newInstance() - valueObject = resultSer.deserialize(valueBytes) + valueObject = Option(resultSer).getOrElse(SparkEnv.get.serializer.newInstance()) --- End diff -- nit: I prefer the following codes because `Option(...).getOrElse` doesn't improve the readability but creates unnecessary objects. ```Scala val resultSer = if (resultSer == null) SparkEnv.get.serializer.newInstance() else resultSer valueObject = resultSer.deserialize(valueBytes) ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org