Skip to content

Commit 590d6da

Browse files
committed
Style: import PartialFunction as ~>
1 parent cc1cb55 commit 590d6da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/scala/com/spark_helper/SparkHelper.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import org.apache.hadoop.mapred.{FileSplit, TextInputFormat => TextInputFormat2}
1313

1414
import scala.reflect.ClassTag
1515

16+
import scala.{PartialFunction => ~>}
17+
1618
import scala.util.Random
1719

1820
/** A facility to deal with RDD/file manipulations based on the Spark API.
@@ -91,7 +93,7 @@ object SparkHelper extends Serializable {
9193
* @return an rdd of the same type, for which each element is either the
9294
* application of the partial function where defined or the identity.
9395
*/
94-
def partialMap(pf: PartialFunction[T, T]): RDD[T] =
96+
def partialMap(pf: T ~> T): RDD[T] =
9597
rdd.map {
9698
case x if pf.isDefinedAt(x) => pf(x)
9799
case x => x
@@ -105,7 +107,7 @@ object SparkHelper extends Serializable {
105107
* {{{ RDD((1, "a"), (2, "b")).withKey(_._1) // RDD(1, (1, "a")), (2, (2, "b")) }}}
106108
*
107109
* @param toKey the function to apply to extract the key
108-
* @return an rdd of (K, V) from an RDD of V where K is determined by
110+
* @return an RDD of (K, V) from an RDD of V where K is determined by
109111
* applying toKey on V.
110112
*/
111113
def withKey[K](toKey: T => K): RDD[(K, T)] = rdd.map(x => (toKey(x), x))

0 commit comments

Comments
 (0)