MapReduce - Exam Hints Cheat Sheet

Updated 5 Oct 2026

Here are high-yield, condensed cheat-sheet blocks addressing your professor’s specific exam hints (MapReduce Pseudocode, AWS EMR, and Data Cleaning Strategies).


1. MapReduce Pseudocode & Logic

  • Map Phase: Reads (Line_Number, Text_Line) →\rightarrow splits string →\rightarrow cleans tokens →\rightarrow outputs key-value pair emit(key, value).
  • Reduce Phase: Takes (key, list_of_values) →\rightarrow loops/aggregates values →\rightarrow outputs final pair emit(key, aggregated_result).
  • Word Count Example:
    • Mapper: map(doc_id, text): for word in text.split(): emit(word.lower(), 1)
    • Reducer: reduce(word, counts): emit(word, sum(counts))
  • Inverted Index Example:
    • Mapper: map(doc_id, text): for word in text.split(): emit(word, doc_id)
    • Reducer: reduce(word, doc_ids): emit(word, unique(doc_ids))
  • Optional Driver/Combiner:
    • Combiner: Mini-reducer on the Mapper node to reduce network shuffle traffic.
    • Partitioner: Routes (key, value) to specific Reducers using hash(key) % num_reducers.

2. AWS EMR Architecture & Components

  • Master Node: Manages cluster state, coordinates task distribution, runs Resource Manager (YARN) and NameNode (HDFS).
  • Core Node: Runs DataNode (HDFS) and NodeManager (YARN); handles processing AND stores persistent cluster data.
  • Task Node: Only runs processing (YARN NodeManager); no HDFS storage. Good for auto-scaling spot instances.
  • EMR vs. Self-Managed Hadoop: Elastic/auto-scaling, decoupled storage (S3 using EMRFS) and compute, automated provisioning.
  • Ephemeral Cluster: Spin up EMR →\rightarrow process data from S3 →\rightarrow write results to S3 →\rightarrow terminate cluster to save costs.

3. Data Quality & Cleaning (Handling "Dirty Data")

  • Syntax / Format Errors (Missing Commas, Quotes, Bad Delimiters):

  • Identification: Parsing failures, mismatched column counts, trailing spaces.

  • Fix: Use regex/string parsing, escape characters, or strip whitespace before splitting lines.

  • Missing Values:

  • Categorical: Replace with Mode or "Unknown".

  • Numerical: Replace with Mean/Median (Imputation) or drop row if missing rate is >50%>50\%.

  • Outliers & Invalid Values:

  • Identification: Range checks (e.g., Age<0Age < 0, Salary<0Salary < 0), IQR rule (Q1−1.5×IQRQ1 - 1.5 \times IQR, Q3+1.5×IQRQ3 + 1.5 \times IQR), or Z-score (∣Z∣>3\vert{}Z\vert{} > 3).

  • Fix: Cap values (winsorization), convert to NULL and impute, or filter out completely.

  • Duplicates & Inconsistencies:

  • Identification: Mismatched casing ("NYC" vs "new york"), duplicated primary keys.

  • Fix: Case normalization (lower()), standardizing formats (dates to YYYY-MM-DD), and deduplication (DISTINCT / grouping).


4. Extra Exam-Room Reminders (Quick Cheat-Sheet Wins)

  • Schema-on-Write vs Schema-on-Read: Data Warehouse enforces structure during ingest; Data Lake enforces structure when querying.

  • Data Verification vs Validation:

  • Validation: Checking structure, ranges, data types during/after import (Automated).

  • Verification: Ensuring accuracy against the real-world truth (e.g., manual check, two-pass entry).

  • Hadoop / YARN Terms:

  • NameNode: Master metadata storage.

  • DataNode: Block storage on local disks.

  • ResourceManager: Allocates cluster compute resources.

  • NodeManager: Executes compute containers on worker nodes.