Skip to content

Commit

Permalink
simplify wordcount example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji Zhang committed Feb 12, 2013
1 parent 2a6e929 commit 1ffff9d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 67 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

## Usage

### src/cia-hadoop/wordcount5.clj
### Import into Eclipse

* Compile
$ lein eclipse

### Wordcount Example

* Run locally with `lein`:

$ lein test

* Compile:

$ lein uberjar

* Run locally:
* Run locally with `java`:

$ java -cp target/cia-hadoop-0.1.0-SNAPSHOT-standalone.jar clojure_hadoop.job -job cia-hadoop.wordcount5/job -input README.md -output out5
$ java -cp target/cia-hadoop-0.1.0-SNAPSHOT-standalone.jar clojure_hadoop.job -job cia-hadoop.wordcount/job

* Run on a cluster:

$ hadoop jar target/cia-hadoop-0.1.0-SNAPSHOT-standalone.jar clojure_hadoop.job -job cia-hadoop.wordcount5/job -input README.md -output out5
$ hadoop jar target/cia-hadoop-0.1.0-SNAPSHOT-standalone.jar clojure_hadoop.job -job cia-hadoop.wordcount/job

## License

Expand Down
3 changes: 1 addition & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]
[clojure-hadoop "1.4.1"]]
:plugins [[lein2-eclipse "2.0.0"]]
:aot [cia-hadoop.wordcount5])
:plugins [[lein2-eclipse "2.0.0"]])
6 changes: 0 additions & 6 deletions src/cia_hadoop/core.clj

This file was deleted.

23 changes: 23 additions & 0 deletions src/cia_hadoop/wordcount.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(ns cia-hadoop.wordcount
(:require [clojure-hadoop.wrap :as wrap]
[clojure-hadoop.defjob :as defjob])
(:import [java.util StringTokenizer])
(:use clojure-hadoop.job))

(defn my-map [key value]
(map (fn [token] [token 1])
(enumeration-seq (StringTokenizer. value))))

(defn my-reduce [key values-fn]
[[key (reduce + (values-fn))]])

(defjob/defjob job
:map my-map
:map-reader wrap/int-string-map-reader
:reduce my-reduce
:input-format :text
:output-format :text
:compress-output false
:replace true
:input "README.md"
:output "out-wordcount")
42 changes: 0 additions & 42 deletions src/cia_hadoop/wordcount5.clj

This file was deleted.

12 changes: 0 additions & 12 deletions test/cia_hadoop/core_test.clj

This file was deleted.

7 changes: 7 additions & 0 deletions test/cia_hadoop/wordcount_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns cia-hadoop.wordcount-test
(:use clojure.test
clojure-hadoop.job
cia-hadoop.wordcount))

(deftest test-wordcount
(is (run job)))

0 comments on commit 1ffff9d

Please sign in to comment.