Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
huahaiy committed Jul 28, 2020
1 parent 7e54ac9 commit 29288f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
26 changes: 9 additions & 17 deletions src/datalevin/query.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,15 @@
:clj ^{:tag "[[Ljava.lang.Object;"} idxs1)
t2 #?(:cljs idxs2
:clj ^{:tag "[[Ljava.lang.Object;"} idxs2)]
(let [l1 (da/alength idxs1)
l2 (da/alength idxs2)
t1-array? (da/array? t1)
t2-array? (da/array? t2)
t1-acopy? (and t1-array? (= l1 (da/alength t1)))
t2-acopy? (and t2-array? (= l2 (da/alength t2)))
g1 (if t1-array? typed-aget get)
g2 (if t2-array? typed-aget get)
res (da/make-array (+ l1 l2))]
(if t1-acopy?
(da/acopy t1 0 l1 res 0)
(dotimes [i l1]
(da/aset res i (g1 t1 (da/aget idxs1 i)))))
(if t2-acopy?
(da/acopy t2 0 l2 res l1)
(dotimes [i l2]
(da/aset res (+ l1 i) (g2 t2 (da/aget idxs2 i)))))
(let [l1 (alength idxs1)
l2 (alength idxs2)
tg1 (if (da/array? t1) typed-aget get)
tg2 (if (da/array? t2) typed-aget get)
res (da/make-array (+ l1 l2))]
(dotimes [i l1]
(aset res i (tg1 t1 (aget idxs1 i))))
(dotimes [i l2]
(aset res (+ l1 i) (tg2 t2 (aget idxs2 i))))
res))

(defn sum-rel [a b]
Expand Down
27 changes: 13 additions & 14 deletions test/datalevin/test/query.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

;; #8
(deftest test-many-joins
(let [data (->> (range 10)
(let [data (->> (range 1000)
(map (fn [^long i]
{:db/id (inc i)
:a (str (UUID/randomUUID))
Expand All @@ -31,19 +31,18 @@
:g {:db/valueType :db.type/long}
:h {:db/valueType :db.type/long}})
(d/db-with data))]
(d/q '[:find ?eid1 .
:where
[?eid1 :a ?a1]
[?eid1 :b ?b1]
[?eid1 :c ?c1]
[?eid1 :d ?d1]
[?eid1 :e ?e1]
[?eid1 :f ?f1]
[?eid1 :g ?g1]
[?eid1 :h ?h1]
[?eid2 :e ?e1]
]
db)))
(is (= 100 (d/q '[:find ?eid1 .
:where
[?eid1 :a ?a1]
[?eid1 :b ?b1]
[?eid1 :c ?c1]
[?eid1 :d ?d1]
[?eid1 :e ?e1]
[?eid1 :f ?f1]
[?eid1 :g ?g1]
[?eid1 :h ?h1]
[?eid2 :e ?e1]]
db)))))

(deftest test-joins
(let [db (-> (d/empty-db)
Expand Down

0 comments on commit 29288f6

Please sign in to comment.