datafaker icon indicating copy to clipboard operation
datafaker copied to clipboard

Generator of unique values for file based generators

Open snuyanzin opened this issue 3 years ago • 0 comments

After thinking about https://github.com/datafaker-net/datafaker/issues/232 I came to the idea which potentially should work without issues mentioned in https://github.com/datafaker-net/datafaker/issues/232 however with the assumption that we consider only bounded set of values like data from files, enums

During resolution of provider in net.datafaker.service.FakeValuesService#safeFetch it retrieves a list of possible values and then picks a random. So the idea is keeping track of retrieved values each time removing picked one. So, it means we should not retrieve it each time. Since each time we remove the one which was already generated then we guarantee that we have only those which are allowed to be generated. So there is no need to do multiple retries. Once we generate all unique values we could throw an exception

Also the downside is that it requires deep dive into core implementation and probably will consume time to implement

snuyanzin avatar Jul 30 '22 19:07 snuyanzin