Skip to content

Commit 8617e34

Browse files
committed
Use lazy sequence for CSV import
Signed-off-by: Greg Haskins <greg@manetu.com>
1 parent de6d941 commit 8617e34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/manetu/sparql_loadtest/binding_loader.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
(defn record-seq
1919
[rdr nr]
20-
(->> rdr parse-csv cycle (take nr) doall))
20+
(->> rdr parse-csv cycle (take nr)))
2121

2222
(defn csv->bindings
2323
"Given 'path' to a .csv file, return 'nr' records, possibly repeating if nr exceeds the record count in the file"
@@ -26,8 +26,9 @@
2626
(let [ch (async/chan)]
2727
(async/thread
2828
(with-open [rdr (io/reader path)]
29-
(let [coll (record-seq rdr nr)]
30-
(async/onto-chan!! ch coll))))
29+
(doseq [record (record-seq rdr nr)]
30+
(async/>!! ch record))
31+
(async/close! ch)))
3132
ch))
3233

3334
(defn null-bindings

0 commit comments

Comments
 (0)