Reputation: 645
val titleMap = movies.map(line => line.split("\\|")).take(2)
//converting movie-id and movie name as map(key-pair)
val title1 = titleMap.map(array=>(array(0).toInt,array(1)))
val titles = movies.map(line => line.split("\\|").take(2)).map(array
=> (array(0).toInt,
array(1))).collectAsMap()
Whats wrong here with "title1",I am unable to apply collectAsMap function here,same thing I can apply in case of "titles"
Upvotes: 1
Views: 419
Reputation: 31543
The type of title1
is not an RDD
, so it doesn't have the method collectAsMap()
.
The type of titles
is an RDD
so it does have the method collectAsMap()
.
Advise reading up on types https://en.wikipedia.org/wiki/Type_safety, https://en.wikipedia.org/wiki/Type_system
Upvotes: 1