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