Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0bcb9a4

Browse files
author
Kapil Reddy
committed
Add flow to icw.core
- Add small fixes
1 parent 54349c5 commit 0bcb9a4

File tree

6 files changed

+58
-10
lines changed

6 files changed

+58
-10
lines changed

‎src/icw/core.clj

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
(:require [icw.system :as system]
33
[icw.data.process]
44
[icw.data.process-faster]
5+
[icw.java-interop.intro]
6+
[icw.search.reader]
7+
[icw.async.intro]
8+
[ics.async.rlsc]
59
[icw.web.core :as web])
610
(:gen-class))
711

@@ -26,10 +30,47 @@ web/app
2630

2731
icw.data.process/populate-db
2832

33+
;; git checkout solutions src/
34+
2935
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3036
;; Chapter 2 - Concurrency
3137
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3238

3339
;; Can we make make populate-db faster?
3440

3541
'icw.data.process-faster
42+
43+
44+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45+
;; Chapter 3 - Java interop
46+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47+
48+
'icw.java-interop.intro
49+
50+
51+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52+
;; Chapter 4 - Java interop (search)
53+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54+
55+
;; Go to
56+
;; http://localhost:6789/search/beatles
57+
58+
;; Let's go back to the routes
59+
web/app
60+
61+
;; We need fix search
62+
icw.search.reader/search
63+
64+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65+
;; Chapter 5 - core.async introduction
66+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67+
68+
;; Let's write some core.async
69+
70+
'icw.async.intro
71+
72+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73+
;; Chapter 6 - core.async exercise
74+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75+
76+
'icw.async.rlsc

‎src/icw/data/gen.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"\"")]))
3333
(gen/sample-seq album-gen)
3434
(mapcat (fn [year]
35-
(repeat (rand-nth (range 10 40))
35+
(repeat (rand-nth (range 10 15))
3636
year))
3737
(drop 2040 (range)))
3838
(drop 501 (range))))

‎src/icw/data/process.clj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
;; Reading and processing data from resources/data/albumlist.csv
99

10-
(def album-lines (drop 1
11-
(line-seq (clojure.java.io/reader
12-
"resources/data/albumlist.csv"))))
10+
(defonce album-lines (drop 1
11+
(line-seq (clojure.java.io/reader
12+
"resources/data/albumlist.csv"))))
1313

1414
(comment
1515
(first album-lines))
@@ -42,7 +42,7 @@
4242
"Psychedelic Rock"]]))
4343

4444
(comment
45-
(map parse-line album-lines))
45+
(take2 (map parse-line album-lines)))
4646

4747

4848
(defn line-vec->line-map
@@ -98,7 +98,9 @@
9898
(jdbc/init-db)
9999
(let [albums (line-xs->album-xs album-lines)]
100100
(doseq [album albums]
101-
(jdbc/insert! album))))
101+
(jdbc/insert! (update-in album
102+
[:subgenre]
103+
#(cs/join "," %))))))
102104

103105
;; Check http://localhost:6789/albums
104106

@@ -128,6 +130,9 @@
128130
#_FIXME))))
129131

130132
(comment (= (take 5 (line-xs->albums-xs-before album-lines 1987))
133+
(comment (= (take 5 (map (juxt :year :album)
134+
(line-xs->albums-xs-before 1987
135+
album-lines)))
131136
'([1967 "Sgt. Pepper's Lonely Hearts Club Band"]
132137
[1966 "Pet Sounds"]
133138
[1966 "Revolver"]

‎src/icw/data/process_faster.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ x
358358
albums (idp/line-xs->album-xs idp/album-lines)]
359359
(doseq [album albums]
360360
;; Running it in another thread will help
361-
(jdbc/insert! album)))))
361+
(jdbc/insert! (update-in album
362+
[:subgenre]
363+
#(cs/join "," %)))))))
362364

363365

364366
(time (populate-db))

‎src/icw/java_interop/intro.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@
8787
;; Objects:1 ends here
8888

8989
;; [[file:~/github/intermediate-clojure-workshop/content/java-interop/intro.org::*Objects][Objects:2]]
90-
(clojure.pprint/pprint (do (datafy sample-point)))
90+
(comment (clojure.pprint/pprint (do (datafy sample-point))))
9191
;; Objects:2 ends here
9292

9393
;; [[file:~/github/intermediate-clojure-workshop/content/java-interop/intro.org::*Objects][Objects:3]]
94-
(clojure.pprint/pprint (do (bean sample-point)))
94+
(comment (clojure.pprint/pprint (do (bean sample-point))))
9595
;; Objects:3 ends here
9696

9797
;; [[file:~/github/intermediate-clojure-workshop/content/java-interop/intro.org::*Objects][Objects:4]]

‎src/icw/java_interop/jdbc.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
(defn insert!
4747
[row]
48-
(Thread/sleep (rand-int 100))
48+
(Thread/sleep (rand-int 20))
4949
(jdbc/insert! hsqldb
5050
:albums
5151
row))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /