简体   繁体   中英

Scala FoldLeft: object RDD does not take type parameters

I'm trying to apply foldLeft to list of Strings as following:

 items.foldLeft(RDD[(String, Iterable[SomeClass])])((total, item) => total.union(fetchRDD(item))

where:

  • item is a List[String]
  • SomeClass is a simple case Class

But I receive the following exception for "RDD[(String, Iterable[SomeClass])]"-(expression in first braces of foldLeft):

"object RDD does not take type parameters"

But I receive the following exception for "RDD[(String, Iterable[WikipediaArticle])]"-(expression in first braces of foldLeft):

"object RDD does not take type parameters" - .

You have to pass an instance of type RDD[_] as first parameter in foldLeft .

Here you are passing the object RDD which as the error says does not take type parameters.

You likely want to add () like RDD[X]() to create an empty RDD and use it as the zero element in the foldLeft .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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