taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.04k stars 60 forks source link

Thaw two or more nippy frozen concatenated strings #21

Closed rhishikeshj closed 10 years ago

rhishikeshj commented 11 years ago

I am using nippy to write data to and read data from a socket. The socket read can return the result of more than one write operation which causes nippy to crash since it cannot handle more than one nippy frozen clojure-data objects in one thaw call. Am i using the api correctly ? Is there some way i can use the existing api to achieve intended result ?

ptaoussanis commented 11 years ago

Hi Rhishikesh, could you show me a code/example snippet that reproduces the issue? Are you using the new streaming api, or just freeze/thaw?

rhishikeshj commented 11 years ago

Hi ptaoussanis Please find the link to code which uses this https://github.com/rhishikeshj/clj-nio/blob/master/src/clj_nio/core.clj

ptaoussanis commented 11 years ago

Okay, just looked at your ns briefly. As you correctly noticed, Nippy's thaw does expect to receive exactly the frozen bytes as a single argument. This is necessary to support compression, encryption, etc.

As of v2.1.0 though, the lower-level freeze-to-stream and thaw-from-stream utils are public. These operate on a DataOutputStream and DataInputStream respectively and might be more in line with what you want.

Does that help?