Re: TUTORIAL: Generating Unique ID Strings
Re: TUTORIAL: Generating Unique ID Strings
- Subject: Re: TUTORIAL: Generating Unique ID Strings
- From: Jeffrey Oleander <email@hidden>
- Date: Mon, 17 May 2010 09:22:12 -0700 (PDT)
> On Fri, 2010/05/14, Thomas Wetmore <email@hidden> wrote:
> From: Thomas Wetmore <email@hidden>
> Subject: Re: TUTORIAL: Generating Unique ID Strings
> To: "Jens Alfke" <email@hidden>
> Cc: "CocoaDev" <email@hidden>
> Date: Friday, 2010 May 14, 12:30
> I must say that I am constantly
> amused by the nanniness of the Apple discussion lists,
> telling people what is safe and what is dangerous. There is
> nothing dangerous about bit-twiddling code. You test it til
> it works and then it works forever. It doesn't develop bugs
> later. My goal was to use the 128 bits of a UUID and encode
> them for use in genealogical database applications using the
> smallest record id strings possible. My choice was to break
> the 128-bits into 22 6-bit sequences and encode each 6-bit
> sequence as a simple character. This is good, honest, easy
> to write, easy to debug software.
>
> In my application databases can be very large, having
> millions if not billions of records. The goal is that every
> instance of the application, wherever it is being run, will
> generate record ids that are not only unique to itself, but
> to every other instance of the application. In this way
> people can share information with one another knowing with
> assurance that any data imported from a database created by
> another instance of the program will never have id clashes.
> It is not intended that massive numbers of records be
> transferred over the network, though they could be, just
> that data can be shared between databases to any extent with
> no clashes. There are other benefits such a system has for
> genealogical data, but what I have described here is good
> enough.
>
> Tom "danger is my middle name" Wetmore
>> On 2010 May 14, at 13:00, Jens Alfke wrote:
>> (2) If you do need to convert to string, it would be
>> safer to use an existing Base64 converter rather than
>> writing your own as you've done. This kind of bit-twiddling
>> code is very prone to error. Probably the quickest way is to
>> use the Base64 support in the OpenSSL library; a bit of
>> searching in the list archives should turn up some sample
>> code.
>>
>> (3) I'm sort of confused by Thomas Wetmore's comment
>> that "my application generates billions of [unique ids]".
>> That's way too many to be sending over the network, so these
>> must be used locally. But in that case, generating unique
>> IDs becomes much easier, and the IDs a lot smaller: just
>> increment a 32-bit counter.
I'll concur with both.
It's typical for an individual genealogist to collect
records about 3,000 or 4,000 people in their family forest,
and each of those can have hundreds of associated records
(objects) of various types.
But the big progress comes when you can link up with
a base of data created by another researcher, who has
records on several thousand relatives, and so on.
Names don't suffice to uniquely designate an individual
(sometimes not even full-name plus birth-date), and
it's common for a researcher to, unknowingly, have
3 or 5 records for the same individual human being.
The desire is to convert those to aliases, and to use
UUIDs to designate each human. And there are many
other data-items in such information collections
which benefit from universally unique identifiers.
But I agree with Jens that, when well-tested, off-the-
shelf utilities, e.g. for binary to octal or hex or ASCII
or Unicode conversion and back are available, they're
preferable to rolling our own (and I rolled my own such
coder/decoders a couple times before the web existed).
But my memory is that there is already a method in the
UUID framework for such conversions. No need to bring
in external packages, even.
http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFUUIDRef/Reference/reference.html
Functions by Task
Creating CFUUID Objects
CFUUIDCreate
CFUUIDCreateFromString
CFUUIDCreateFromUUIDBytes
CFUUIDCreateWithBytes
Getting Information About CFUUID Objects
CFUUIDCreateString
CFUUIDGetConstantUUIDWithBytes
CFUUIDGetUUIDBytes
Getting the CFUUID Type Identifier
CFUUIDGetTypeID
http://developer.apple.com/mac/library/documentation/Java/Reference/1.5.0/doc/api/java/util/UUID.html
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden