Skip to content

Commit

Permalink
always close tc
Browse files Browse the repository at this point in the history
  • Loading branch information
alexy committed Jun 24, 2010
1 parent 27ab4b1 commit 1f00639
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
proto/*.class
proto/*.java
30 changes: 17 additions & 13 deletions src/tokyo-graph.clj
Expand Up @@ -128,17 +128,21 @@
in-init-params {:path in-db-pathname :read-only true}
out-init-params {:path out-db-pathname :create true}
in-db (tc/db-init in-init-params)
out-db (tc/db-init out-init-params)
; need open to define :db
_ (do (tc/db-open in-db) (tc/db-open out-db))
in-tc (:db in-db)
out-tc (:db out-db)]
out-db (tc/db-init out-init-params)]

(try
(tc/db-open in-db)
(tc/db-open out-db)
(let [in-tc (:db in-db)
out-tc (:db out-db)]

(when (.iterinit in-tc)
(loop [k (.iternext2 in-tc) i 0]
(when-not (or (empty? k) (>= i n))
(when (and progress (zero? (mod i progress))) (err "."))
(tc/db-add out-db k (tc/db-get in-db k))
(recur (.iternext2 in-tc) (inc i)))))
(tc/db-close in-db)
(tc/db-close out-db)))
(when (.iterinit in-tc)
(loop [k (.iternext2 in-tc) i 0]
(when-not (or (empty? k) (>= i n))
(when (and progress (zero? (mod i progress))) (err "."))
(tc/db-add out-db k (tc/db-get in-db k))
(recur (.iternext2 in-tc) (inc i))))))

(finally
(tc/db-close in-db)
(tc/db-close out-db)))))

0 comments on commit 1f00639

Please sign in to comment.