Skip to content

Commit

Permalink
Retrieving properties from property list using iterator and while loo…
Browse files Browse the repository at this point in the history
…p instead of chained functions
  • Loading branch information
Harsh Gupta authored and Harsh Gupta committed May 21, 2015
1 parent a294569 commit f74064d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ object RpcTimeout {
require(timeoutPropList.nonEmpty)

// Find the first set property or use the default value with the first property
val foundProp = timeoutPropList.view.map(x => (x, conf.getOption(x))).filter(_._2.isDefined).
map(y => (y._1, y._2.get)).headOption.getOrElse(timeoutPropList.head, defaultValue)

val itr = timeoutPropList.iterator
var foundProp = (timeoutPropList.head,defaultValue)
while (itr.hasNext){
val propKey = itr.next()
conf.getOption(propKey) match {
case Some(prop) => foundProp = (propKey,prop)
case None =>
}
}
val timeout = { Utils.timeStringAsSeconds(foundProp._2) seconds }
new RpcTimeout(timeout, messagePrefix + foundProp._1)
}
Expand Down

0 comments on commit f74064d

Please sign in to comment.