File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 316316 (cmp-val (.-v d1) (.-v d2))
317317 (cmp-num (.-tx d1) (.-tx d2))))
318318
319+ (extend-protocol hc/IKeyCompare
320+ clojure.lang.PersistentVector
321+ (compare [key1 key2]
322+ (if-not (= (class key2) clojure.lang.PersistentVector)
323+ -1 ; ; HACK
324+ (let [[a b c d] key1
325+ [e f g h] key2]
326+ (combine-cmp
327+ (hc/compare a e)
328+ (hc/compare b f)
329+ (hc/compare c g)
330+ (hc/compare d h)))))
331+ java.lang.String
332+ (compare [key1 key2]
333+ (compare key1 key2))
334+ clojure.lang.Keyword
335+ (compare [key1 key2]
336+ (compare key1 key2))
337+ nil
338+ (compare [key1 key2]
339+ (if (nil? key2)
340+ 0 -1 )))
341+
342+
343+
344+
319345(defrecord EAVTKey [datom]
320346 hc /IKeyCompare
321347 (compare [this other]
Original file line number Diff line number Diff line change 1313
1414
1515(def db (d/db-with
16- (d/empty-db {:name {:db/index true }})
16+ (d/empty-db #_ {:name {:db/index true }})
1717 [{ :db/id 1 , :name " Ivan" , :age 15 }
1818 { :db/id 2 , :name " Petr" , :age 37 }
1919 { :db/id 3 , :name " Ivan" , :age 37 }
6363 (time
6464 (d/db-with
6565 db
66- (for [i (shuffle ( range 5 10000 ) )]
66+ (for [i (range 5 100000 )]
6767 {:db/id i :name (str " Bot" i) :age i}))))
6868
6969 ; ; TODO why is logarithmic query scaling so bad?
7474 (time
7575 (doseq [i (range 100 )]
7676 (d/q '[:find ?e
77- :where [?e :name " Bot42" ]] new-db)))
77+ :where [?e :name " Bot4200" ]] new-db)))
78+
7879
7980 (time (d/q '[:find ?e
80- :where [?e :name " Ivan" ]] db))
81+ :where [?e :name " Ivan" ]] new- db))
8182
8283 )
8384
You can’t perform that action at this time.
0 commit comments