[Insight-developers] Patch for gdcm::Util::CreateUniqueUID

Henning Meyer tutmann at gmail.com
Thu Apr 24 06:46:37 EDT 2008


I think the duplicate problem is caused by another reason.
I use only one thread, but if I call rand() often enough in the same
milisecond I have quite high chances of getting two numbers with the
same two ending digits (the implementation clipped it to two digits).
For two numbers in a milisecond chances are 1/100 (I exported about
6000 slices, so I had this problem quite a few times).

I'm still not sure, whether FNV is the right hashing algorithm for
this purpose, I just found it to be quite fast by browsing through
wikipedia :-).

Henning


2008/4/24, Mathieu Malaterre <mathieu.malaterre at gmail.com>:
> Hi Henning,
>
>   Thanks a bunch for your patch, it is very well written. You are
>  using the WIN32 api but hopefully it should be fairly easy to port to
>  POSIX system. I really like your implementation using the threadid
>  instead of a random number. I believe I now understand why you could
>  get duplicate keys: start two thread and start two gdcm, with a little
>  of bad luck the c-function rand() will return *exactly* the same
>  number. So on the same physical machine at the same millisecond, the
>  two keys would be the same :( Same goes for processid.
>   So yes it will definitely goes into gdcm CVS, just give me some time
>  to fix the 'long long' issue  (this is not portable) and the
>  WIN32-specific function which I need to find POSIX equivalents for.
>
>  Thanks again !
>  -Mathieu
>
>
>  On Mon, Apr 21, 2008 at 3:08 PM, Henning Meyer <tutmann at gmail.com> wrote:
>  > Hello All,
>  >
>  >  I wrote a small Patch for gdcm::Util::CreateUniqueUID, because with my
>  >  setup I had UID-Clashes under Windows from time to time.
>  >  I think its a good idea to use a Counter instead of a two-digit random
>  >  number and also to include thread-id or process-id.
>  >  I hope I won't offend you to much by not using the version control,
>  >  but this seemed easiest.
>  >  I hope you like it and include it to the repository.
>  >
>  >  Thank you,
>  >
>  >  Henning
>  >
>
> > _______________________________________________
>  >  Insight-developers mailing list
>  >  Insight-developers at itk.org
>  >  http://www.itk.org/mailman/listinfo/insight-developers
>  >
>  >
>
>
>
>  --
>
> Mathieu
>


More information about the Insight-developers mailing list