100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

The Reduce Phase

How reducers consume grouped intermediate data, apply the reduce() contract, and commit final output, including reducer count tuning and fault tolerance.

MapReduceIntermediate9 min readJul 10, 2026
Analogies

Overview of the Reduce Phase

The reduce phase is the final stage of a MapReduce job and is itself commonly described as three sub-phases: copy (fetching partitioned map output), sort (merging fetched segments into one grouped stream), and reduce (invoking the user's reduce() method once per distinct key). Only once all the values for a key have been merged and grouped does the framework call reduce(key, values, context) — this guarantee is what allows a reducer to compute things like a running total, a maximum, or a distinct count correctly, since it is certain it has seen every value for that key before finishing.

🏏

Cricket analogy: A tournament's official statistician doesn't publish a batsman's final tournament average until every single match's scoresheet has been collected and combined, ensuring the number reflects all innings, just as reduce() only runs once all values for a key are gathered.

The Reducer Contract

A Reducer's reduce() method receives a key and an Iterable<VALUEIN> representing every value emitted for that key across all mappers, and it can emit zero, one, or many output key-value pairs via context.write(). A crucial and often-missed detail is that the values Iterable is single-pass and backed by data that gets overwritten as iteration proceeds — Hadoop reuses the same Writable object for efficiency, so if you need to retain values beyond a single pass (say, to compute both a min and a max in ways that need the raw list), you must explicitly copy them rather than just storing the Writable reference, or every stored 'copy' will end up holding the last value seen.

🏏

Cricket analogy: A commentator calling out a bowler's figures live only gets to watch each ball's replay once as it streams by; if they want to reference an earlier delivery later, they must write it down themselves rather than expect the broadcast feed to replay it, mirroring the single-pass values iterator.

Number of Reducers and Its Impact

The number of reduce tasks is set explicitly via job.setNumReduceTasks() (or mapreduce.job.reduces) rather than derived automatically from data size, and this choice has real consequences: too few reducers under-parallelizes the reduce phase and can create huge output files, while too many reducers creates many small output files and adds scheduling and merge overhead disproportionate to the work each one does. Setting the reducer count to zero produces a map-only job, useful for pure filtering or transformation tasks where no cross-record aggregation by key is needed, and skips the shuffle-and-sort phase entirely since there's nothing to group.

🏏

Cricket analogy: A tournament organizer deciding how many finals venues to book has to balance too few venues causing overcrowding against too many venues splitting attendance too thinly, mirroring the tradeoff in choosing reducer count.

java
public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {

    private final IntWritable result = new IntWritable();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context)
            throws IOException, InterruptedException {
        int sum = 0;
        for (IntWritable val : values) {
            sum += val.get(); // values Iterable is single-pass; read once
        }
        result.set(sum);
        context.write(key, result);
    }
}

A reasonable starting heuristic for choosing reducer count is roughly 0.95 to 1.75 times (number of NodeManagers × mapreduce.tasktracker.reduce.tasks.maximum), which lets the fastest reducers pick up a second wave of work while slower nodes finish their first, keeping the cluster busy without over-fragmenting output files.

Output Committing and Fault Tolerance

Each reduce task writes its output not directly to the final output directory but to a task-attempt-specific temporary directory (something like _temporary/1/_temporary/attempt_.../), and only after the task completes successfully does the OutputCommitter promote that directory's contents to the job's final output location — this is what makes speculative execution and task retries safe, since two attempts at the same task can write to separate temp locations without colliding, and only one attempt's output is ever actually committed. The FileOutputCommitter protocol coordinates this two-phase commit (task commit, then job commit) so that even if the ApplicationMaster itself fails partway through, no partial or duplicate output is visible in the final directory.

🏏

Cricket analogy: A DRS review keeps the on-field umpire's original call unofficial until the third umpire's review is finalized and only then updates the official scorecard, similar to how a task's output stays in a temporary location until it's officially committed.

Never write output files directly from within map() or reduce() using raw file I/O outside the OutputCommitter's managed path (for example, opening a FileOutputStream to a fixed path). Because speculative execution can run two attempts of the same task simultaneously, and failed attempts can be retried, direct side-effect writes bypass Hadoop's commit protocol and can produce duplicated, corrupted, or partially written files.

  • The reduce phase consists of copy, sort, and reduce sub-phases, with reduce() called once per fully grouped key.
  • reduce() receives a single-pass Iterable of values, and Hadoop reuses the underlying Writable object across iterations.
  • The number of reducers is set explicitly and significantly affects parallelism and output file granularity.
  • Setting reducer count to zero produces a map-only job and skips the shuffle-and-sort phase entirely.
  • Task output is written to a temporary attempt directory and only promoted to the final path after successful commit.
  • The two-phase task/job commit protocol makes speculative execution and task retries safe from data corruption.
  • Bypassing the OutputCommitter with raw side-effect file writes can produce duplicated or corrupted output.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#HadoopStudyNotes#TheReducePhase#Reduce#Phase#Reducer#Contract#StudyNotes#SkillVeris#ExamPrep

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse