If we want to take Hadoop for a test-drive without installing the whole distribution, we can do it quite easily.
First of all, let's create a maven project with the following dependencies:
There is a known issue with running newer version on Windows, so the older one is chosen.
Cygwin is also required to be installed when running on Windows.
We will create a job to count the words in files (it's a well-known example taken from the official tutorial).
Our mapper would look like:
The mapper splits the lines from file into words and pass on each word as the key with the value of one.
Here comes the reducer:
The reducer receives all values for given key and counts them.
All that is left is a main class that will run the job:
We are setting job's mapper, reducer and classer for key and value.
Input and output paths are set as well.
You can run it directly and check the output file with the result.
The whole project can be found on github.