For the moment to generate random data for testing I stream my data, then I shuffle the stream and take the first n elements. But I was thinking about storing the data in a local lightweight key/value store. Is there one that allows to shuffle the key in the cache or at a low level? Is there another way to do this? My goal is to have a low level function that generates random samples in a fairly unbiased manner without taking too much memory.
Asked
Active
Viewed 59 times
0
-
What do you mean with "shuffle the key in the cache"? – Ben May 15 '18 at 14:54
-
Maybe this can help you: https://stackoverflow.com/questions/6017338/how-do-you-shuffle-elements-in-a-map – Ehler May 15 '18 at 14:55
-
If you really want more than just a `HashMap`, you can for example try redis and https://redis.io/commands/randomkey or sth based on https://redis.io/commands/srandmember – zapl May 15 '18 at 15:03
-
@Ben I meant to shuffle them as soon as I access them. I don't even know whether I want to put a cache in between just making some hypotheses. – FluidCode May 15 '18 at 15:27
-
@Zapl Thank you. I'll try it, that maybe the answer I was looking for. – FluidCode May 15 '18 at 15:30