Skip to content

Commit

Permalink
Merge pull request #189 from chrovis/spike/cache-replacement-for-cigar
Browse files Browse the repository at this point in the history
Replace memoizing cache for parsed CIGARs with core.memoize's LU cache
  • Loading branch information
r6eve authored Feb 13, 2020
2 parents c320af1 + d1c7312 commit 0eb2542
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
:url "https://github.com/chrovis/cljam"
:license {:name "Apache License, Version 2.0"
:url "https://www.apache.org/licenses/LICENSE-2.0"}
:dependencies [[org.clojure/tools.logging "0.5.0"]
:dependencies [[org.clojure/core.memoize "0.8.2"]
[org.clojure/tools.logging "0.5.0"]
[org.clojure/tools.cli "0.4.2"]
[org.apache.commons/commons-compress "1.19"]
[clj-sub-command "0.5.1"]
Expand Down
7 changes: 6 additions & 1 deletion src/cljam/io/sam/util/cigar.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns cljam.io.sam.util.cigar
"Parser of CIGAR strings."
(:require [clojure.core.memoize :as memoize]
[proton.core :as proton])
(:import [java.nio ByteBuffer ByteOrder]))

(defn parse
Expand Down Expand Up @@ -45,7 +47,10 @@
#{\I} (recur xs r (+ s l) (update-last! idx (fn [x] [:i x [s (+ l s)]]))))
(persistent! idx)))))

(def to-index (memoize to-index*))
(def to-index
(memoize/lu to-index* :lu/threshold
(or (proton/as-int (System/getProperty "cljam.sam.cigar.cache-size"))
1024)))

(defn count-op
"Returns length of CIGAR operations."
Expand Down

0 comments on commit 0eb2542

Please sign in to comment.