diff options
author | huangzhaowei <carlmartinmax@gmail.com> | 2014-11-11 03:02:12 -0800 |
---|---|---|
committer | Tathagata Das <tathagata.das1565@gmail.com> | 2014-11-11 03:02:12 -0800 |
commit | 6e03de304e0294017d832763fd71e642736f8c33 (patch) | |
tree | a87821a812a62c213345a30f760e0e589a6844de /streaming/src | |
parent | c8850a3d6d948f9dd9ee026ee350428968d3c21b (diff) | |
download | spark-6e03de304e0294017d832763fd71e642736f8c33.tar.gz spark-6e03de304e0294017d832763fd71e642736f8c33.tar.bz2 spark-6e03de304e0294017d832763fd71e642736f8c33.zip |
[Streaming][Minor]Replace some 'if-else' in Clock
Replace some 'if-else' statement by math.min and math.max in Clock.scala
Author: huangzhaowei <carlmartinmax@gmail.com>
Closes #3088 from SaintBacchus/StreamingClock and squashes the following commits:
7b7f8e7 [huangzhaowei] [Streaming][Minor]Replace some 'if-else' in Clock
Diffstat (limited to 'streaming/src')
-rw-r--r-- | streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala b/streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala index 39145a3ab0..7cd867ce34 100644 --- a/streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala +++ b/streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala @@ -41,13 +41,7 @@ class SystemClock() extends Clock { return currentTime } - val pollTime = { - if (waitTime / 10.0 > minPollTime) { - (waitTime / 10.0).toLong - } else { - minPollTime - } - } + val pollTime = math.max(waitTime / 10.0, minPollTime).toLong while (true) { currentTime = System.currentTimeMillis() @@ -55,12 +49,7 @@ class SystemClock() extends Clock { if (waitTime <= 0) { return currentTime } - val sleepTime = - if (waitTime < pollTime) { - waitTime - } else { - pollTime - } + val sleepTime = math.min(waitTime, pollTime) Thread.sleep(sleepTime) } -1 |