Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indenting #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
;; If nREPL takes too long to load it may timeout,
;; increase this to wait longer before timing out.
;; Defaults to 30000 (30 seconds)
:timeout 12000000
}
:timeout 12000000}

:profiles {:dev {:source-paths ["src-dev" "src"]
:dependencies [[org.jumpmind.symmetric.schemaspy/schemaspy "5.0.0"]
[com.clojure-goes-fast/clj-java-decompiler "0.1.0"]
Expand Down
12 changes: 6 additions & 6 deletions src/cavm/auth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@
(do
(info "Login:" email)
(-> (response/redirect
(let [{:keys [redirect-to]} session]
(if (string? redirect-to)
redirect-to
(let [{:keys [uri params]} redirect-to]
(str server-address (subs uri 1)
(and (seq params) (str "?" (client/generate-query-string params))))))))
(let [{:keys [redirect-to]} session]
(if (string? redirect-to)
redirect-to
(let [{:keys [uri params]} redirect-to]
(str server-address (subs uri 1)
(and (seq params) (str "?" (client/generate-query-string params))))))))
(assoc :session {:user {:authenticated? true
:email email}})))
(login-failed-page (str "Invalid user email: " email "."))))
Expand Down
60 changes: 30 additions & 30 deletions src/cavm/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@
(throw ex)))))

(comment (defn- del-datasets [args]
(dorun (map del-exp args))))
(dorun (map del-exp args))))

(comment (defn- print-datasets []
(dorun (map println (datasets)))))
(dorun (map println (datasets)))))

(defn load-edn-from
[filename]
Expand Down Expand Up @@ -239,23 +239,23 @@

; XXX call clean-sources somewhere?? Should be automated.
(comment (defn- loadfiles [load-fn root args]
(when (not (> (count args) 0))
(println "Usage\nload <filename>")
(System/exit 0))
(when (not (> (count args) 0))
(println "Usage\nload <filename>")
(System/exit 0))

; Skip files outside the designated path
(let [{in-path true, not-in-path false}
(group-by #(in-data-path root %) args)]
(when not-in-path
(binding [*out* *err*]
(println "These files are outside the CAVM data path and will not be served:")
(println (s/join "\n" (in-path false)))))
(create)
(println "Loading " (count in-path) " file(s)")
(dorun (map #(do (print %2 %1 "") (time (load-report load-fn root %1)))
in-path
(range (count in-path) 0 -1)))
(clean-sources))))
(let [{in-path true, not-in-path false}
(group-by #(in-data-path root %) args)]
(when not-in-path
(binding [*out* *err*]
(println "These files are outside the CAVM data path and will not be served:")
(println (s/join "\n" (in-path false)))))
(create)
(println "Loading " (count in-path) " file(s)")
(dorun (map #(do (print %2 %1 "") (time (load-report load-fn root %1)))
in-path
(range (count in-path) 0 -1)))
(clean-sources))))

(defn- load-files [port always files]
(client/post (str "http://localhost:" port "/update/")
Expand Down Expand Up @@ -446,12 +446,12 @@
(System/exit 1))
(throw ex))))))]
(when (and gui serve) (try
(reset! xena-import (XenaImport/start))
(catch Exception ex
(binding [*out* *err*]
(println "Failed to start gui. Logging error.")
(error "Failed to start gui." ex)
nil))))
(reset! xena-import (XenaImport/start))
(catch Exception ex
(binding [*out* *err*]
(println "Failed to start gui. Logging error.")
(error "Failed to start gui." ex)
nil))))
(Splash/close)
(reset! db (h2/create-xenadb database))
(when server
Expand All @@ -467,10 +467,10 @@
; When logging to the repl from a future, *err* gets lost.
; This will set it to the repl terminal, for reasons I don't understand.
(comment (defn snoop [msg x]
(.start (Thread. #(binding [*out* *err*]
(println msg x)
(flush))))
x))
(.start (Thread. #(binding [*out* *err*]
(println msg x)
(flush))))
x))


(comment
Expand All @@ -485,16 +485,16 @@
(def testloader (cl/loader-agent testdb testdetector docroot))
; (watch (partial file-changed #'testloader docroot-default) docroot-default)
(def keystore {:keystore (.toString (io/resource "localhost.keystore"))
:password "localxena"})
:password "localxena"})

(let [[loader load-queue] testloader]
(def ws-config (events/jetty-config load-queue))
(def app (get-app docroot testdb loader load-queue 7222 nil
(re-pattern (s/join "|" (conj trusted-hosts local-trusted-host))))))
(defonce server (serv #'app "localhost" 7222 keystore ws-config))

(.start server)
)
(.start server))


(.stop server)
(cavm.db/close testdb))
32 changes: 16 additions & 16 deletions src/cavm/h2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@
; create the sequence separately in order to set the cache parameter.

(comment (defn- sequence-seq [seqname]
(let [[{val :i}] (exec-raw (format "SELECT CURRVAL('%s') AS I" seqname) :results)]
(range (+ val 1) Double/POSITIVE_INFINITY 1))))
(let [[{val :i}] (exec-raw (format "SELECT CURRVAL('%s') AS I" seqname) :results)]
(range (+ val 1) Double/POSITIVE_INFINITY 1))))

(comment
(defn- sequence-seq
Expand Down Expand Up @@ -530,7 +530,7 @@

(defn- sequence-stmt ^cavm.statement.PStatement [db-seq]
(sql-stmt-result (jdbcd/find-connection)
(format "SELECT NEXT VALUE FOR %s AS i" db-seq)))
(format "SELECT NEXT VALUE FOR %s AS i" db-seq)))

(defn- run-delays [m]
(into {} (for [[k v] m] [k (force v)])))
Expand Down Expand Up @@ -681,9 +681,9 @@
(let [[{text :text :or {text "{}"}}] rows
metadata (json/read-str text)]
(jdbcd/update-values :dataset ["`id` = ?" dataset-id] {:text
(json/write-str
(assoc metadata "error" (str ex))
:escape-slash false)}))))
(json/write-str
(assoc metadata "error" (str ex))
:escape-slash false)}))))

(defn- with-load-status* [dataset-id func]
(try
Expand Down Expand Up @@ -781,7 +781,7 @@
:subname file
:conn-customizer "conn_customizer"
:make-pool? make-pool?}]
(if make-pool? (delay (pool spec)) (delay (-> spec)))))
(if make-pool? (delay (pool spec)) (delay (-> spec)))))

; XXX should sanitize the query
(defn- run-query [q]
Expand Down Expand Up @@ -1063,7 +1063,7 @@
(map (juxt :i :scores))
(into (or cache {})))]
(update-in new-cache [:codes] update-codes-cache field-id missing new-cache))
cache)))
cache)))

;
;
Expand Down Expand Up @@ -1260,9 +1260,9 @@
(if (not-empty rows)
(fetch-rows cache rows (fields field))
{}))]
(evaluate (set-of-all-cache N) {:fetch fetch
:fetch-indexed (partial fetch-indexed fields)
:indexed? (partial has-index? fields)} exp)))
(evaluate (set-of-all-cache N) {:fetch fetch
:fetch-indexed (partial fetch-indexed fields)
:indexed? (partial has-index? fields)} exp)))

;(jdbcd/with-connection @(:db cavm.core/testdb)
; (eval-sql {:select ["sampleID"] :from ["BRCA1"] :where [:in "sampleID"
Expand Down Expand Up @@ -1328,9 +1328,9 @@
"ALTER TABLE `dataset` ADD FOREIGN KEY (`probeMap`) REFERENCES `dataset` (`name`)"))))

(defn- migrate []
(migrate-probemap)
(migrate-probemap))
; ...add more here
)


(defn- create[]
(jdbcd/transaction
Expand All @@ -1353,9 +1353,9 @@
(defmethod hsqlfmt/format-clause :table [[_ [fields alias]] _]
(str "TABLE("
(clojure.string/join ", "
(map (fn [[name type values]]
(str (hsqlfmt/to-sql name) " " (hsqlfmt/to-sql type) "="
(hsqlfmt/paren-wrap (clojure.string/join ", " (map hsqlfmt/to-sql values))))) fields))
(map (fn [[name type values]]
(str (hsqlfmt/to-sql name) " " (hsqlfmt/to-sql type) "="
(hsqlfmt/paren-wrap (clojure.string/join ", " (map hsqlfmt/to-sql values))))) fields))
") " (hsqlfmt/to-sql alias)))

; Fix GROUP_CONCAT in honeysql
Expand Down
32 changes: 16 additions & 16 deletions src/cavm/huffman.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
;(byte-freqs-p (mapv #(.getBytes ^String %) ["foo" "bar" "baz" "horse" "fly"]))

(defn- take-lowest [^ArrayBlockingQueue q0
^ArrayBlockingQueue q1]
^ArrayBlockingQueue q1]
(let [v0 (.peek q0) v1 (.peek q1)]
(if (or (not v1) (and v0 (>= (:priority v1) (:priority v0))))
(.take q0)
Expand Down Expand Up @@ -126,10 +126,10 @@
(defn- ht-coded-dictionary [codes ^java.io.ByteArrayOutputStream out]
(write-int (count codes) out)
(doseq [{:keys [code length]} codes]
(write-int code out)
(write-int length out))
(write-int code out)
(write-int length out))
(doseq [{:keys [symbol]} codes]
(.write out ^byte symbol))
(.write out ^byte symbol))
(dotimes [i (rem (- 4 (rem (count codes) 4)) 4)] ; extend to word boundary
(.write out 0)))

Expand Down Expand Up @@ -158,7 +158,7 @@
(rest groups)
(+ start (count nodes))
depth1
(conj! acc
(conj! acc
(assoc group
:length depth1
:symbols (map #(assoc %1 :code %2)
Expand All @@ -175,9 +175,9 @@
groups)))

(comment
(defn spy [msg x]
(println msg x)
x))
(defn spy [msg x]
(println msg x)
x))

; Return the compactly-encoded canonical dictionary
; len count, lens, bytes
Expand Down Expand Up @@ -238,10 +238,10 @@
(.write output (bit-and 0xff (bit-shift-right out 8)))
(when (= m 64)
(.write output (bit-and 0xff out))))))))))
(if (>= m 8)
(let [shift (* 8 (quot m 8))]
(recur (inc i) (bit-shift-left out shift) (long (- m shift))))
(recur (inc i) out m)))
(if (>= m 8)
(let [shift (* 8 (quot m 8))]
(recur (inc i) (bit-shift-left out shift) (long (- m shift))))
(recur (inc i) out m)))
(when (not= m 0) ; write last partial byte
(.write output (bit-and 0xff (bit-shift-right out 56))))))))

Expand Down Expand Up @@ -319,7 +319,7 @@
(if (= 0 (bit-and (bit-shift-left 1 i) code))
:right
:left))
assoc :symbol sym))
assoc :symbol sym))

; build decoding tree for huffman encoding
(defn huff-tree [^ByteBufferAsIntBufferL buff32 ^ByteBuffer buff8 offset32]
Expand Down Expand Up @@ -424,11 +424,11 @@
(println disa)
(= disa disb)
(let [s (map #(.getBytes ^String %) ["foo" "bar" "baz" "one" "two" "three"])]
(display-dictionary (dictionary (build s))))
(display-dictionary (dictionary (build s))))
(let [s (map #(.getBytes ^String %) ["foo" "bar" "baz" "one" "two" "three" "zzzzzzz"])
huffman (build s)
dict (dictionary huffman)
encoded (encode-bytes dict (apply concat s))
]
encoded (encode-bytes dict (apply concat s))]

(display-dictionary dict)
[(count encoded) (into [] encoded)]))
19 changes: 9 additions & 10 deletions src/cavm/pfc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
[(.toByteArray acc)]))))

(comment
(defn decompress [[init diffs]]
(reductions (fn [^String prev [n suffix]] (str (.substring prev 0 n) suffix))
init diffs)))
(defn decompress [[init diffs]]
(reductions (fn [^String prev [n suffix]] (str (.substring prev 0 n) suffix))
init diffs)))

(defn compress-bin [strings]
{:header (into-array Byte/TYPE (concat (.getBytes ^String (first strings)) [0])) ; XXX eliminate concat. use implicit zero?
Expand Down Expand Up @@ -140,10 +140,10 @@
ht (huffman/make-hu-tucker (map #(:header %) front-coded))
; XXX Does get-bytes make sense? Why do we need to do this?
compressed-headers (map #(get-bytes huffman/write ht (:header %))
front-coded)
front-coded)
huff (huffman/make-huffman (r/mapcat :inner front-coded))
compressed (r/foldcat (r/map #(get-bytes huffman/write huff (:inner %))
front-coded))
front-coded))
sizes (map #(+ (count %1) (count %2)) compressed-headers compressed)
offsets (reductions + 0 (take (dec (count sizes)) sizes))]
{:length (count ordered)
Expand Down Expand Up @@ -319,8 +319,8 @@
;(merge-sorted-v [] ["boo" "bff" "foo" "goo" "hoo"])
;(merge-sorted-v ["boo" "foo"] [])
;(merge-sorted-v ["boo" "foo" "zoo"] ["boo" "foo" "goo" "hoo"])
(defn lookup-htfc [htfc i]
)
(defn lookup-htfc [htfc i])


(defn find-htfc [htfc s])

Expand Down Expand Up @@ -356,7 +356,7 @@
(let [strings strings
in (time (serialize-htfc (compress-htfc strings 256)))
out (time (into [] (uncompress-dict (htfc-offsets (doto (ByteBuffer/wrap in)
(.order java.nio.ByteOrder/LITTLE_ENDIAN))))))]
(.order java.nio.ByteOrder/LITTLE_ENDIAN))))))]
(= (sort strings) out))

(time
Expand Down Expand Up @@ -434,5 +434,4 @@
; more entropy in tcga/gtex ids?

(float (/ 207422 22000)) ; 9.42 bytes per string, toil
(float (/ 8900000 1300000)) ; 6.8 bytes per string, singlecell
)
(float (/ 8900000 1300000))) ; 6.8 bytes per string, singlecell
4 changes: 2 additions & 2 deletions src/cavm/statement.clj
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
(throw-non-rte e))))
(do
(doseq [param-group param-groups]
((or (:set-parameters db) set-parameters) stmt param-group)
(.addBatch stmt))
((or (:set-parameters db) set-parameters) stmt param-group)
(.addBatch stmt))
(if transaction?
(with-db-transaction [t-db (add-connection db (.getConnection stmt))]
(execute-batch stmt))
Expand Down
4 changes: 2 additions & 2 deletions src/cavm/views/datasets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
(:require [cavm.query.expression :as expr])
(:require [cavm.query.functions :as f])
(:require [ring.util.codec :as codec])
(:require [ring.util.response :as response ])
(:require [ring.util.request :refer [body-string] ])
(:require [ring.util.response :as response])
(:require [ring.util.request :refer [body-string]])
(:require [clojure.edn :as edn])
(:require [cavm.json :as json])
(:require [cavm.h2 :as h2])
Expand Down
Loading