Skip to main content
100%

Trivia: Generate primes between 1 and 100 million with Hadoop MapReduce job. Inspired by https://gist.github.com/krishnanraman/6346307.

✓ Published0🌍 Public
PP7h
Last edited Apr 13, 2014
Created on Apr 12, 2014

This example compares Hadoop MapReduce and pure Java for computing prime numbers between 1 and 100 million. It uses the Hadoop `Job`, `Mapper`, `TextInputFormat`, and `TextOutputFormat` APIs to process a file with one number per line, emitting each prime via `context.write`. The MapReduce job runs in about 2 minutes 20 seconds, while a pure Java loop takes 5 minutes 26 seconds. The output file, `part-r-00000`, contains 5,761,455 primes, demonstrating the parallel framework’s speed advantage over a single-threaded approach.

AI-generated description

Similar vizzes