简体   繁体   English

错误:值联接不是org.apache.spark.rdd.RDD [(Long,U)]的成员吗?

[英]error: value join is not a member of org.apache.spark.rdd.RDD[(Long, U)]?

I'm trying to write the following method: 我正在尝试编写以下方法:

scala>   def isEqual[U, V](expected: RDD[U], result: RDD[V]) = {
 |         val expectedIndexValue: RDD[(Long, U)] = expected.zipWithIndex().map{ case (row, idx) => (idx, row) }
 |         val resultIndexValue: RDD[(Long, V)] = result.zipWithIndex().map{ case (row, idx) => (idx, row) }
 |         val combined = expectedIndexValue.join(resultIndexValue)
 |       }

But I got the following error: 但我收到以下错误:

<console>:52: error: value join is not a member of org.apache.spark.rdd.RDD[(Long, U)]
         val combined = expectedIndexValue.join(resultIndexValue)

The join function is defined on a special type called PairRDDFunctions and there is an implicit conversion between RDDs of tuples of this special type. join函数是在称为PairRDDFunctions的特殊类型上定义的,并且此特殊类型的元组的RDD之间存在隐式转换。 If you are working in an old version of Spark you would need to import the implicit conversions eg import org.apache.spark.SparkContext._ . 如果您使用的是旧版本的Spark,则需要导入隐式转换,例如import org.apache.spark.SparkContext._ There is also an explicit (albiet deprecated) function on the SparkContext called rddToPairRDDFunctions that you can manually use. SparkContext上还有一个显式(不推荐使用)的函数rddToPairRDDFunctions ,您可以手动使用。

However both the explicit function and the implicit conversions require that the class tags for the types be present, so you could use a fake class tag, but since you're working in Scala you might as well just add the class tags as implicit params to your function. 但是,显式函数和隐式转换都要求存在类型的类标记,因此您可以使用伪造的类标记,但是由于您在Scala中工作,因此不妨将类标记作为隐式参数添加到您的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM