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

data::Prim::Nil breaks associativty #26

Open
davidrusu opened this issue Dec 16, 2018 · 0 comments
Open

data::Prim::Nil breaks associativty #26

davidrusu opened this issue Dec 16, 2018 · 0 comments

Comments

@davidrusu
Copy link
Member

davidrusu commented Dec 16, 2018

Exanding on this after digging into it a bit:

the root of our problem comes from crdts::Map<Key, Value, Actor> requiring Value to implement Default.

crdts::Map needs Default because we may receive an Update op that is updating a key that doesn't exist. It needs a way to create an instance of Value so that we can apply the update to it.

In HermitDB, Map keys have type (String, Kind). This gives us enough information to create a default Data for a missing key (using Kind::default_data() -> Data) but in crdts::Map we rely on Type parameters, not Key's to tell us the default value.

Potential fixes:

  • edit crdts::Map to have smarter keys: This has performance implications since we move to the equivalent of dynamic dispatch. As a library I would like crdts to stay as static as possible.
  • re-implement a special case of crdts::Map for HermitDB, we already have an implementation of Map that has the semantics we need but it uses sled as it's backing datastore. If we can abstract over the storage layer, we can re-use this implementation with a HashMap in place of sled.
  • Re-introduce Nil
    • merge(Nil, A) = A forall A
    • Make a bunch of runtime checks to ensure Nil never ends up in the database or things can go bad
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

1 participant