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

Option as RedbValue #486

Closed
casey opened this issue Jan 12, 2023 · 4 comments · Fixed by #490
Closed

Option as RedbValue #486

casey opened this issue Jan 12, 2023 · 4 comments · Fixed by #490

Comments

@casey
Copy link
Contributor

casey commented Jan 12, 2023

I was thinking about combing two tables which map keys to u64s. However, the second table doesn't have an entry for each ID, so the value type would need to be (u64, Option<u64>), but Option<u64> doesn't have an impl for RedbValue.

This isn't at all pressing, since I can just leave them separate, and I was combining them based on the assumption that having fewer tables with multiple values in each table would be faster, and I haven't actually benchmarked that. However I assume it'll be a common use-case.

@cberner
Copy link
Owner

cberner commented Jan 12, 2023

Oh ya, this seems like a good idea. It also gives me a good test case for working through some of the complexities of supporting #360 . There are enough use cases for type alignment that I think it'd be nice to support, but as much as possible I want the alignment to be checked at compile time, so that it doesn't introduce a bunch of subtle bugs

@casey
Copy link
Contributor Author

casey commented Jan 12, 2023

Is Option guaranteed to have a stable binary representation? Or, maybe I misunderstood, how does alignment figure into this?

@cberner
Copy link
Owner

cberner commented Jan 13, 2023

Oh not directly. It's just that one of the complexities of type alignment is nested types. Implementing nested aligned types in tuples would be pretty annoying, but I'd like to implement them for something to be sure the abstractions work. Option seems like a good, simple, first type for that

@casey
Copy link
Contributor Author

casey commented Jan 13, 2023

Check out my comment in #360 (comment), but I'm wondering if alignment might be something that redb only needs to support for top-level byte slice and array keys and values. If a user needs alignment, then there's a good chance that they need it because they're going to do some kind of performance-critical zero-copy deserialization from a byte slice to higher level types that require alignment. And in those circumstances, they might also have their own serialization/deserialization format that they'll be using instead of redb's types/tuples. So in that case might be limited utility in supporting alignment for things other than byte slices, which might reduce the complexity of the implementation.

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

Successfully merging a pull request may close this issue.

2 participants