Skip to content

Commit

Permalink
prepare to release
Browse files Browse the repository at this point in the history
  • Loading branch information
huahaiy committed Feb 23, 2024
1 parent 8fc3d32 commit b259401
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
63 changes: 32 additions & 31 deletions src/datalevin/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -332,37 +332,38 @@ Only usable for debug output.
(let [db# ^DB (deref ~orig-conn)
s# (.-store db#)
old# (datalog-index-cache-limit db#)]
(datalog-index-cache-limit db# 0)
(if (instance? DatalogStore s#)
(let [res# (if (l/writing? s#)
(let [~conn ~orig-conn]
~@body)
(let [s1# (r/open-transact s#)
w# #(let [~conn (atom (db/new-db s1#)
:meta (meta ~orig-conn))]
~@body) ]
(try
(u/repeat-try-catch
~c/+in-tx-overflow-times+
l/resized? (w#))
(finally (r/close-transact s#)))))
new-db# (db/new-db s#)]
(reset! ~orig-conn new-db#)
(datalog-index-cache-limit new-db# old#)
res#)
(let [kv# (.-lmdb ^Store s#)
s1# (volatile! nil)
res1# (l/with-transaction-kv [kv1# kv#]
(let [conn1# (atom (db/new-db (s/transfer s# kv1#))
:meta (meta ~orig-conn))
res# (let [~conn conn1#]
~@body)]
(vreset! s1# (.-store ^DB (deref conn1#)))
res#))
new-db# (db/new-db (s/transfer (deref s1#) kv#))]
(reset! ~orig-conn new-db#)
(datalog-index-cache-limit new-db# old#)
res1#)))))
(locking (l/write-txn s#)
(datalog-index-cache-limit db# 0)
(if (instance? DatalogStore s#)
(let [res# (if (l/writing? s#)
(let [~conn ~orig-conn]
~@body)
(let [s1# (r/open-transact s#)
w# #(let [~conn (atom (db/new-db s1#)
:meta (meta ~orig-conn))]
~@body) ]
(try
(u/repeat-try-catch
~c/+in-tx-overflow-times+
l/resized? (w#))
(finally (r/close-transact s#)))))
new-db# (db/new-db s#)]
(reset! ~orig-conn new-db#)
(datalog-index-cache-limit new-db# old#)
res#)
(let [kv# (.-lmdb ^Store s#)
s1# (volatile! nil)
res1# (l/with-transaction-kv [kv1# kv#]
(let [conn1# (atom (db/new-db (s/transfer s# kv1#))
:meta (meta ~orig-conn))
res# (let [~conn conn1#]
~@body)]
(vreset! s1# (.-store ^DB (deref conn1#)))
res#))
new-db# (db/new-db (s/transfer (deref s1#) kv#))]
(reset! ~orig-conn new-db#)
(datalog-index-cache-limit new-db# old#)
res1#))))))

(def ^{:arglists '([conn])
:doc "Rollback writes of the transaction from inside [[with-transaction]]."}
Expand Down
2 changes: 1 addition & 1 deletion test/datalevin/test/transact.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
(future
(dotimes [j 100]
(d/transact! conn [{:i+j (+ i j) :i i :j j}])
(is (= (+ i j) (d/q q+ (d/db conn) i j)))
(d/with-transaction [cn conn]
(is (= (+ i j) (d/q q+ (d/db cn) i j)))
(swap! trials u/long-inc)
(d/transact! cn [{:i*j (* i j) :i i :j j}])
(is (= (* i j) (d/q q* (d/db cn) i j)))))))
Expand Down

0 comments on commit b259401

Please sign in to comment.