Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom serialization not working #122

Open
behrica opened this issue Oct 7, 2024 · 6 comments
Open

custom serialization not working #122

behrica opened this issue Oct 7, 2024 · 6 comments

Comments

@behrica
Copy link

behrica commented Oct 7, 2024

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:

(def byte->serializer

which seems to list all potential classes implementing PStoreSerializer

I get a nil here:

env-array (byte-array [version serializer-id compressor-id encryptor-id])

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

@pkpkpk
Copy link
Collaborator

pkpkpk commented Oct 7, 2024

can you share you connect-store call and serializer?

@behrica
Copy link
Author

behrica commented Oct 9, 2024

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

Lets see if find the code back.

@whilo
Copy link
Member

whilo commented Oct 9, 2024

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.

@behrica
Copy link
Author

behrica commented Oct 9, 2024

Thnaks, I thought so after reading code.
But then this should maybe reformluated:

- this is where you can provide your own serializer to reference via `:default-serializer`

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

@behrica
Copy link
Author

behrica commented Oct 9, 2024

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.

@whilo
Copy link
Member

whilo commented Oct 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants