Skip to content

Commit

Permalink
Merge branch 'development' into benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmassa authored Nov 2, 2021
2 parents 87dff2a + 2e82719 commit 9fe7139
Show file tree
Hide file tree
Showing 12 changed files with 501 additions and 453 deletions.
33 changes: 14 additions & 19 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -197,29 +197,24 @@ the code.
(ns test-db
(:require [konserve.filestore :refer [new-fs-store]]
[konserve.core :as k]
[clojure.core.async :as async :refer [go <!]]))
[clojure.core.async :refer [<!]]))

(go
(def store (<! (new-fs-store "/tmp/store")))
(def store (<! (new-fs-store "/tmp/store")))

(<! (k/assoc-in store ["foo" :bar] {:foo "baz"}))
(<! (k/get-in store ["foo"]))
(<! (k/exists? store "foo"))
(<! (k/assoc-in store ["foo" :bar] {:foo "baz"}))
(<! (k/get-in store ["foo"]))
(<! (k/exists? store "foo"))

(<! (k/assoc-in store [:bar] 42))
(<! (k/update-in store [:bar] inc))
(<! (k/get-in store [:bar]))
(<! (k/dissoc store :bar))
(<! (k/assoc-in store [:bar] 42))
(<! (k/update-in store [:bar] inc))
(<! (k/get-in store [:bar]))
(<! (k/dissoc store :bar))

(<! (k/append store :error-log {:type :horrible}))
(<! (k/log store :error-log))
(<! (k/append store :error-log {:type :horrible}))
(<! (k/log store :error-log))

(let [ba (byte-array (* 10 1024 1024) (byte 42))]
(time (<! (k/bassoc store "banana" ba))))

(<! (k/bget store "banana"
(fn [{is :input-stream}]
(go (your-read-does-all-work-here is))))))
(let [ba (byte-array (* 10 1024 1024) (byte 42))]
(time (<! (k/bassoc store "banana" ba))))
#+END_SRC

And the following synchronous code if you are not using core.async in your scope:
Expand All @@ -228,7 +223,7 @@ And the following synchronous code if you are not using core.async in your scope
(:require [konserve.filestore :refer [new-fs-store]]
[konserve.core :as k]))

(def store (new-fs-store "/tmp/store" {:sync? true}))
(def store (new-fs-store "/tmp/store" :opts {:sync? true}))

(k/assoc-in store ["foo" :bar] {:foo "baz"} {:sync? true})
(k/get-in store ["foo"] nil {:sync? true})
Expand Down
10 changes: 5 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.773"}
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.10.866"}
org.clojure/data.fressian {:mvn/version "1.0.0"} ;; for filestore
fress/fress {:mvn/version "0.3.1"}
io.replikativ/incognito {:mvn/version "0.2.5"}
Expand All @@ -10,9 +10,9 @@
;; reactivate for nodejs support
;com.google.javascript/closure-compiler-unshaded {:mvn/version "v20190325"}
;org.clojure/google-closure-library {:mvn/version "0.0-20190213-2033d5d9"}
org.lz4/lz4-java {:mvn/version "1.6.0"}
com.taoensso/timbre {:mvn/version "4.10.0"}}
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.10.21"}
org.lz4/lz4-java {:mvn/version "1.8.0"}
com.taoensso/timbre {:mvn/version "5.1.2"}}
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.15.12"}
binaryage/devtools {:mvn/version "1.0.2"}}
:extra-paths ["test"]}
:dev {:extra-deps {criterium/criterium {:mvn/version "0.4.4"}
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>1.6.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.1</version>
<version>1.10.3</version>
</dependency>
<dependency>
<groupId>io.replikativ</groupId>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojurescript</artifactId>
<version>1.10.773</version>
<version>1.10.866</version>
</dependency>
<dependency>
<groupId>fress</groupId>
Expand All @@ -51,7 +51,7 @@
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>timbre</artifactId>
<version>4.10.0</version>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>io.replikativ</groupId>
Expand Down
10 changes: 5 additions & 5 deletions src/konserve/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
(:require [konserve.protocols :refer [-exists? -get-meta -get-in -assoc-in
-update-in -dissoc -bget -bassoc
-keys]]
[hasch.core :refer [uuid]]
[taoensso.timbre :as timbre :refer [trace debug]]
[hasch.core :as hasch]
[taoensso.timbre :refer [trace debug]]
[konserve.utils :refer [meta-update #?(:clj async+sync) *default-sync-translation*]]
[superv.async :refer [go-try- <?-]]
[clojure.core.async :refer [chan put! poll!]])
Expand All @@ -21,7 +21,7 @@
;; durable


(defn get-lock [{:keys [locks] :as store} key]
(defn get-lock [{:keys [locks] :as _store} key]
(or (clojure.core/get @locks key)
(let [c (chan)]
(put! c :unlocked)
Expand Down Expand Up @@ -185,7 +185,7 @@
[append-log? last-id first-id] head
new-elem {:next nil
:elem elem}
id (uuid)]
id (hasch/uuid)]
(when (and head (not= append-log? :append-log))
(throw (ex-info "This is not an append-log." {:key key})))
(<?- (-update-in store [id] (partial meta-update key :append-log) (fn [_] new-elem) opts))
Expand All @@ -204,7 +204,7 @@
*default-sync-translation*
(go-try-
(let [head (<?- (get store key nil opts))
[append-log? last-id first-id] head]
[append-log? _last-id first-id] head]
(when (and head (not= append-log? :append-log))
(throw (ex-info "This is not an append-log." {:key key})))
(when first-id
Expand Down
Loading

0 comments on commit 9fe7139

Please sign in to comment.