Sync housekeeping
This commit is contained in:
parent
e07ec91f41
commit
a8faac734c
3 changed files with 20 additions and 18 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
:dependencies
|
:dependencies
|
||||||
[[org.clojure/clojure "1.5.1"]
|
[[org.clojure/clojure "1.5.1"]
|
||||||
[org.clojure/tools.reader "0.10.0"]
|
[org.clojure/tools.reader "0.10.0"]
|
||||||
[com.taoensso/encore "2.64.1"]
|
[com.taoensso/encore "2.67.1"]
|
||||||
[org.iq80.snappy/snappy "0.4"]
|
[org.iq80.snappy/snappy "0.4"]
|
||||||
[org.tukaani/xz "1.5"]
|
[org.tukaani/xz "1.5"]
|
||||||
[net.jpountz.lz4/lz4 "1.3"]]
|
[net.jpountz.lz4/lz4 "1.3"]]
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
LazySeq IRecord ISeq]))
|
LazySeq IRecord ISeq]))
|
||||||
|
|
||||||
(if (vector? enc/encore-version)
|
(if (vector? enc/encore-version)
|
||||||
(enc/assert-min-encore-version [2 52 1])
|
(enc/assert-min-encore-version [2 67 1])
|
||||||
(enc/assert-min-encore-version 2.52))
|
(enc/assert-min-encore-version 2.67))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(set! *unchecked-math* :warn-on-boxed)
|
(set! *unchecked-math* :warn-on-boxed)
|
||||||
|
|
@ -238,9 +238,9 @@
|
||||||
|
|
||||||
;; TODO Switch to thread-local proxies?
|
;; TODO Switch to thread-local proxies?
|
||||||
|
|
||||||
(enc/defonce* ^:dynamic *freeze-fallback* "(fn [data-output x]), nil => default" nil)
|
(enc/defonce ^:dynamic *freeze-fallback* "(fn [data-output x]), nil => default" nil)
|
||||||
(enc/defonce* ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])}" nil)
|
(enc/defonce ^:dynamic *custom-readers* "{<hash-or-byte-id> (fn [data-input])}" nil)
|
||||||
(enc/defonce* ^:dynamic *auto-freeze-compressor*
|
(enc/defonce ^:dynamic *auto-freeze-compressor*
|
||||||
"(fn [byte-array])->compressor used by `(freeze <x> {:compressor :auto}),
|
"(fn [byte-array])->compressor used by `(freeze <x> {:compressor :auto}),
|
||||||
nil => default"
|
nil => default"
|
||||||
nil)
|
nil)
|
||||||
|
|
@ -1553,5 +1553,6 @@
|
||||||
|
|
||||||
;;;; Deprecated
|
;;;; Deprecated
|
||||||
|
|
||||||
(enc/defonce* ^:dynamic *final-freeze-fallback* "DEPRECATED" nil)
|
(enc/deprecated
|
||||||
(def freeze-fallback-as-str "DEPRECATED" write-unfreezable)
|
(enc/defonce ^:dynamic *final-freeze-fallback* "DEPRECATED" nil)
|
||||||
|
(def freeze-fallback-as-str "DEPRECATED" write-unfreezable))
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,17 @@
|
||||||
;; Unfortunately the only ~reliable way we can tell if something's
|
;; Unfortunately the only ~reliable way we can tell if something's
|
||||||
;; really serializable/readable is to actually try a full roundtrip.
|
;; really serializable/readable is to actually try a full roundtrip.
|
||||||
|
|
||||||
(defn- memoize-type-test [test-fn]
|
(let [swap-cache! @#'enc/-swap-cache!] ; TODO Public with newer Encore
|
||||||
(let [cache (atom {})] ; {<type> <type-okay?>}
|
(defn- memoize-type-test [test-fn]
|
||||||
(fn [x]
|
(let [cache (atom {})] ; {<type> <type-okay?>}
|
||||||
(let [t (type x)
|
(fn [x]
|
||||||
;; This is a bit hackish, but no other obvious solutions (?):
|
(let [t (type x)
|
||||||
cacheable? (not (re-find #"__\d+" (str t))) ; gensym form
|
;; This is a bit hackish, but no other obvious solutions (?):
|
||||||
test (fn [] (try (test-fn x) (catch Exception _ false)))]
|
cacheable? (not (re-find #"__\d+" (str t))) ; gensym form
|
||||||
(if cacheable?
|
test (fn [] (try (test-fn x) (catch Exception _ false)))]
|
||||||
@(enc/swap-val! cache t #(if % % (delay (test))))
|
(if cacheable?
|
||||||
(test))))))
|
@(swap-cache! cache t #(if % % (delay (test))))
|
||||||
|
(test)))))))
|
||||||
|
|
||||||
(def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true)))
|
(def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true)))
|
||||||
(def serializable?
|
(def serializable?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue