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
I was trying to install a custom comparison function for an unqlite kv store and noticed that the current implementation is pretty limited in that regard:
It's taking only one "length" parameter, which I assume is the minimum length of both keys. This is problematic as one could imagine some comparison functions that need to know both lengths;
It could use an additional void* parameter to pass user-provided data;
I would suggest adding an UNQLITE_KV_CONFIG_CMP2_FUNC key for unqlite_kv_config(), accepting two arguments:
a comparison function with signature int (*xCmp)(const void*, const void*, unsigned int, unsigned int, void*);
a void* context for user-provided data (which will be passed as last argument to the comparison function whenever it is called).
The text was updated successfully, but these errors were encountered:
Note however that the comparison function works only with binary blobs and not nil terminated strings. This is why the signature looks like memcmp() or bzero() of the C standard library.
Actually I wonder how unqlite distinguished a key and a prefix of that key, right now? Unless unqlite checks if the sizes are different outside of the comparison function and implicitly assumes, should the comparison return 0, that the shortest key is lower? (Which isn't necessarily a good assumption outside of lexicographical order)
I was trying to install a custom comparison function for an unqlite kv store and noticed that the current implementation is pretty limited in that regard:
void*
parameter to pass user-provided data;I would suggest adding an
UNQLITE_KV_CONFIG_CMP2_FUNC
key forunqlite_kv_config()
, accepting two arguments:int (*xCmp)(const void*, const void*, unsigned int, unsigned int, void*)
;The text was updated successfully, but these errors were encountered: