XDN is a Clojure(script) library for transforming EDN to EDN using EDN.
I shouldn't have done that.
Imagine you have this
[ | |
{ | |
"id":"266d9729-7678-4e5d-8ddb-40d2c5631d0c", | |
"url":"http://random.cat/i/065_-_AhrGPRl.gif" | |
}, | |
{ | |
"id":"ccaa6a40-d3a5-4761-8f85-ca9e5ad8623a", | |
"url":"http://random.cat/i/dDVns.gif" | |
}, | |
{ |
JavaRDD<String> textFile = sc.textFile("hdfs://..."); | |
JavaPairRDD<String, Integer> counts = textFile | |
.flatMap(line -> Arrays.asList(line.split(" "))) | |
.mapToPair(w -> new Tuple2<>(w, 1)) | |
.reduceByKey((x, y) -> x + y); | |
counts.saveAsTextFile("hdfs://..."); |
#define GRID "\t\t+-------+-------+-------+\n" \ | |
"\t\t| | | |\n" \ | |
"\t\t| %s | %s | %s |\n" \ | |
"\t\t| 1| 2| 3|\n" \ | |
"\t\t+-------+-------+-------+\n" \ | |
"\t\t| | | |\n" \ | |
"\t\t| %s | %s | %s |\n" \ | |
"\t\t| 4| 5| 6|\n" \ | |
"\t\t+-------+-------+-------+\n" \ | |
"\t\t| | | |\n" \ |
#ifndef TICTACTOE_GRID_H | |
#define TICTACTOE_GRID_H | |
#define COLOR1 "\x1B[32m" | |
#define COLOR2 "\x1B[35m" | |
#define NORMAL "\x1B[0m" | |
#define GRID "\t\t+-------+-------+-------+\n" \ | |
"\t\t| | | |\n" \ | |
"\t\t| %s | %s | %s |\n" \ |
(defn runp! | |
"Runs the function `f` in parallel on the given collection `coll`. | |
It will use (by default) the same numbers of threads as there are cores available on the system. | |
You can set a specific number of threads using `:threads` waits maximum `:timeout` milliseconds." | |
([f coll {:keys [threads timeout] :or {threads (.availableProcessors (Runtime/getRuntime))}}] | |
(let [pool (java.util.concurrent.Executors/newFixedThreadPool threads) | |
tasks (map (fn [e] (fn [] (f e))) coll)] | |
(try | |
(doseq [future (.invokeAll pool tasks)] | |
(.get future)) |
(defn monoid [id f] | |
(fn | |
([] id) | |
([a] (f id a)) | |
([a b] (f a b)) | |
([a b & more] (reduce f (f a b) more)))) |