Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Implicit conversion of Spark1.4 Source Code Walking Notes

Shulou Source: shulou.com Published: 2022-06-03 04:30:55 11月25日 Update

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))

}

Tags: Parameters run source code up and down context manual notes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi MariaDB macOS Linux