【发布时间】:2016-04-26 16:11:18
【问题描述】:
我对@987654323@ 上的join 或cogroup 方法有疑问。具体来说,我必须加入两个RDDs,其中一个是泛型类型的RDD,与通配符一起使用。
val indexedMeasures = measures.map(m => (m.id(), m)) // RDD[(String, Measure[_]]
val indexedRegistry = registry.map(r => (r.id, r)) // RDD[(String, Registry)]
indexedRegistry.cogroup(indexedMeasures)
最后一条语句给出了编译时错误,如下:
no type parameters for method cogroup: (other: org.apache.spark.rdd.RDD[(String, W)])org.apache.spark.rdd.RDD[(String, (Iterable[Registry],
Iterable[W]))] exist so that it can be applied to arguments (org.apache.spark.rdd.RDD[(String, Measure[?0]) forSome { type ?0 }]) --- because --- argument expression's type is not compatible
with formal parameter type; found : org.apache.spark.rdd.RDD[(String, Measure[?0]) forSome { type ?0 }] required: org.apache.spark.rdd.RDD[(String, ?W)] Note: (String,
Measure[?0]) forSome { type ?0 } >: (String, ?W), but class RDD is invariant in type T. You may wish to define T as -T instead. (SLS 4.5)
这里发生了什么?为什么我不能cogroupRDDs 使用泛型通配符类型?
感谢您的所有回复。
【问题讨论】:
标签: scala generics apache-spark rdd