2017-08-10 3 views
0

もう一つの問題不変です。次のように:これは初心者のために仕事を得るためにどのようにスパークScalaのクラスが、RDDは、型Tに初心者のための

<console>:182: error: type mismatch; 
found : org.apache.spark.rdd.RDD[Product with Serializable] 
required: org.apache.spark.rdd.RDD[(String, Int)] 
Note: Product with Serializable >: (String, Int), but class RDD is invariant in type T. 
You may wish to define T as -T instead. (SLS 4.5) 
    val rddunion = rdd1.union(rdd2).collect() 
          ^

val rdd0 = sc.parallelize(List("a", "b", "c", "d", "e")) 
val rdd1 = rdd0.map(x => (x, 110 - x.toCharArray()(0).toByte)) 
val rdd2 = sc.parallelize(List(("c", 2), ("d, 2)", ("e", 2), ("f", 2)))) 
//Seemingly the same type but not, how practically to get them to be UNIONed? 
val rddunion = rdd1.union(rdd2).collect() 

はこれを取得します。 Scalaではなぜ人々が少し躊躇しているのか分かります。文書の一部を読むが、完全にはっきりしない。このUNION of RDDを動作させる方法

非常に感謝します。

+0

おかげで、私は本当にマークダウンが大好き! – thebluephantom

答えて

3

あなたは間違った場所に("d, 2)"

"を書いているが、その代わりに

val rdd2 = sc.parallelize(List(("c", 2), ("d, 2)", ("e", 2), ("f", 2)))) 

の正しいものは

val rdd2 = sc.parallelize(List(("c", 2), ("d", 2), ("e", 2), ("f", 2))) 
関連する問題