Module 2: Module 2
Concepts
• RDDs (Resilient Distributed Datasets) – Immutable distributed collections.
• Lazy evaluation with DAG execution.
• Transformations: map, filter, flatMap, union, join.
• Actions: collect, count, reduce, take, saveAsTextFile.
Example
rdd = [Link]([1,2,3,4,5]) squared = [Link](lambda x: x**2)
print([Link]()) # [1,4,9,16,25]
Exercises
• Create RDD of numbers 1–20, filter even numbers, square them.
• Load text file, count word frequency.
• Compare lazy evaluation vs action.
Interview Questions
• Difference between RDD, DataFrame, Dataset.
• Why is Spark lazily evaluated?
• Difference between narrow vs wide transformations.