Skip to content

Commit

Permalink
add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
huahaiy committed Nov 9, 2024
1 parent 7b6fa52 commit 60cb923
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/datalevin/query.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1588,16 +1588,16 @@
0 attrs-v))

(defn- factor
[magic n]
[magic ^long n]
(if (zero? n) 1 ^long (estimate-round (* ^double magic n))))

(defn- estimate-scan-v-cost
[{:keys [attrs-v vars]} ^long size]
(* size
^double c/magic-cost-merge-scan-v
(factor c/magic-cost-var (count vars))
(factor c/magic-cost-pred (n-items attrs-v :pred))
(factor c/magic-cost-fidx (n-items attrs-v :fidx))))
^double (factor c/magic-cost-var (count vars))
^double (factor c/magic-cost-pred (n-items attrs-v :pred))
^double (factor c/magic-cost-fidx (n-items attrs-v :fidx))))

(defn- estimate-base-cost
[{:keys [mcount]} steps]
Expand Down
14 changes: 7 additions & 7 deletions src/datalevin/storage.clj
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@
(recur (produce in))))))
(fn [iterable]
(let [gcounts (group-counts aids)
gstarts (group-starts gcounts)
gstarts ^ints (group-starts gcounts)
gcounts (int-array gcounts)]
(loop [tuple (produce in)]
(when tuple
Expand All @@ -964,7 +964,7 @@
in? false]
(if next?
(let [vb ^ByteBuffer (lmdb/next-val iter)
a (b/read-buffer (.rewind vb) :int)
a ^int (b/read-buffer (.rewind vb) :int)
gi (if (== pa a)
gi
(if in? (inc gi) gi))
Expand All @@ -983,7 +983,7 @@
(int fidx)))))
(.add ^FastList (aget vs ai) v))))
(recur (lmdb/has-next-val iter)
gi a true))
gi (int a) true))
(recur (lmdb/has-next-val iter)
gi pa false)))
(when-not (some #(.isEmpty ^FastList %) vs)
Expand Down Expand Up @@ -1063,7 +1063,7 @@
(r/join-tuples tuple vst))))))))))))
(fn [iterable]
(let [gcounts (group-counts aids)
gstarts (group-starts gcounts)
gstarts ^ints (group-starts gcounts)
gcounts (int-array gcounts)]
(dotimes [i nt]
(let [tuple (.get ^List in i)
Expand All @@ -1080,7 +1080,7 @@
in? false]
(if next?
(let [vb ^ByteBuffer (lmdb/next-val iter)
a (b/read-buffer (.rewind vb) :int)
a ^int (b/read-buffer (.rewind vb) :int)
gi (if (== pa a)
gi
(if in? (inc gi) gi))
Expand All @@ -1099,9 +1099,9 @@
(int fidx)))))
(.add ^FastList (aget vs ai) v))))
(recur (lmdb/has-next-val iter)
gi a true))
gi (int a) true))
(recur (lmdb/has-next-val iter)
gi a false)))
gi pa false)))
(when-not (some #(.isEmpty ^FastList %) vs)
(let [vst (r/many-tuples
(->> (map (fn [v s] (when-not s v))
Expand Down

0 comments on commit 60cb923

Please sign in to comment.