Dirk Eddelbuettel: ulid 0.4.0 on CRAN: Extended to Milliseconds
A new version of the ulid package is
now on CRAN. The packages
provides universally (unique) lexicographically (sortable) identifiers
see the spec at GitHub for
details on those which offer sorting which uuids lack. The R package
provides access via the standard C++ library, had been put together by
Bob Rudis and is now maintained by me.
Mark Heckmann noticed
that a ulid round trip of generating and unmarshalling swallowed
subsecond informationm and posted on a well-known site I no longer go
to. Duncan Murdoch was kind
enough to open
an issue to make me aware, and in it included the nice minimally
complete verifiable example by Mark.
It turns out that this issue was known, documented upstream in two
issues and fixed in fork
by the authors of those issues, Chris Bove. It replaces
time_t as the value of record (constrained at the second
resolution) with a proper std::chrono object which offers
milliseconds (and much more, yay Modern C++). So I switched the two main
files of library to his, and updated the wrapper code to interface from
POSIXct to std::chrono object. And with that
we are in business. The original example of five ulids create 100
millisecond part, then unmarshalled and here printed as a
data.table as data.frame by default truncates
to seconds:
> library(ulid)
> gen_ulid <- \(sleep) replicate(5, Sys.sleep(sleep); generate() )
> u <- gen_ulid(.1)
> df <- unmarshal(u)
> data.table::data.table(df)
ts rnd
<POSc> <char>
1: 2024-05-30 16:38:28.588 CSQAJBPNX75R0G5A
2: 2024-05-30 16:38:28.688 XZX0TREDHD6PC1YR
3: 2024-05-30 16:38:28.789 0YK9GKZVTED27QMK
4: 2024-05-30 16:38:28.890 SC3M3G6KGPH7S50S
5: 2024-05-30 16:38:28.990 TSKCBWJ3TEKCPBY0
>Courtesy of my CRANberries, there is also a diffstat report for this release. If you like this or other open-source work I do, you can sponsor me at GitHub.Changes in version 0.4.0 (2024-06-03)
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
The twentyfirst release of
The key idea of
This version mostly just updates to the newest releases of