Created
April 14, 2014 15:14
-
-
Save mishok13/10657143 to your computer and use it in GitHub Desktop.
Simple C3P0 passing to mapfn fails.
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 weird.core | |
(:require | |
[cascalog.api :refer [hfs-textline ?- stdout <- defmapfn]] | |
[cascalog.cascading.conf :refer [with-serializations *JOB-CONF*]] | |
[honeysql.helpers :as sql] | |
[honeysql.core :as sql.eng]) | |
(:import | |
[com.esotericsoftware.kryo Kryo] | |
[com.esotericsoftware.kryo.serializers.JavaSerializer] | |
[com.mchange.v2.c3p0 ComboPooledDataSource]) | |
(:gen-class)) | |
(defn- jdbc-pool | |
[host port database user password] | |
(let [jdbc-url (format "jdbc:postgresql://%s:%s/%s" host port database)] | |
{:datasource (doto (ComboPooledDataSource.) | |
(.setDriverClass "org.postgresql.Driver") | |
(.setJdbcUrl jdbc-url) | |
(.setUser user) | |
(.setPassword password))})) | |
(defmapfn get-baz | |
[db foo bar] | |
:stub) | |
(defn parse-line | |
[line] | |
(clojure.string/split line #"\s+")) | |
(defn -main | |
"I don't do a whole lot ... yet." | |
[path & args] | |
(let [input (hfs-textline path) | |
db (jdbc-pool "localhost" 5432 "pipeline" "pipeline" "pipeline")] | |
(with-serializations ["org.apache.hadoop.io.serializer.WritableSerialization" | |
"cascading.tuple.hadoop.BytesSerialization" | |
"cascading.tuple.hadoop.TupleSerialization" | |
"com.esotericsoftware.kryo.serializers.JavaSerializer" | |
"com.twitter.chill.hadoop.KryoSerialization"] | |
(?- (stdout) | |
(<- [?foo ?bar ?baz] | |
(input ?line) | |
(parse-line ?line :> ?foo ?bar) | |
(get-baz db ?foo ?bar :> ?baz)))))) |
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
(defproject weird "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:profiles {:dev {:dependencies [[org.apache.hadoop/hadoop-core "1.2.1"]]}} | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[cascalog "2.1.0"] | |
[honeysql "0.4.3"] | |
[postgresql "9.1-901-1.jdbc4"] | |
[org.clojure/java.jdbc "0.3.3"] | |
[org.apache.hadoop/hadoop-core "1.2.1"] | |
[c3p0/c3p0 "0.9.1.2"]] | |
:main ^:skip-aot weird.core | |
:target-path "target/%s" | |
:profiles {:uberjar {:aot :all}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment