aboutsummaryrefslogtreecommitdiff
path: root/streaming
diff options
context:
space:
mode:
authorwangyang <wangyang@haizhi.com>2016-06-10 13:10:03 -0700
committerReynold Xin <rxin@databricks.com>2016-06-10 13:10:03 -0700
commit026eb90644be7685971dacaabae67a293edd0133 (patch)
treecacc1ed1fb398d122bb5a46fd20b94574203fd58 /streaming
parent865ec32dd997e63aea01a871d1c7b4947f43c111 (diff)
downloadspark-026eb90644be7685971dacaabae67a293edd0133.tar.gz
spark-026eb90644be7685971dacaabae67a293edd0133.tar.bz2
spark-026eb90644be7685971dacaabae67a293edd0133.zip
[SPARK-15875] Try to use Seq.isEmpty and Seq.nonEmpty instead of Seq.length == 0 and Seq.length > 0
## What changes were proposed in this pull request? In scala, immutable.List.length is an expensive operation so we should avoid using Seq.length == 0 or Seq.lenth > 0, and use Seq.isEmpty and Seq.nonEmpty instead. ## How was this patch tested? existing tests Author: wangyang <wangyang@haizhi.com> Closes #13601 from yangw1234/isEmpty.
Diffstat (limited to 'streaming')
-rw-r--r--streaming/src/main/scala/org/apache/spark/streaming/dstream/TransformedDStream.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/streaming/src/main/scala/org/apache/spark/streaming/dstream/TransformedDStream.scala b/streaming/src/main/scala/org/apache/spark/streaming/dstream/TransformedDStream.scala
index 47eb9b806f..0dde120927 100644
--- a/streaming/src/main/scala/org/apache/spark/streaming/dstream/TransformedDStream.scala
+++ b/streaming/src/main/scala/org/apache/spark/streaming/dstream/TransformedDStream.scala
@@ -29,7 +29,7 @@ class TransformedDStream[U: ClassTag] (
transformFunc: (Seq[RDD[_]], Time) => RDD[U]
) extends DStream[U](parents.head.ssc) {
- require(parents.length > 0, "List of DStreams to transform is empty")
+ require(parents.nonEmpty, "List of DStreams to transform is empty")
require(parents.map(_.ssc).distinct.size == 1, "Some of the DStreams have different contexts")
require(parents.map(_.slideDuration).distinct.size == 1,
"Some of the DStreams have different slide durations")