Commits

Miki Tebeka committed d12b599

jobs

Comments (0)

Files changed (1)

   (let [ks (keys map-result)]
     (zipmap ks (map #(reducer % (map-result %)) ks))))
 
-(defn map-reduce [mapper reducer records]
-  (reduce-stage reducer (map-stage mapper records)))
+(defn map-reduce [job records]
+  (reduce-stage (:reduce job) (map-stage (:map job) records)))
 
 (defn month-only [time]
   (date-time (year time) (month time)))
 (defn day-only [time]
   (date-time (year time) (month time) (day time)))
 
-(defn numlogs-map [record]
-  [(month-only (:time record)) 1])
-
-(defn numlogs-reduce [key values]
-  (reduce + values))
+(def numlogs {
+    :map (fn [record] [(month-only (:time record)) 1])
+    :reduce (fn [key values] (reduce + values))})
 
 (defn -main []
   (let [records (load-data "logs")]