Loading repository dataβ¦
Loading repository dataβ¦
Dansoko22md / repository
π₯ Comprehensive Apache Spark RDD workshop with 3 hands-on exercises: log analysis, sales aggregation, and distributed word counting. Learn data filtering, partitioning, map-reduce, joins & caching. Perfect for data engineering students & big data enthusiasts. Jupyter notebooks included.
A comprehensive hands-on workshop for learning Apache Spark RDD (Resilient Distributed Dataset) operations through practical exercises. This project contains three complete exercises demonstrating core Spark concepts including data filtering, aggregation, partitioning, and distributed word counting.
This workshop provides hands-on experience with Apache Spark's foundational data structure: RDDs. Through three progressive exercises, you'll learn:
Perfect for data engineering students, big data enthusiasts, or anyone looking to master Spark fundamentals.
Exercise 1: Error Log Analysis
Exercise 2: Sales Data Processing
Exercise 3: Advanced Word Count
git clone https://github.com/Dansoko22md/spark-rdd-workshop.git
cd spark-rdd-workshop
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Download Spark from https://spark.apache.org/downloads.html
# Extract to C:\spark
# Set environment variables as shown in the notebook
# Using Homebrew (macOS)
brew install apache-spark
# Or download manually
wget https://archive.apache.org/dist/spark/spark-3.5.0/spark-3.5.0-bin-hadoop3.tgz
tar -xvf spark-3.5.0-bin-hadoop3.tgz
sudo mv spark-3.5.0-bin-hadoop3 /opt/spark
Ensure JAVA_HOME is set:
# Windows
setx JAVA_HOME "C:\Program Files\Java\jdk-17"
# macOS/Linux
export JAVA_HOME=$(/usr/libexec/java_home) # macOS
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk # Linux
spark-rdd-workshop/
β
βββ atelier1.ipynb # Main workshop notebook
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ LICENSE # MIT License
β
βββ data/ # Data files
β βββ error_log.txt # Log file for Exercise 1
β βββ purchases.txt # Sales data for Exercise 2
β βββ README.md # Spark documentation
β βββ CHANGES.txt # Spark changelog
β
βββ results/ # Output directory
β βββ .gitkeep
β
βββ screenshots/ # Visual documentation
βββ .gitkeep
Objective: Filter and analyze error entries in server log files.
Key Concepts:
Code Snippet:
errors_rdd = rdd.filter(lambda line: "ERROR" in line)
error_count = errors_rdd.count()
Expected Output:
Nombre de lignes contenant 'ERROR' : 13
Objective: Calculate total sales per store from transaction data.
Key Concepts:
Code Snippet:
total_par_magasin = rdd.map(lambda line: line.split('\t')) \
.map(lambda parts: (parts[2], float(parts[4]))) \
.reduceByKey(lambda a, b: a + b)
Sample Output:
Albuquerque: 3028079.62
Anaheim: 3085295.94
Cleveland: 3121222.68
Total gΓ©nΓ©ral: 313270384.87
Objective: Count word frequencies across multiple documents using RDD joins.
Key Concepts:
Code Snippet:
rdd_joint = word_count_readme.fullOuterJoin(word_count_changes)
rdd_joint.cache()
rdd_final = rdd_joint.mapValues(combiner_counts)
Top Results:
1. spark: 3918 occurrences
2. com: 3878 occurrences
3. pull: 2833 occurrences
# Start Jupyter
jupyter notebook
# Open atelier1.ipynb
# Run cells sequentially
!pip install pyspark# Convert notebook to script
jupyter nbconvert --to script atelier1.ipynb
# Run the script
python atelier1.py
| Exercise | Dataset Size | Processing Time | RDD Partitions |
|---|---|---|---|
| Exercise 1 | ~100 lines | < 1 second | 2 |
| Exercise 2 | 4,139 records | ~2 seconds | 4 |
| Exercise 3 | 14,718 lines | ~3 seconds | Default |
Contributions are welcome! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
β Star this repository if you find it helpful! β
Happy Spark Learning! π