You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Exanding on this after digging into it a bit:
the root of our problem comes from
crdts::Map<Key, Value, Actor>
requiringValue
to implementDefault
.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 ofValue
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 (usingKind::default_data() -> Data
) but incrdts::Map
we rely on Type parameters, not Key's to tell us the default value.Potential fixes:
crdts::Map
to have smarter keys: This has performance implications since we move to the equivalent of dynamic dispatch. As a library I would likecrdts
to stay as static as possible.crdts::Map
for HermitDB, we already have an implementation of Map that has the semantics we need but it usessled
as it's backing datastore. If we can abstract over the storage layer, we can re-use this implementation with aHashMap
in place of sled.Nil
merge(Nil, A) = A
forall AThe text was updated successfully, but these errors were encountered: