Skip to content
Browse files

transact action log in parallel

  • Loading branch information...
1 parent bfbc6b6 commit 09f94e1608be36b885b57af3ba83c839be9333f0 Stuart Halloway committed Feb 11, 2013
Showing with 15 additions and 1 deletion.
  1. +5 −1 src/simulant/sim.clj
  2. +10 −0 src/simulant/util.clj
View
6 src/simulant/sim.clj
@@ -70,6 +70,10 @@ key specified by :service/key."
"Teardown service at the end of a sim run."
(fn [conn process service services-map] (getx service :service/type)))
+;; do-nothing default
+(defmethod finalize-service :default
+ [conn process service services-map])
+
(defn- start-services
[conn process]
(reduce
@@ -131,7 +135,7 @@ process."
(.close ^Closeable writer)
(with-open [reader (io/reader temp-file)
pbr (PushbackReader. reader)]
- (transact-batch conn (form-seq pbr)))))
+ (transact-pbatch conn (form-seq pbr) 1000))))
(defn create-action-log
"Create an action log service for the sim."
View
10 src/simulant/util.clj
@@ -108,6 +108,16 @@
@(d/transact-async conn (mapcat identity batch))
:ok)))
+(defn transact-pbatch
+ "Submit txes in batches of size batch-size, default is 100"
+ ([conn txes] (transact-pbatch conn txes 100))
+ ([conn txes batch-size]
+ (->> (partition-all batch-size txes)
+ (pmap #(d/transact-async conn (mapcat identity %)))
+ (map deref)
+ dorun)
+ :ok))
+
(defn tx-ent
"Resolve entity id to entity as of the :db-after value of a tx result"
[txresult eid]

0 comments on commit 09f94e1

Please sign in to comment.
Something went wrong with that request. Please try again.