Skip to content

Commit

Permalink
Fix cljs compilation.
Browse files Browse the repository at this point in the history
Remove untested outboard API. Most functions should probably be rebuilt on the konserve backend anyway.
  • Loading branch information
whilo committed May 24, 2020
1 parent 0658e68 commit c582e65
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 314 deletions.
22 changes: 11 additions & 11 deletions src/hitchhiker/tree.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,17 @@
"Takes the result of a search and puts the iterated elements onto iter-ch
going forward over the tree as needed. Does lg(n) backtracking sometimes."
[iter-ch path start-key]
(ha/go-try
(loop [path path]
(if path
(let [start-node (peek path)
elements (subseq (:children start-node)
>=
start-key)]
(ha/<? (async/onto-chan iter-ch
elements false))
(recur (ha/<? (right-successor (pop path)))))
(async/close! iter-ch)))))
(ha/go-try
(loop [path path]
(if path
(let [start-node (peek path)
elements (subseq (:children start-node)
>=
start-key)]
(ha/<? (async/onto-chan iter-ch
elements false))
(recur (ha/<? (right-successor (pop path)))))
(async/close! iter-ch)))))

#?(:clj
(defn lookup-fwd-iter
Expand Down
239 changes: 0 additions & 239 deletions src/hitchhiker/tree/bootstrap/outboard.clj

This file was deleted.

103 changes: 39 additions & 64 deletions test/hitchhiker/konserve_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,14 @@
(ha/go-try
(let [iter-ch (async/chan)
path (ha/<? (core/lookup-path tree key))]
(when path
(msg/forward-iterator iter-ch path key))
(ha/<? (async/into [] iter-ch)))))
(ha/if-async?
(do
(when path
(msg/forward-iterator iter-ch path key))
(ha/<? (async/into [] iter-ch)))
(msg/forward-iterator path key)))))


(let [folder "/tmp/async-hitchhiker-tree-test"
_ (delete-store folder)
store (kons/add-hitchhiker-tree-handlers
(kc/ensure-cache (async/<!! (new-fs-store folder :config {:fsync false}))))
backend (kons/->KonserveBackend store)
config (core/->Config 1 3 (- 3 1))
flushed (ha/<?? (core/flush-tree
(time (reduce (fn [t i]
(ha/<?? (msg/insert t i i)))
(ha/<?? (core/b-tree config))
(range 1 11)))
backend))
root-key (kons/get-root-key (:tree flushed))
tree (ha/<?? (kons/create-tree-from-root-key store root-key))]
(is (= (ha/<?? (msg/lookup tree -10)) nil))
(is (= (ha/<?? (msg/lookup tree 100)) nil))
(dotimes [i 10]
(is (= (ha/<?? (msg/lookup tree (inc i))) (inc i))))
(is (= (map first (msg/lookup-fwd-iter tree 4)) (range 4 11)))
(is (= (map first (msg/lookup-fwd-iter tree 0)) (range 1 11)))
(let [deleted (ha/<?? (core/flush-tree (ha/<?? (msg/delete tree 3)) backend))
root-key (kons/get-root-key (:tree deleted))
tree (ha/<?? (kons/create-tree-from-root-key store root-key))]
(is (= (ha/<?? (msg/lookup tree 2)) 2))
(is (= (ha/<?? (msg/lookup tree 3)) nil))
(is (= (ha/<?? (msg/lookup tree 4)) 4)))
(delete-store folder))

(deftest simple-konserve-test
(testing "Insert and lookup"
#?(:cljs
Expand Down Expand Up @@ -159,31 +134,31 @@
(assert res (str "These are unequal: " (pr-str b-tree-order) " " (pr-str (seq (sort set)))))
res))))

;; ;; TODO recheck when https://dev.clojure.org/jira/browse/TCHECK-128 is fixed
;; ;; and share clj mixed-op-seq test, remove ops.cljc then.
;; #?(:cljs
;; (deftest manual-mixed-op-seq
;; (async done
;; (ha/go-try
;; (loop [[ops & r] recorded-ops]
;; (when ops
;; (is (ha/<? (ops-test ops 1000)))
;; (recur r)))
;; (done)))))


;; #?(:clj
;; (defn mixed-op-seq
;; "This is like the basic mixed-op-seq tests, but it also mixes in flushes to a konserve filestore"
;; [add-freq del-freq flush-freq universe-size num-ops]
;; (prop/for-all [ops (gen/vector (gen/frequency
;; [[add-freq (gen/tuple (gen/return :add)
;; (gen/no-shrink gen/int))]
;; [flush-freq (gen/return [:flush])]
;; [del-freq (gen/tuple (gen/return :del)
;; (gen/no-shrink gen/int))]])
;; num-ops)]
;; (ha/<?? (ops-test ops universe-size)))))
;; TODO recheck when https://dev.clojure.org/jira/browse/TCHECK-128 is fixed
;; and share clj mixed-op-seq test, remove ops.cljc then.
#?(:cljs
(deftest manual-mixed-op-seq
(async done
(ha/go-try
(loop [[ops & r] recorded-ops]
(when ops
(is (ha/<? (ops-test ops 1000)))
(recur r)))
(done)))))


#?(:clj
(defn mixed-op-seq
"This is like the basic mixed-op-seq tests, but it also mixes in flushes to a konserve filestore"
[add-freq del-freq flush-freq universe-size num-ops]
(prop/for-all [ops (gen/vector (gen/frequency
[[add-freq (gen/tuple (gen/return :add)
(gen/no-shrink gen/int))]
[flush-freq (gen/return [:flush])]
[del-freq (gen/tuple (gen/return :del)
(gen/no-shrink gen/int))]])
num-ops)]
(ha/<?? (ops-test ops universe-size)))))


;; #?(:clj
Expand All @@ -192,11 +167,11 @@
;; (mixed-op-seq 800 200 10 1000 1000)))


;; #?(:cljs
;; (defn ^:export test-all [cb]
;; (defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
;; (cb (clj->js m))
;; (if (cljs.test/successful? m)
;; (println "Success!")
;; (println "FAIL")))
;; (run-tests)))
#?(:cljs
(defn ^:export test-all [cb]
(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
(cb (clj->js m))
(if (cljs.test/successful? m)
(println "Success!")
(println "FAIL")))
(run-tests)))

0 comments on commit c582e65

Please sign in to comment.