Misc hk
This commit is contained in:
parent
0905b96ca6
commit
037cb14739
1 changed files with 17 additions and 13 deletions
|
|
@ -410,11 +410,10 @@
|
||||||
(let [;; Intentionally undocumented:
|
(let [;; Intentionally undocumented:
|
||||||
no-header? (or (:no-header? opts) (:skip-header? opts))
|
no-header? (or (:no-header? opts) (:skip-header? opts))
|
||||||
encryptor (when password encryptor)
|
encryptor (when password encryptor)
|
||||||
zero-copy-mode? (and (nil? compressor) (nil? encryptor))
|
|
||||||
baos (ByteArrayOutputStream. 64)
|
baos (ByteArrayOutputStream. 64)
|
||||||
dos (DataOutputStream. baos)]
|
dos (DataOutputStream. baos)]
|
||||||
|
|
||||||
(if zero-copy-mode?
|
(if (and (nil? compressor) (nil? encryptor))
|
||||||
(do ; Optimized case
|
(do ; Optimized case
|
||||||
(when-not no-header? ; Avoid `wrap-header`'s array copy:
|
(when-not no-header? ; Avoid `wrap-header`'s array copy:
|
||||||
(let [head-ba (get-head-ba {:compressor-id nil :encryptor-id nil})]
|
(let [head-ba (get-head-ba {:compressor-id nil :encryptor-id nil})]
|
||||||
|
|
@ -442,12 +441,17 @@
|
||||||
(if no-header?
|
(if no-header?
|
||||||
ba
|
ba
|
||||||
(wrap-header ba
|
(wrap-header ba
|
||||||
{:compressor-id (when-let [c compressor]
|
{:compressor-id
|
||||||
|
(when-let [c compressor]
|
||||||
(or (compression/standard-header-ids
|
(or (compression/standard-header-ids
|
||||||
(compression/header-id c)) :else))
|
(compression/header-id c))
|
||||||
:encryptor-id (when-let [e encryptor]
|
:else))
|
||||||
|
|
||||||
|
:encryptor-id
|
||||||
|
(when-let [e encryptor]
|
||||||
(or (encryption/standard-header-ids
|
(or (encryption/standard-header-ids
|
||||||
(encryption/header-id e)) :else))}))))))))
|
(encryption/header-id e))
|
||||||
|
:else))}))))))))
|
||||||
|
|
||||||
;;;; Thawing
|
;;;; Thawing
|
||||||
|
|
||||||
|
|
@ -671,8 +675,8 @@
|
||||||
|
|
||||||
Options include:
|
Options include:
|
||||||
:v1-compatibility? - support data frozen by legacy versions of Nippy?
|
:v1-compatibility? - support data frozen by legacy versions of Nippy?
|
||||||
:compressor - An ICompressor, :auto (requires Nippy header), or nil
|
:compressor - :auto (checks header, default) an ICompressor, or nil
|
||||||
:encryptor - An IEncryptor, :auto (requires Nippy header), or nil"
|
:encryptor - :auto (checks header, default), an IEncryptor, or nil"
|
||||||
|
|
||||||
([ba] (thaw ba nil))
|
([ba] (thaw ba nil))
|
||||||
([^bytes ba
|
([^bytes ba
|
||||||
|
|
@ -785,7 +789,7 @@
|
||||||
(assert-custom-type-id custom-type-id)
|
(assert-custom-type-id custom-type-id)
|
||||||
(if-not (keyword? custom-type-id)
|
(if-not (keyword? custom-type-id)
|
||||||
(int (- ^long custom-type-id))
|
(int (- ^long custom-type-id))
|
||||||
(let [^long hash-id (hash custom-type-id)
|
(let [^int hash-id (hash custom-type-id)
|
||||||
short-hash-id (if (pos? hash-id)
|
short-hash-id (if (pos? hash-id)
|
||||||
(mod hash-id Short/MAX_VALUE)
|
(mod hash-id Short/MAX_VALUE)
|
||||||
(mod hash-id Short/MIN_VALUE))]
|
(mod hash-id Short/MIN_VALUE))]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue