-
Notifications
You must be signed in to change notification settings - Fork 8
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
support for Buffers (keys and values) #2
Comments
If you have only Buffer-keys, not much, no algorithms need changing at all (especially if they are fixed-size)
Globally, it should be also much faster, since Node can handle the conversion from Uint16 to Buffer internally using only the C++ code. Instead of copying element per element, you can do _decodeKey(pos) {
return this.keysData.slice(pos * this.meta[META.keySize],
(pos+1) * this.meta[META.keySize)).buffer;
} The Uint16Array internal buffer property is what you need. You have to use .slice, uou can't use the faster .subarray because you need to copy the subarray, otherwise .buffer will return the whole array. If you need both Buffer-keys and String-keys, you will need an extra field to recognize them and some extra code to return either Buffer either String |
Thanks. I'll give it a try. |
Was there any work done on this? I have a need for a shared hashmap that uses buffers for keys and values of fixed size. |
How much work would it be to add support for Buffers? I have 128-bit keys and would expect 37.5% efficiency encoding their base64 representation to UTF-16 (and don't have a base16k implementation).
I'd be happy to try it myself but would appreciate some warning if most of the code would require rewriting. Thank you.
The text was updated successfully, but these errors were encountered: