Code is available here: Broadcast Example
var commonWords = Array("a", "an", "the", "of", "at", "is", "am","are","this","that","at", "in", "or", "and", "or", "not", "be", "for", "to", "it") | |
val commonWordsMap = collection.mutable.Map[String, Int]() | |
for(word <- commonWords){ | |
commonWordsMap(word) = 1 | |
} | |
var commonWordsBC = sc.broadcast(commonWordsMap) | |
var file = sc.textFile("/data/mr/wordcount/input/big.txt") | |
def toWords(line:String):Array[String] = { | |
var words = line.split(" ") | |
var output = Array[String](); | |
for(word <- words){ | |
if(! (commonWordsBC.value contains word.toLowerCase.trim.replaceAll("[^a-z]",""))) output = output :+ word; | |
} | |
return output; | |
} | |
var uncommonWords = file.flatMap(toWords) | |
uncommonWords.take(100) |
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Please login to comment
24 Comments
This comment has been removed.
This comment has been removed.
Hi,
Please go through previous slides and chapters and let us know which topic you didn't understand.
Thanks.
Upvote ShareAlso, we have provided the live session recordings, so feel free to go through them for better understanding.
Upvote ShareIt is throwing an error. I am just copying and pasting the codes. Actually didn't understood even a single line.
Upvote ShareThis comment has been removed.
Hi,
Please go through previous slides and chapters and let us know which topic you didn't understand.
Thanks.
Upvote SharePlease go thru the previous sessions and also the recordings of the live session.
Upvote ShareHey! Cloudxlab Team,
It looks like the code needs some update. Upon running, it returned a NullPointerException error.
Upvote ShareThis comment has been removed.
Code is available here: there is no link
Upvote ShareHi, Amit.
Here is the link you can find all the codes here.
https://gist.github.com/girisandeep/f12ab4bf2536dc5f0a8ca673efbac1db#file-broadcast-example-scala
All
Upvote ShareHi
There is no link or code shared as shown on the attached screen shot. Please share the link.
Hi Dilip,
Code is there, can you please try reloading?.
It may take longer as it is rendering from github.
If it is still not visible then please go to this link: https://gist.github.com/girisandeep/f12ab4bf2536dc5f0a8ca673efbac1db#file-broadcast-example-scala
Upvote ShareNo code is visible as shared in snippet
Hi Anant,
Code is there, can you please try reloading?.
It may take longer as it is rendering from github.
If it is still not visible then please go to this link: https://gist.github.com/girisandeep/f12ab4bf2536dc5f0a8ca673efbac1db#file-broadcast-example-scala
Upvote ShareSir ,Why all these type of new heavy codes are not explained everytime ??
Upvote Shareplease also explain all the terms and function you are using as we are doing scala for the very first time in every vedio you guys are coming up with a new operation and only keeps on dictating it instead of making us understand.
REALLY REALLY DISAPPOINTED!!!
1 Upvote Sharenot able to find link
Upvote ShareWhen I run the above code I get the following error---
Name: org.apache.spark.SparkException
1 Upvote ShareMessage: Job aborted due to stage failure: Task 0 in stage 0.0 failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0, localhost, executor driver): java.lang.NullPointerException
at $line13.$read$$iw$$iw$$iw$$iw$$iw$$iw$$anonfun$toWords$1.apply(<console>:39)
at $line13.$re
Hi Sandeep,
Upvote ShareI couldn't see any link below of "Code is available here:"
Hi, Dhirendra.
Can you please check again!.
The code is just below the video!. It is completely visible!
Please let me know if still you could not find it.
All the best!
Upvote ShareCode is available here:
But there is no link or code.
Upvote ShareHi Thiago,
Upvote ShareThe code is there in the section just below the text.