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

Implicit conversion of Spark1.4 Source Code Walking Notes

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Implicit conversion in RDD source code

Def distinct (numPartitions: Int) (implicit ord: Ordering [T] = null): RDD [T] = withScope {

Map (x = > (x, null)). ReduceByKey ((x, y) = > x, numPartitions). Map (_. _ 1)

}

Implicit parameters are used, the runtime does not need to provide the parameter ord manually, and the runtime injects the parameters according to the context

Def groupBy [K] (f: t = > K) (implicit kt: ClassTag [K]): RDD [(K, Iterable [T])] = withScope {

GroupBy [K] (f, defaultPartitioner (this))

}

Def groupBy [K] (

F: t = > K

NumPartitions: Int) (implicit kt: ClassTag [K]): RDD [(K, Iterable [T])] = withScope {

GroupBy (f, new HashPartitioner (numPartitions))

}

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