File tree Expand file tree Collapse file tree 6 files changed +17
-17
lines changed
Expand file tree Collapse file tree 6 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 99 [hitchhiker.tree.messaging :as msg]))
1010
1111; ;; Description of refcounting system in redis
12- ; ;;
12+ ; ;;
1313; ;; The refcounting system allows any key in redis to be managed
1414; ;; by refcounting. This refcounter doesn't do cycle protection, but
1515; ;; weakrefs would be very simple to add.
276276 e [" " " :rc" " :rs" " :rl" ]]
277277 (println (str k e) " =" (wcar {} ((if (= e " :rl" )
278278 #(car/lrange % 0 -1 )
279- car/get) (str k e)))))
279+ car/get) (str k e)))))
280280 (wcar {} (drop-ref " foo" ))
281281
282282 (wcar {} (create-refcounted " foo" 22 ))
283283
284284 (wcar {} (car/flushall ))
285- (count (wcar {} (car/keys " *" )))
285+ (count (wcar {} (car/keys " *" )))
286286 (count (msg/lookup-fwd-iter (create-tree-from-root-key @(:storage-addr (:tree my-tree))) -1 ))
287287 (count (msg/lookup-fwd-iter (create-tree-from-root-key @(:storage-addr (:tree my-tree-updated))) -1 ))
288288 (def my-tree (core/flush-tree
289289 (time (reduce msg/insert
290290 (core/b-tree (core/->Config 17 300 (- 300 17 )))
291- (range 50000 )))
291+ (range 50000 )))
292292 (->RedisBackend )
293293 ))
294294 (def my-tree-updated (core/flush-tree
Original file line number Diff line number Diff line change 2929 (underflow? [node] " Returns true if this node has too few elements" )
3030 (merge-node [node other] " Combines this node with the other to form a bigger node. We assume they're siblings" )
3131 (split-node [node] " Returns a Split object with the 2 nodes that we turned this into" )
32- (lookup [node key] " Returns the child node which contains the given key" ))
32+ (lookup [node key] " Returns the child node which contains the given key" ))
3333
3434(defrecord Split [left right median])
3535
357357 child (if (data-node? cur)
358358 nil #_(nth-of-set (:children cur) index)
359359 (-> (:children cur)
360- ; ;TODO what are the semantics for exceeding on the right? currently it's trunc to the last element
360+ ; ;TODO what are the semantics for exceeding on the right? currently it's trunc to the last element
361361 (nth index (peek (:children cur)))
362362 (resolve )))
363363 path' (conj path index child)]
Original file line number Diff line number Diff line change 11(ns hitchhiker.tree.messaging
22 (:refer-clojure :exclude [subvec])
33 (:require [hitchhiker.tree.core :as core]
4- [clojure.pprint :as pp]
4+ [clojure.pprint :as pp]
55 [clojure.core.rrb-vector :refer (catvec subvec)])
66 (:import java.io.Writer
7- java.util.Collections))
7+ java.util.Collections))
88
99; ; An operation is an object with a few functions
1010; ; 1. It has a function that it applies to the tree to apply its effect
8989 ; )
9090 (loop [[child & children] (:children tree)
9191 rebuilt-children []
92- msgs (vec (sort-by affects-key ; must be a stable sort
92+ msgs (vec (sort-by affects-key ; must be a stable sort
9393 (concat (:op-buf tree) msgs)))]
9494 (let [took-msgs (into []
9595 (take-while #(>= 0 (core/compare
177177 (drop-while #(>= 0 (core/compare (affects-key %)
178178 left-sibs-min-last)))
179179 identity)
180- data-node (peek path)
180+ data-node (peek path)
181181 my-last (core/last-key data-node)
182182 right-side-filter (if is-last?
183183 identity
Original file line number Diff line number Diff line change 9999 (println (->> (read-string (slurp " broken-data.edn" ))
100100 (map (fn [[op x]] [op (mod x 100000 )]))
101101 (take-last 125 )
102- first))
102+ first))
103103 (println (lookup-fwd-iter b-tree -1 ))
104104 (println (sort s))
105105 ))
Original file line number Diff line number Diff line change 11(ns hitchhiker.tree.core-test
2- (:refer-clojure :exclude [compare resolve])
2+ (:refer-clojure :exclude [compare resolve])
33 (:require [clojure.test :refer :all ]
44 [hitchhiker.tree.core :refer :all ]
55 [clojure.test.check :as tc]
4747 (let [sorted-set-order (into (sorted-set ) v)
4848 b-tree (reduce insert-helper (b-tree (->Config 3 3 2 )) v)
4949 b-tree-order (lookup-fwd-iter b-tree Integer/MIN_VALUE)]
50- (= (seq sorted-set-order) (seq (map first b-tree-order))))))
50+ (= (seq sorted-set-order) (seq (map first b-tree-order))))))
5151
5252(defspec test-delete2
5353 1000
Original file line number Diff line number Diff line change 3030 (let [sorted-set-order (into (sorted-set ) v)
3131 b-tree (reduce insert (core/b-tree (core/->Config 3 3 2 )) v)
3232 b-tree-order (lookup-fwd-iter b-tree Integer/MIN_VALUE)]
33- (= (seq sorted-set-order) b-tree-order))))
33+ (= (seq sorted-set-order) b-tree-order))))
3434
3535(defspec test-delete2
3636 1000
8686 :del (msg/delete %2 (second %1 )))
8787 ]
8888 ; (println ops)
89- (println killer-op)
89+ (println killer-op)
9090 (clojure.pprint/pprint b-tree)
9191 (println (lookup-fwd-iter b-tree -1 ))
9292 (println (sort s))
9696 (println (lookup-fwd-iter (f killer-op b-tree) -1 ))
9797 (println (sort (disj s (second killer-op))))
9898 (when killer-op-dos
99- (println killer-op-dos)
99+ (println killer-op-dos)
100100 (clojure.pprint/pprint (f killer-op-dos (f killer-op b-tree)))))
101101 )
102-
102+
103103 (clojure.pprint/pprint cool-test-tree)
104104 (clojure.pprint/pprint (insert cool-test-tree 20 ))
105105 (clojure.pprint/pprint (msg/delete cool-test-tree 32 ))
You can’t perform that action at this time.
0 commit comments