org.apache.hadoop.examples
Class WordCount

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.examples.WordCount
All Implemented Interfaces:
Configurable, Tool

public class WordCount
extends Configured
implements Tool

This is an example Hadoop Map/Reduce application. It reads the text input files, breaks each line into words and counts them. The output is a locally sorted list of words and the count of how often they occurred. To run: bin/hadoop jar build/hadoop-examples.jar wordcount [-m maps] [-r reduces] in-dir out-dir


Nested Class Summary
static class WordCount.MapClass
          Counts the words in each line.
static class WordCount.Reduce
          A reducer class that just emits the sum of the input values.
 
Constructor Summary
WordCount()
           
 
Method Summary
static void main(String[] args)
           
 int run(String[] args)
          The main driver for word count map/reduce program.
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
 

Constructor Detail

WordCount

public WordCount()
Method Detail

run

public int run(String[] args)
        throws Exception
The main driver for word count map/reduce program. Invoke this method to submit the map/reduce job.

Specified by:
run in interface Tool
Parameters:
args - command specific arguments.
Returns:
exit code.
Throws:
IOException - When there is communication problems with the job tracker.
Exception

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2008 The Apache Software Foundation