Sync housekeeping

This commit is contained in:
Peter Taoussanis 2016-07-24 15:41:31 +07:00
parent e07ec91f41
commit a8faac734c
3 changed files with 20 additions and 18 deletions

View file

@ -15,7 +15,7 @@
:dependencies
[[org.clojure/clojure "1.5.1"]
[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.tukaani/xz "1.5"]
[net.jpountz.lz4/lz4 "1.3"]]

View file

@ -20,8 +20,8 @@
LazySeq IRecord ISeq]))
(if (vector? enc/encore-version)
(enc/assert-min-encore-version [2 52 1])
(enc/assert-min-encore-version 2.52))
(enc/assert-min-encore-version [2 67 1])
(enc/assert-min-encore-version 2.67))
(comment
(set! *unchecked-math* :warn-on-boxed)
@ -238,9 +238,9 @@
;; TODO Switch to thread-local proxies?
(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 *auto-freeze-compressor*
(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 *auto-freeze-compressor*
"(fn [byte-array])->compressor used by `(freeze <x> {:compressor :auto}),
nil => default"
nil)
@ -1553,5 +1553,6 @@
;;;; Deprecated
(enc/defonce* ^:dynamic *final-freeze-fallback* "DEPRECATED" nil)
(def freeze-fallback-as-str "DEPRECATED" write-unfreezable)
(enc/deprecated
(enc/defonce ^:dynamic *final-freeze-fallback* "DEPRECATED" nil)
(def freeze-fallback-as-str "DEPRECATED" write-unfreezable))

View file

@ -8,16 +8,17 @@
;; Unfortunately the only ~reliable way we can tell if something's
;; really serializable/readable is to actually try a full roundtrip.
(defn- memoize-type-test [test-fn]
(let [cache (atom {})] ; {<type> <type-okay?>}
(fn [x]
(let [t (type x)
;; This is a bit hackish, but no other obvious solutions (?):
cacheable? (not (re-find #"__\d+" (str t))) ; gensym form
test (fn [] (try (test-fn x) (catch Exception _ false)))]
(if cacheable?
@(enc/swap-val! cache t #(if % % (delay (test))))
(test))))))
(let [swap-cache! @#'enc/-swap-cache!] ; TODO Public with newer Encore
(defn- memoize-type-test [test-fn]
(let [cache (atom {})] ; {<type> <type-okay?>}
(fn [x]
(let [t (type x)
;; This is a bit hackish, but no other obvious solutions (?):
cacheable? (not (re-find #"__\d+" (str t))) ; gensym form
test (fn [] (try (test-fn x) (catch Exception _ false)))]
(if cacheable?
@(swap-cache! cache t #(if % % (delay (test))))
(test)))))))
(def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true)))
(def serializable?