Generate single UUID:
::uuid_generate_random()
RcppUUID#> [1] "95a0b90b-46bc-4e16-b41e-cb04bb53aa71"
Generate multiple UUIDs:
::uuid_generate_random(5)
RcppUUID#> [1] "2d5caacd-7123-4072-b66f-74874f0424d9" "3c4f1e13-50af-46ab-a32a-f17cb1842875"
#> [3] "b0c0075d-f1fb-476c-9d27-0dd07c63ddef" "e6992ca8-7b32-45ab-9fa2-e11690c11c35"
#> [5] "4d9fce08-a71d-402f-9fa5-9e38fa136abb"
Check uniques for the uuids:
<- function(x) length(unique(x))
unique_n <- 1000000
n unique_n(RcppUUID::uuid_generate_random(n)) == n
#> [1] TRUE
Benchmarking:
Single UUID:
::microbenchmark(
microbenchmarkuuid = uuid::UUIDgenerate(FALSE),
RcppUUID = RcppUUID::uuid_generate_random()
)#> Unit: microseconds
#> expr min lq mean median uq max neval
#> uuid 3.05 3.165 19.24921 3.28 3.36 1594.021 100
#> RcppUUID 2.04 2.075 2.36520 2.11 2.20 20.280 100
Multiple UUIDs:
<- 10000
n ::microbenchmark(
microbenchmarkuuid = uuid::UUIDgenerate(FALSE, n),
RcppUUID = RcppUUID::uuid_generate_random(n)
)#> Unit: milliseconds
#> expr min lq mean median uq max neval
#> uuid 25.47780 25.98014 29.13786 26.07774 26.19531 199.5827 100
#> RcppUUID 12.76133 13.05205 17.27462 13.46904 13.69007 203.0705 100
Generate version UUIDs based on the text input:
::uuid_generate_name(letters[1:5])
RcppUUID#> [1] "54a0a790-c611-5b5b-b50e-ff01490ecdfa" "d5080e36-1ba4-5cb3-861c-34b25868f7db"
#> [3] "33ed51b6-a330-5830-bda9-2bac09e15753" "b74b2afe-06d5-5fea-99cc-a7de0b492704"
#> [5] "8535136c-b0d3-5373-aa79-ab67d33a2a8e"
For the each unique input will be generated unique UUID. Check uniqueness:
<- replicate(10, RcppUUID::uuid_generate_name(letters))
uuids length(unique(as.vector(uuids))) == length(letters)
#> [1] TRUE
::uuid_validate(NA_character_)
RcppUUID#> [1] FALSE
::uuid_validate("")
RcppUUID#> [1] FALSE
::uuid_validate("not uuid")
RcppUUID#> [1] FALSE
::uuid_validate(RcppUUID::uuid_generate_random(5))
RcppUUID#> [1] TRUE TRUE TRUE TRUE TRUE
::uuid_validate(RcppUUID::uuid_generate_nil(5))
RcppUUID#> [1] TRUE TRUE TRUE TRUE TRUE
::uuid_validate(RcppUUID::uuid_generate_name(letters[1:5]))
RcppUUID#> [1] TRUE TRUE TRUE TRUE TRUE
To install the package from the CRAN run the following command:
install.packages("RcppUUID", repos = "https://cloud.r-project.org/")
Pre-releases can be installed from r-universe via
<- c(ru = 'https://eddelbuettel.r-universe.dev', getOption("repos"))
repos install.packages('RcppUUID', repos = repos)
which provides binaries for several operating systems too.
One can install the development version with the
install_github()
function from the remotes
package:
::install_github("eddelbuettel/rcppuuid") remotes
This package contains the compiled code, therefore one has to use the Rtools to install it on Windows.
Use the following command to go to the page for bug report submissions:
bug.report(package = "RcppUUID")
Before reporting a bug or submitting an issue, please do the following:
news(package = "RcppUUID", Version == packageVersion("RcppUUID"))
command;RcppUUID
package, not from other packages;Please attach traceback() and sessionInfo() output to bug report. It may save a lot of time.
The RcppUUID
package is distributed under GPLv2 license.
The package was written by Artem Klevtsov and maintained in this GitLab repo.
The package in this repository is now maintained by Dirk Eddelbuettel.