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

Marshal #34

Open
blacktop opened this issue Dec 12, 2020 · 5 comments
Open

Marshal #34

blacktop opened this issue Dec 12, 2020 · 5 comments

Comments

@blacktop
Copy link

Would it be possible to add Marshal/Unmarshal functions? I'm creating very large tries and it burns my lap to generate them 🔥 I'd like to save them to disk so I don't have to regen again.

Would that be possible?

@blacktop
Copy link
Author

I tried to gob and got gob: type radix.Tree has no exported fields

@rfyiamcool
Copy link

rfyiamcool commented Feb 26, 2021

@backspace +1

@i0x71
Copy link

i0x71 commented Apr 22, 2021

Would be very nice to have this.

@banks
Copy link
Member

banks commented Jun 16, 2021

My slight hesitation is that gob is not the format most projects would need if they wanted to encode to disk or network since it's not cross-platform. Encoding to GOB then decoding to something else and re-encoding to JSON or protobuf seems painful.

An alternative would be to add a ToMap function or similar that copies the tree into a map[[]byte]interface{}. and returns that to be encoded however the caller wishes.

But in reality that method would just be a simple iteration over the tree and assignment into a map - something the caller could do with a few lines of code anyway and probably more efficiently as they might not need interim map copy.

So I'd be inclined to follow the Go convention of not including code that is trivial to write in low-level libs.

What do you all think? Would having an example in the README of how to encode to Gob be a reasonable alternative?

@blacktop
Copy link
Author

I think that'd be great!

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

4 participants