Scala报错value reduceByKey is not a member of Array[(String, Int)]
1.原因在于在spark中,使用scala编程时,没有使用pairRDD
2.错误代码示例:
val book = Array(("spark",2),("hadoop",6),("hadoop",4),("spark",6))
val result = book.reduceByKey(_+_)
3.修正如下:
val book = Array(("spark",2),("hadoop",6),("hadoop",4),("spark",6))
val rdd = sc.parallelize(book)
val result = book.reduceByKey(_+_)