konserve icon indicating copy to clipboard operation
konserve copied to clipboard

custom serialization not working

Open behrica opened this issue 1 year ago • 6 comments

I tried to plugin my own custom serailisation using nippy as documented here: https://github.com/replikativ/konserve/blob/main/doc/api-walkthrough.md#connecting-stores

but I got an NPE, which seems to related to this line: https://github.com/replikativ/konserve/blob/8e96b4648599c42a93bb0e2e1779fccc4194f81b/src/konserve/serializers.cljc#L79

which seems to list all potential classes implementing PStoreSerializer

I get a nil here: https://github.com/replikativ/konserve/blob/8e96b4648599c42a93bb0e2e1779fccc4194f81b/src/konserve/impl/storage_layout.cljc#L26

as now serializer-id is found for my own class.

behrica avatar Oct 07 '24 11:10 behrica

can you share you connect-store call and serializer?

pkpkpk avatar Oct 07 '24 22:10 pkpkpk

I worked arround it by creating bytes first via nippy, and save those via konserve.

Lets see if find the code back.

behrica avatar Oct 09 '24 07:10 behrica

If you want to add a serializer you need to open a PR. The serializer are internally mapped into a lookup table like this to allow store schema updates for konserve, that is why adding it to the codebase is reasonable. Nippy would definitely be nice to have for the JVM. I focused on formats that also work in JS so far, but not everybody needs that.

whilo avatar Oct 09 '24 17:10 whilo

Thnaks, I thought so after reading code. But then this should maybe reformluated: https://github.com/replikativ/konserve/blob/32b7f253a5ec76b9dfcb177a58cdbf76fb006a51/doc/api-walkthrough.md?plain=1#L64

"custom serializer" sounds like "custom defrecord", while you mean "custom configuration/handler"

behrica avatar Oct 09 '24 21:10 behrica

To add "nippy" would be nice, but needed to be very configurable. In a lot of case a user would need to configure custom " safe classes" for de-serialization of Serialised java classes.

behrica avatar Oct 09 '24 21:10 behrica

So you are saying that this cannot be passed in as a read and write handler to the serializer? Currently it works by defining stateless serializer constructors, but they then can be parametrized by such custom handling code.

The reason for this is that konserve allows to change serializers without having to reserialize the whole store. It keeps a mapping per key to make sure that a value can always be read, even if the store serializer was different when it was written. You still need to provide the handlers though if you want it to be read in particular way.

whilo avatar Oct 11 '24 19:10 whilo