Add a fast serialization for Date objects
This commit is contained in:
parent
e48ccb4c45
commit
8b13ff68b9
1 changed files with 7 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
(:import [java.io DataInputStream DataOutputStream ByteArrayOutputStream
|
||||
ByteArrayInputStream]
|
||||
[java.lang.reflect Method]
|
||||
[java.util Date]
|
||||
[clojure.lang Keyword BigInt Ratio PersistentQueue PersistentTreeMap
|
||||
PersistentTreeSet IPersistentList IPersistentVector IPersistentMap
|
||||
IPersistentSet IPersistentCollection IRecord]))
|
||||
|
|
@ -66,6 +67,8 @@
|
|||
|
||||
(def ^:const id-record (int 80))
|
||||
|
||||
(def ^:const id-date (int 90))
|
||||
|
||||
;;; DEPRECATED (old types will be supported only for thawing)
|
||||
(def ^:const id-old-reader (int 1)) ; as of 0.9.2, for +64k support
|
||||
(def ^:const id-old-string (int 11)) ; as of 0.9.2, for +64k support
|
||||
|
|
@ -173,6 +176,8 @@
|
|||
(write-biginteger s (.numerator x))
|
||||
(write-biginteger s (.denominator x)))
|
||||
|
||||
(freezer Date id-date (.writeLong s (.getTime x)))
|
||||
|
||||
(def ^:private head-meta-id (reduce-kv #(assoc %1 %3 %2) {} head-meta))
|
||||
|
||||
(defn- wrap-header [data-ba metadata]
|
||||
|
|
@ -276,6 +281,8 @@
|
|||
method ^Method (.getMethod class "create" meth-sig)]
|
||||
(.invoke method class (into-array Object [(thaw-from-stream s)])))
|
||||
|
||||
id-date (Date. (.readLong s))
|
||||
|
||||
;;; DEPRECATED
|
||||
id-old-reader (edn/read-string (.readUTF s))
|
||||
id-old-string (.readUTF s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue