get_unique_name() in node_class.R might not be unique
- Dominant language
- C++
- Stars
- 607
- Forks
- 67
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
Perhaps this is not likely to happen, or for this to be an issue, but it seems that the rhex() function as defined isn't gauranteed to create a unique name if there are many many nodes (like 1 million).
This is used in [node_class.R](https://github.com/greta-dev/greta/blob/a07d84fc53f71e87790999c1d8da92ac99ed8659/R/node_class.R#L273).
See example below.
``` r
n_rhex <- 1e6
# generate a random 8-digit hexadecimal string
rhex <- function() paste(as.raw(sample.int(256L, 4, TRUE) - 1L), collapse = "")
many_rhex <- replicate(n = n_rhex, expr = rhex(), simplify = "vector")
dplyr::n_distinct(many_rhex)
#> [1] 999874
dplyr::n_distinct(many_rhex) == n_rhex
#> [1] FALSE
```
Created on 2021-04-08 by the [reprex package](https://reprex.tidyverse.org) (v2.0.0)
Perhaps digest or something like https://github.com/coolbutuseless/xxhashlite could be used to give nodes unique IDs
Contributor guide
Assessment
This issue has not been assessed yet.