[uuid] sequential_generator / comb_generator / utc_generator / timestamp_generator
For personal use, I've created a few generators that create sequential and time-based uuids. However there does not seem to be a single standard for these kinds of algorithms. While tidying up this code, I've run into some obstacles with generalization of the logic. Although some applications like SQL Server will use GUIDs and lexicographically compare based on the least significant bytes of Data4 for boost::uuids' purposes we can simply assume a block of 16 bytes. The generic approach is to combine (basic_comb_generator) a number of bytes from a sequential source, filling the rest of the bytes with random data. What concerns me is the choice of source and the number of bytes to use. And additionally the value which specifies the variant / version. The usual choices seem to be 8 or 6 bytes. The source is also usually UTC Unix time. However the original uuid version used nanosecond intervals and the MAC address. Am I worrying too much about extensibility? As it is now my basic_comb_generator has a template param for a source, a number of bytes of the source to use, and a UniformRandomNumberGenerator to fill the rest. Since resolution may be a second if using Unix time they may not be consistently sequential but generally so, hence my hesitation to name the generator typedef as sequential. Of course it is possible to use even higher resolution. I suppose I am gauging interest in this feature, as well as asking if there are any thoughts or suggestions on how others would likely use this, and alternative or standard algorithms defined. Once I have some feedback I intend to complete the code and bounce it back on here for any further comments before lobbying to include anything within the library. It seems like commonly needed functionality at least! Nilsson article here for SQL Server: http://www.informit.com/articles/article.aspx?p=25862&seqNum=7 CouchDB's uuid generation algorithms: https://wiki.apache.org/couchdb/HttpGetUuids
On Thu, Mar 6, 2014 at 1:08 AM, Adam Walling
I suppose I am gauging interest in this feature, as well as asking if there are any thoughts or suggestions on how others would likely use this, and alternative or standard algorithms defined.
I've been using something like that: An "id" type which internally uses uuid by default, but in some conditions I can make it use a sequential id. Most of the time the reason is helping with debugging (as sequential ids, depending on the source, can help understand what happened in a sequence of events). However, I never thought about mixing both with the same interface than uuid. So I'm interested in taking a look at how your extension works.
participants (2)
-
Adam Walling
-
Klaim - Joël Lamotte