Skip to content

Commit

Permalink
fix #260
Browse files Browse the repository at this point in the history
  • Loading branch information
huahaiy committed Jun 23, 2024
1 parent 4283f25 commit 6b4093f
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 627 deletions.
29 changes: 12 additions & 17 deletions src/datalevin/query.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
(:refer-clojure :exclude [update assoc])
(:require
[clojure.set :as set]
[clojure.pprint :as pp]
[clojure.edn :as edn]
[clojure.string :as str]
[clojure.walk :as walk]
[datalevin.db :as db]
[datalevin.rules :as rl]
[datalevin.query-util :as qu]
[datalevin.relation :as r]
[datalevin.built-ins :as built-ins]
Expand All @@ -22,10 +20,9 @@
[datalevin.constants :as c]
[datalevin.query :as q]
[datalevin.bits :as b]
[clojure.pprint :as pp])
)
(:import
[java.util Arrays List]
[java.nio.charset StandardCharsets]
[clojure.lang ILookup LazilyPersistentVector]
[datalevin.utl LikeFSM]
[datalevin.relation Relation]
Expand Down Expand Up @@ -1523,17 +1520,18 @@
know-e? (int? e)
schema (db/-schema db)
init (cond-> (map->InitStep
{:attr attr :vars [e] :cols [e] :out #{e}
{:attr attr :vars [e] :out #{e}
:mcount (:count clause)
:save *save-intermediate*})
know-e? (assoc :know-e? true :vars [] :cols [])
var (#(assoc % :pred (attr-pred [attr clause])
:vars (cond-> (:vars %)
(not (qu/placeholder? var))
(conj var))
:cols (conj (:cols %) attr)
:range range))
val (assoc :val val))
var (assoc :pred (attr-pred [attr clause])
:vars (cond-> [e]
(not (qu/placeholder? var))
(conj var))
:range range)
val (assoc :val val)
know-e? (assoc :know-e? true)
true (#(assoc % :cols
(if (= 1 (count (:vars %))) [e] [e attr]))))
cols (:cols init)]
(cond-> [init]
(< 1 (+ (count bound) (count free)))
Expand Down Expand Up @@ -1665,7 +1663,6 @@

(defn- link-step
[op last-step index attr tgt new-key]
(println "tgt ->" tgt)
(let [in (:out last-step)
cols (conj (:cols last-step) tgt)]
(case op
Expand Down Expand Up @@ -1787,7 +1784,6 @@
{:keys [cost] :as new-plan}
(binary-plan db nodes (base-plans new-e) prev-plan
(first link-e) (first new-e) new-key)]
(println "new plan ->" new-plan)
(if (< ^long cost ^long cur-cost)
(assoc t new-key new-plan)
t))
Expand All @@ -1814,7 +1810,6 @@
tables (FastList. n)
n-1 (dec n)
base-ps (build-base-plans db nodes component)]
(println "base-plans ->" base-ps)
(.add tables base-ps)
(dotimes [i n-1]
(.add tables (plans db nodes connected base-ps (.get tables i))))
Expand Down Expand Up @@ -1915,7 +1910,7 @@
(do (plan-explain) context)
(as-> context c
(build-plan c)
(do (pp/pprint c) (plan-explain) c)
(do (plan-explain) c)
(if run? (execute-plan c) c)
(if run? (reduce resolve-clause c (:late-clauses c)) c))))))

Expand Down
Loading

0 comments on commit 6b4093f

Please sign in to comment.