You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by zsxwing <gi...@git.apache.org> on 2016/10/17 17:51:32 UTC
[GitHub] spark pull request #15512: [SPARK-17930][CORE]The SerializerInstance instanc...
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org