Skip to content

Commit 6e03de3

Browse files
SaintBacchustdas
authored andcommitted
[Streaming][Minor]Replace some 'if-else' in Clock
Replace some 'if-else' statement by math.min and math.max in Clock.scala Author: huangzhaowei <[email protected]> Closes #3088 from SaintBacchus/StreamingClock and squashes the following commits: 7b7f8e7 [huangzhaowei] [Streaming][Minor]Replace some 'if-else' in Clock
1 parent c8850a3 commit 6e03de3

File tree

1 file changed

+2
-13
lines changed
  • streaming/src/main/scala/org/apache/spark/streaming/util

1 file changed

+2
-13
lines changed

streaming/src/main/scala/org/apache/spark/streaming/util/Clock.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,15 @@ class SystemClock() extends Clock {
4141
return currentTime
4242
}
4343

44-
val pollTime = {
45-
if (waitTime / 10.0 > minPollTime) {
46-
(waitTime / 10.0).toLong
47-
} else {
48-
minPollTime
49-
}
50-
}
44+
val pollTime = math.max(waitTime / 10.0, minPollTime).toLong
5145

5246
while (true) {
5347
currentTime = System.currentTimeMillis()
5448
waitTime = targetTime - currentTime
5549
if (waitTime <= 0) {
5650
return currentTime
5751
}
58-
val sleepTime =
59-
if (waitTime < pollTime) {
60-
waitTime
61-
} else {
62-
pollTime
63-
}
52+
val sleepTime = math.min(waitTime, pollTime)
6453
Thread.sleep(sleepTime)
6554
}
6655
-1

0 commit comments

Comments
 (0)