This commit is contained in:
jeaye 2016-09-01 05:47:41 +00:00 committed by GitHub
commit fdeefdc34e
2 changed files with 10 additions and 10 deletions

View file

@ -975,12 +975,12 @@
compressor compressor
(if (identical? compressor :auto) (if (identical? compressor :auto)
(if no-header? (if no-header?
lz4-compressor @lz4-compressor
(if-let [fc *auto-freeze-compressor*] (if-let [fc *auto-freeze-compressor*]
(fc ba) (fc ba)
;; Intelligently enable compression only if benefit ;; Intelligently enable compression only if benefit
;; is likely to outweigh cost: ;; is likely to outweigh cost:
(when (> (alength ba) 8192) lz4-compressor))) (when (> (alength ba) 8192) @lz4-compressor)))
(if (fn? compressor) (if (fn? compressor)
(compressor ba) ; Assume compressor selector fn (compressor ba) ; Assume compressor selector fn
@ -1244,7 +1244,7 @@
nil nil nil nil
:snappy snappy-compressor :snappy snappy-compressor
:lzma2 lzma2-compressor :lzma2 lzma2-compressor
:lz4 lz4-compressor :lz4 @lz4-compressor
:no-header (throw (ex-info ":auto not supported on headerless data." {})) :no-header (throw (ex-info ":auto not supported on headerless data." {}))
:else (throw (ex-info ":auto not supported for non-standard compressors." {})) :else (throw (ex-info ":auto not supported for non-standard compressors." {}))
(throw (ex-info (str "Unrecognized :auto compressor id: " compressor-id) (throw (ex-info (str "Unrecognized :auto compressor id: " compressor-id)

View file

@ -99,7 +99,7 @@
ba-decomp))) ba-decomp)))
(def ^:private ^net.jpountz.lz4.LZ4Factory lz4-factory (def ^:private ^net.jpountz.lz4.LZ4Factory lz4-factory
(net.jpountz.lz4.LZ4Factory/fastestInstance)) (delay (net.jpountz.lz4.LZ4Factory/fastestInstance)))
(def lz4-compressor (def lz4-compressor
"Default net.jpountz.lz4 compressor: "Default net.jpountz.lz4 compressor:
@ -111,13 +111,13 @@
Thanks to Max Penet (@mpenet) for our first implementation, Thanks to Max Penet (@mpenet) for our first implementation,
Ref. https://github.com/mpenet/nippy-lz4" Ref. https://github.com/mpenet/nippy-lz4"
(LZ4Compressor. (.fastCompressor lz4-factory) (delay (LZ4Compressor. (.fastCompressor @lz4-factory)
(.fastDecompressor lz4-factory))) (.fastDecompressor @lz4-factory))))
(def lz4hc-compressor (def lz4hc-compressor
"Like `lz4-compressor` but trades some write speed for ratio." "Like `lz4-compressor` but trades some write speed for ratio."
(LZ4Compressor. (.highCompressor lz4-factory) (delay (LZ4Compressor. (.highCompressor @lz4-factory)
(.fastDecompressor lz4-factory))) (.fastDecompressor @lz4-factory))))
(comment (comment
(def ba-bench (.getBytes (apply str (repeatedly 1000 rand)) "UTF-8")) (def ba-bench (.getBytes (apply str (repeatedly 1000 rand)) "UTF-8"))
@ -130,8 +130,8 @@
(println (println
{:snappy (bench1 snappy-compressor) {:snappy (bench1 snappy-compressor)
;:lzma2 (bench1 lzma2-compressor) ; Slow! ;:lzma2 (bench1 lzma2-compressor) ; Slow!
:lz4 (bench1 lz4-compressor) :lz4 (bench1 @lz4-compressor)
:lz4hc (bench1 lz4hc-compressor)}) :lz4hc (bench1 @lz4hc-compressor)})
;;; 2014 April 7 ;;; 2014 April 7
{:snappy {:time 2251, :ratio 0.852}, {:snappy {:time 2251, :ratio 0.852},