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
Assign two keys/namespaces to the same value without duplicating effort #56
Comments
This seems like a reasonable thing to support - the lower level bits will all be there. Just need to think about the interface. If you could describe your ideal interface that would be useful (along with a verb). Perhaps duplicate = function(key_src, key_dest, namespace_src = self$default_namespace, namespace_dest = self$default_namespace) ... |
It would also be helpful to pass multiple namespaces to the |
How about I would also suggest the following default arguments. alias <- function(
key_src,
key_dest = key_src,
namespace_src = self$default_namespace,
namespace_dest = namespace_src
){
...
} |
Some preliminary work here: https://github.com/richfitz/storr/compare/i56_duplicate I've gone with
You can with |
Looks like the right idea. The default arguments of I do see now that x <- storr_rds("test")
x$mset(key = "a", value = 1, namespace = c("n1", "n2"))
## Error: 'value' must have 2 elements (recieved 1)
x$mset(key = "a", value = 1:2, namespace = c("n1", "n2")) # No error I would like to assign the same data to the same key over multiple namespaces without duplicating the (potentially large) data. |
I see. The restriction that The value will never actually be duplicated, even in R. Because of R's copy-on-write semantics,
only one copy of |
Hmm... I wish there were a way to avoid recycling altogether. As you say, the rehashing is slow, and the data is duplicated in memory before it is stored once. |
Please check the new "fill" method on the i56_duplicate branch - this will hopefully do what you need |
Thanks, Rich! I dug through it, and it does exactly what I want. I also think the term |
Is this possible without recaching, resaving, rehashing, reserializing? I can think of a hack:
## TRUE
But I do not know if this is the right thing to do because it involves manually mucking around with the hash. Please let me know if further abstraction is already supported, planned for future development, or beyond the scope of
storr
.The text was updated successfully, but these errors were encountered: