0
0
Apache Sparkdata~10 mins

Broadcast variables in Apache Spark - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a broadcast variable in Spark.

Apache Spark
broadcastVar = sc.[1](value)
Drag options to blanks, or click blank then click option'
Acollect
Baccumulator
Cparallelize
Dbroadcast
Attempts:
3 left
💡 Hint
Common Mistakes
Using sc.accumulator instead of sc.broadcast
Trying to use sc.collect which is for actions
Using sc.parallelize which creates RDDs
2fill in blank
medium

Complete the code to access the value of a broadcast variable.

Apache Spark
value = broadcastVar.[1]
Drag options to blanks, or click blank then click option'
Avalue
Bvalue()
CgetValue()
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call a method like getValue()
Using parentheses after value attribute
3fill in blank
hard

Fix the error in the code to broadcast a dictionary named 'config'.

Apache Spark
broadcastConfig = sc.[1](config)
Drag options to blanks, or click blank then click option'
Abroadcast
BbroadcastVar
Cbroadcast_variable
DbroadcastVar()
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like broadcastVar or broadcast_variable
Trying to call broadcastVar as a function
4fill in blank
hard

Fill both blanks to create a broadcast variable and access its value inside a map function.

Apache Spark
broadcastVar = sc.[1](data)
result = rdd.map(lambda x: x + broadcastVar.[2])
Drag options to blanks, or click blank then click option'
Abroadcast
Bvalue
Ccollect
Daccumulator
Attempts:
3 left
💡 Hint
Common Mistakes
Using collect instead of broadcast
Trying to call value as a method
Using accumulator instead of broadcast
5fill in blank
hard

Fill all three blanks to broadcast a list, use it in a filter, and collect the results.

Apache Spark
broadcastList = sc.[1](myList)
filtered = rdd.filter(lambda x: x in broadcastList.[2])
result = filtered.[3]()
Drag options to blanks, or click blank then click option'
Abroadcast
Bvalue
Ccollect
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using count() instead of collect() to get results
Trying to call value as a method
Using accumulator instead of broadcast