Created
November 18, 2013 10:48
-
-
Save llasram/7525890 to your computer and use it in GitHub Desktop.
Example of using Parkour with multiple outputs from a map-only job.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns parkour.examples.mmo | |
| "Where `mmo` stands for Multiple Map Output." | |
| (:require [clojure.string :as str] | |
| [clojure.core.reducers :as r] | |
| [parkour (conf :as conf) (fs :as fs) (wrapper :as w) | |
| (mapreduce :as mr) (graph :as pg) (tool :as tool)] | |
| [parkour.io (dseq :as dseq) (text :as text) (dux :as dux)] | |
| [parkour.util :refer [returning]])) | |
| (defn ->prefix | |
| [s] (format "%s/part" (subs s 0 1))) | |
| (defn mapper | |
| [input] | |
| (->> (mr/vals input) | |
| (r/mapcat #(str/split % #"\s+")) | |
| (r/map (juxt ->prefix identity)) | |
| (mr/sink-as (dux/prefix-keys :default)))) | |
| (defn split-initial | |
| [conf dseq dsink] | |
| (-> (pg/input dseq) | |
| (pg/map #'mapper) | |
| (pg/output :default dsink) | |
| (pg/execute conf "mmo") | |
| first)) | |
| (defn tool | |
| [conf & args] | |
| (let [[outpath & inpaths] args | |
| dseq (apply text/dseq inpaths) | |
| dsink (text/dsink outpath)] | |
| (split-initial conf dseq dsink))) | |
| (defn -main | |
| [& args] (System/exit (tool/run tool args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment