Update ba inspector
This commit is contained in:
parent
7faaf48ee7
commit
c5901730ea
1 changed files with 23 additions and 21 deletions
|
|
@ -882,30 +882,32 @@
|
||||||
;;;; Tools
|
;;;; Tools
|
||||||
|
|
||||||
(defn inspect-ba "Alpha - subject to change"
|
(defn inspect-ba "Alpha - subject to change"
|
||||||
[ba & [thaw-opts]]
|
([ba ] (inspect-ba ba nil))
|
||||||
(if-not (enc/bytes? ba) :not-ba
|
([ba thaw-opts]
|
||||||
(let [[first2bytes nextbytes] (enc/ba-split ba 2)
|
(when (enc/bytes? ba)
|
||||||
known-wrapper
|
(let [[first2bytes nextbytes] (enc/ba-split ba 2)
|
||||||
(cond
|
?known-wrapper
|
||||||
(enc/ba= first2bytes (.getBytes "\u0000<" "UTF8")) :carmine/bin
|
(cond
|
||||||
(enc/ba= first2bytes (.getBytes "\u0000>" "UTF8")) :carmine/clj)
|
(enc/ba= first2bytes (.getBytes "\u0000<" "UTF8")) :carmine/bin
|
||||||
|
(enc/ba= first2bytes (.getBytes "\u0000>" "UTF8")) :carmine/clj)
|
||||||
|
|
||||||
unwrapped-ba (if known-wrapper nextbytes ba)
|
unwrapped-ba (if ?known-wrapper nextbytes ba)
|
||||||
[data-ba nippy-header] (or (try-parse-header unwrapped-ba)
|
[data-ba ?nippy-header] (or (try-parse-header unwrapped-ba)
|
||||||
[unwrapped-ba :no-header])]
|
[unwrapped-ba :no-header])]
|
||||||
|
|
||||||
{:known-wrapper known-wrapper
|
{:?known-wrapper ?known-wrapper
|
||||||
:nippy-v2-header nippy-header ; Nippy v1.x didn't have a header
|
:?header ?nippy-header
|
||||||
:thawable? (try (thaw unwrapped-ba thaw-opts) true
|
:thawable? (try (thaw unwrapped-ba thaw-opts) true
|
||||||
(catch Exception _ false))
|
(catch Exception _ false))
|
||||||
:unwrapped-ba unwrapped-ba
|
:unwrapped-ba unwrapped-ba
|
||||||
:data-ba data-ba
|
:data-ba data-ba
|
||||||
:unwrapped-len (alength ^bytes unwrapped-ba)
|
:unwrapped-len (alength ^bytes unwrapped-ba)
|
||||||
:ba-len (alength ^bytes ba)
|
:ba-len (alength ^bytes ba)
|
||||||
:data-len (alength ^bytes data-ba)})))
|
:data-len (alength ^bytes data-ba)}))))
|
||||||
|
|
||||||
(comment (inspect-ba (freeze "hello"))
|
(comment
|
||||||
(seq (:data-ba (inspect-ba (freeze "hello")))))
|
(inspect-ba (freeze "hello"))
|
||||||
|
(seq (:data-ba (inspect-ba (freeze "hello")))))
|
||||||
|
|
||||||
;;;; Deprecated
|
;;;; Deprecated
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue