From 29288f6659bac1bf289474bfa9f035ae563588ee Mon Sep 17 00:00:00 2001 From: Huahai Yang Date: Tue, 28 Jul 2020 09:26:57 -0700 Subject: [PATCH] fix test --- src/datalevin/query.cljc | 26 +++++++++----------------- test/datalevin/test/query.cljc | 27 +++++++++++++-------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/src/datalevin/query.cljc b/src/datalevin/query.cljc index 0ef3855e..6df91dc5 100644 --- a/src/datalevin/query.cljc +++ b/src/datalevin/query.cljc @@ -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] diff --git a/test/datalevin/test/query.cljc b/test/datalevin/test/query.cljc index 196ba216..e513579a 100644 --- a/test/datalevin/test/query.cljc +++ b/test/datalevin/test/query.cljc @@ -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)) @@ -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)