-
Notifications
You must be signed in to change notification settings - Fork 24
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
Types design #17
Comments
Storing |
In addition, |
But isn't it the case that the keys are usually non-fixed-length? My use case involves storing (small number of) different strings and finding/inserting (if new) them frequently (like 1 mil rps). I really don't want to clone key on every request, and I cannot pass string ownership to |
Now imagine if
This would allow me pass |
It does not ring true for me that cloning the string is necessary. It's been a while since I looked at this code but |
I could pass reference (instantiate |
Ok so maybe example:
This currently won't work because lifetimes of two references will not match. It would not be a problem if the function |
Mm, I see your problem. This does not need to be solved by removing the I don't remember if there's a reason I didn't implement it this way. It may have been an oversight, or caused other issues with types. Will try to take a look tonight and see if I can figure it out. |
If these keys will never be removed, and it is acceptable to keep their memory for the lifetime of your binary, I believe there are libraries which can be used to intentionally leak memory, getting you an |
Thanks for having a look at the issue. However considering I want to avoid copying the keys because of high intensity of requests, I dont think leaking the keys memory forever is a solution for me =) |
Why should the Trie itself be parameterized over key type? Currently both having
K
as type parameter and needing it passed as owned toinsert
and (especially) toentry
pretty much forces us to make copy of key for each invocation. I think we only need key when first inserting into the trie, which could be better achieved withToOwned
(btw this comment makes sense for me:qp-trie-rs/src/node.rs
Line 245 in 91507d5
insert
andentry
would requireBorrow
+ToOwned
and would clone only when really necessary.Then if we stored
[u8]
in some form in node and parameterize functions likeinsert
andentry
themselves which would allow passing them&'a [u8]
with different'a
which is currently impossible.The text was updated successfully, but these errors were encountered: