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 new hashtable doesn't have a dict entry, so we need to invent one to hold field and value.
Possibly, we can embed field or value or both. The method used earlier is the function sdscopytobuffer and a byte to store the size of the sds header.
A field name never changes so it seems safe to always embed the field name, while the value can change and it can be very large so we can allow it to be non-embedded. This is very similar to string keys with the EMBSTR vs RAW encoding.
Idea of layout with field embedded, value as pointer, stored first to make it aligned. (#1502 simply uses this representation for all field-value pairs.)
+-------+-----------------------------+
| value | field |
| ptr | hdr-size | hdr | content \0 |
+-------+-----------------------------+
To distinguish between different representations, we could use the LSB bits in the pointer to it, the pointer stored in the hashtable. (This solution was not chosen in #1579.)
This PR replaces dict with the new hashtable data structure in the HASH
datatype. There is a new struct for hashtable items which contains a
pointer to value sds string and the embedded key sds string. These
values were previously stored in dictEntry. This structure is kept
opaque so we can easily add small value embedding or other optimizations
in the future.
closesvalkey-io#1095
---------
Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: proost <[email protected]>
The new hashtable doesn't have a dict entry, so we need to invent one to hold field and value.
Possibly, we can embed field or value or both. The method used earlier is the function
sdscopytobuffer
and a byte to store the size of the sds header.A field name never changes so it seems safe to always embed the field name, while the value can change and it can be very large so we can allow it to be non-embedded. This is very similar to string keys with the EMBSTR vs RAW encoding.
Idea of layout with both embedded:
Idea of layout with field embedded, value as pointer, stored first to make it aligned. (#1502 simply uses this representation for all field-value pairs.)
To distinguish between different representations, we could use the LSB bits in the pointer to it, the pointer stored in the hashtable. (This solution was not chosen in #1579.)
Another way to indicate different kinds of entries is to use some bits in the sds header of the field. That's the chosen representation in #1579.
The text was updated successfully, but these errors were encountered: