Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Pattern matching of Spark1.4 Source Code Walking Notes

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Pattern matching in RDD:

def hasNext: Boolean = (thisIter.hasNext, otherIter.hasNext) match {

case (true, true) => true

case (false, false) => false

case _ => throw new SparkException("Can only zip RDDs with " +

"same number of elements in each partition")

}

jobResult = jobResult match {

case Some(value) => Some(f(value, taskResult.get))

case None => taskResult

}

take(1) match {

case Array(t) => t

case _ => throw new UnsupportedOperationException("empty collection")

}

The following is easier to understand:

val len = rdd.dependencies.length

len match {

case 0 => Seq.empty

case 1 =>

val d = rdd.dependencies.head

debugString(d.rdd, prefix, d.isInstanceOf[ShuffleDependency[_, _, _]], true)

case _ => //all in the bowl

val frontDeps = rdd.dependencies.take(len - 1)

val frontDepStrings = frontDeps.flatMap(

d => debugString(d.rdd, prefix, d.isInstanceOf[ShuffleDependency[_, _, _]]))

val lastDep = rdd.dependencies.last

val lastDepStrings =

debugString(lastDep.rdd, prefix, lastDep.isInstanceOf[ShuffleDependency[_, _, _]], true)

(frontDepStrings ++ lastDepStrings)

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report