Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic
Checking for uniqueness within the database is good, like Geert suggested. If you want to make them unique across databases and servers assign each database and each server a unique prefix and prepend that to your "local" unique id. That will guarantee that it is unique across your platform. This is actually a common pattern used by credit card providers, the first four digits of your credit card are unique to your provider the remaining digits are semi-random but unique to your card. That way they can guaranteed uniqueness across providers without the synchronization card numbers issued across organizations. Enjoy. Keith On Tue, Feb 13, 2018 at 7:53 AM, Geert Josten <geert.jos...@marklogic.com> wrote: > Hi Abhinav, > > sem:uuid-string() generates a 123-bit size random string, which makes > changes on collisions extremely rare. If you prefer being paranoid, and > want to check anyhow (there are various ways tocheck if an id or uri is > taken or not), you’d typically do that in one database only. You could also > do it across multiple databases, but the more you check and include, the > slower it obviously gets. > > There are some brief notes on this topic in the README of my ml-unique > library: https://github.com/grtjn/ml-unique > > Cheers, > Geert > > From: <general-boun...@developer.marklogic.com> on behalf of " > abhinav.mish...@cognizant.com" <abhinav.mish...@cognizant.com> > Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com> > Date: Tuesday, February 13, 2018 at 9:39 AM > To: "general@developer.marklogic.com" <general@developer.marklogic.com> > > Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic > > Hi Geert, > > > Thank you for your response. > > > I guess it is just something we are wondering about. If we changed Servers > or hardware, would there be a chance for duplicates. There is no other > specific reason though. > > > Regards, > > Abhinav > -- > *From:* general-boun...@developer.marklogic.com < > general-boun...@developer.marklogic.com> on behalf of Geert Josten < > geert.jos...@marklogic.com> > *Sent:* Tuesday, February 13, 2018 8:55 AM > *To:* MarkLogic Developer Discussion; general-request@developer. > marklogic.com > *Subject:* Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic > > Hi Abhinav, > > Can you elaborate on what you mean with ‘unique across environments’? > > Cheers, > Geert > > From: <general-boun...@developer.marklogic.com> on behalf of abhinav > mishra <abhinavmishr...@gmail.com> > Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com> > Date: Tuesday, February 13, 2018 at 8:40 AM > To: "general-requ...@developer.marklogic.com" <general-request@developer. > marklogic.com>, "general@developer.marklogic.com" < > general@developer.marklogic.com> > Subject: [MarkLogic Dev General] Unique GUID generation in MarkLogic > > Hi All, > > We are exploring ways to generate GUIDs. We just want to be sure that the > GUIDs are unique always and we have a requirement that these GUIDs should > be even unique across environments. There should not be same GUID in two > MarkLogic environments > > We found sem:uuid-string() function from documentation and seems like a > good point to start with. However we are not sure if this method returns > unique across environments. > > Can someone guide or provide more information on GUID generation, any > third party open source library which we can use. > > Regards, > Abhinav > -- > Sent from my iPhone > This e-mail and any files transmitted with it are for the sole use of the > intended recipient(s) and may contain confidential and privileged > information. If you are not the intended recipient(s), please reply to the > sender and destroy all copies of the original message. Any unauthorized > review, use, disclosure, dissemination, forwarding, printing or copying of > this email, and/or any action taken in reliance on the contents of this > e-mail is strictly prohibited and may be unlawful. Where permitted by > applicable law, this e-mail and other e-mail communications sent to and > from Cognizant e-mail addresses may be monitored. > > ___ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > > -- Keith "Do what you can, with what you have, where you are." - Theodore Roosevelt ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic
Thank You Geert. We will go through your library as well. Regards Abhinav From: general-boun...@developer.marklogic.com <general-boun...@developer.marklogic.com> on behalf of Geert Josten <geert.jos...@marklogic.com> Sent: Tuesday, February 13, 2018 9:53 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Abhinav, sem:uuid-string() generates a 123-bit size random string, which makes changes on collisions extremely rare. If you prefer being paranoid, and want to check anyhow (there are various ways tocheck if an id or uri is taken or not), you’d typically do that in one database only. You could also do it across multiple databases, but the more you check and include, the slower it obviously gets. There are some brief notes on this topic in the README of my ml-unique library: https://github.com/grtjn/ml-unique [https://avatars2.githubusercontent.com/u/611397?s=400=4]<https://github.com/grtjn/ml-unique> GitHub - grtjn/ml-unique: MarkLogic library for generating ...<https://github.com/grtjn/ml-unique> github.com ml-unique - MarkLogic library for generating unique database URIs and IDs Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of "abhinav.mish...@cognizant.com<mailto:abhinav.mish...@cognizant.com>" <abhinav.mish...@cognizant.com<mailto:abhinav.mish...@cognizant.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 9:39 AM To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Geert, Thank you for your response. I guess it is just something we are wondering about. If we changed Servers or hardware, would there be a chance for duplicates. There is no other specific reason though. Regards, Abhinav From: general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Geert Josten <geert.jos...@marklogic.com<mailto:geert.jos...@marklogic.com>> Sent: Tuesday, February 13, 2018 8:55 AM To: MarkLogic Developer Discussion; general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com> Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Abhinav, Can you elaborate on what you mean with ‘unique across environments’? Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of abhinav mishra <abhinavmishr...@gmail.com<mailto:abhinavmishr...@gmail.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 8:40 AM To: "general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>" <general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>>, "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi All, We are exploring ways to generate GUIDs. We just want to be sure that the GUIDs are unique always and we have a requirement that these GUIDs should be even unique across environments. There should not be same GUID in two MarkLogic environments We found sem:uuid-string() function from documentation and seems like a good point to start with. However we are not sure if this method returns unique across environments. Can someone guide or provide more information on GUID generation, any third party open source library which we can use. Regards, Abhinav -- Sent from my iPhone This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored. This e-mail and
Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic
Hi Abhinav, sem:uuid-string() generates a 123-bit size random string, which makes changes on collisions extremely rare. If you prefer being paranoid, and want to check anyhow (there are various ways tocheck if an id or uri is taken or not), you’d typically do that in one database only. You could also do it across multiple databases, but the more you check and include, the slower it obviously gets. There are some brief notes on this topic in the README of my ml-unique library: https://github.com/grtjn/ml-unique Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of "abhinav.mish...@cognizant.com<mailto:abhinav.mish...@cognizant.com>" <abhinav.mish...@cognizant.com<mailto:abhinav.mish...@cognizant.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 9:39 AM To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Geert, Thank you for your response. I guess it is just something we are wondering about. If we changed Servers or hardware, would there be a chance for duplicates. There is no other specific reason though. Regards, Abhinav From: general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Geert Josten <geert.jos...@marklogic.com<mailto:geert.jos...@marklogic.com>> Sent: Tuesday, February 13, 2018 8:55 AM To: MarkLogic Developer Discussion; general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com> Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Abhinav, Can you elaborate on what you mean with ‘unique across environments’? Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of abhinav mishra <abhinavmishr...@gmail.com<mailto:abhinavmishr...@gmail.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 8:40 AM To: "general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>" <general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>>, "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi All, We are exploring ways to generate GUIDs. We just want to be sure that the GUIDs are unique always and we have a requirement that these GUIDs should be even unique across environments. There should not be same GUID in two MarkLogic environments We found sem:uuid-string() function from documentation and seems like a good point to start with. However we are not sure if this method returns unique across environments. Can someone guide or provide more information on GUID generation, any third party open source library which we can use. Regards, Abhinav -- Sent from my iPhone This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored. ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic
Hi Geert, Thank you for your response. I guess it is just something we are wondering about. If we changed Servers or hardware, would there be a chance for duplicates. There is no other specific reason though. Regards, Abhinav From: general-boun...@developer.marklogic.com <general-boun...@developer.marklogic.com> on behalf of Geert Josten <geert.jos...@marklogic.com> Sent: Tuesday, February 13, 2018 8:55 AM To: MarkLogic Developer Discussion; general-requ...@developer.marklogic.com Subject: Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi Abhinav, Can you elaborate on what you mean with ‘unique across environments’? Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of abhinav mishra <abhinavmishr...@gmail.com<mailto:abhinavmishr...@gmail.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 8:40 AM To: "general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>" <general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>>, "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi All, We are exploring ways to generate GUIDs. We just want to be sure that the GUIDs are unique always and we have a requirement that these GUIDs should be even unique across environments. There should not be same GUID in two MarkLogic environments We found sem:uuid-string() function from documentation and seems like a good point to start with. However we are not sure if this method returns unique across environments. Can someone guide or provide more information on GUID generation, any third party open source library which we can use. Regards, Abhinav -- Sent from my iPhone This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored. ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] Unique GUID generation in MarkLogic
Hi Abhinav, Can you elaborate on what you mean with ‘unique across environments’? Cheers, Geert From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of abhinav mishra <abhinavmishr...@gmail.com<mailto:abhinavmishr...@gmail.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Tuesday, February 13, 2018 at 8:40 AM To: "general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>" <general-requ...@developer.marklogic.com<mailto:general-requ...@developer.marklogic.com>>, "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: [MarkLogic Dev General] Unique GUID generation in MarkLogic Hi All, We are exploring ways to generate GUIDs. We just want to be sure that the GUIDs are unique always and we have a requirement that these GUIDs should be even unique across environments. There should not be same GUID in two MarkLogic environments We found sem:uuid-string() function from documentation and seems like a good point to start with. However we are not sure if this method returns unique across environments. Can someone guide or provide more information on GUID generation, any third party open source library which we can use. Regards, Abhinav -- Sent from my iPhone ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
[MarkLogic Dev General] Unique GUID generation in MarkLogic
Hi All, We are exploring ways to generate GUIDs. We just want to be sure that the GUIDs are unique always and we have a requirement that these GUIDs should be even unique across environments. There should not be same GUID in two MarkLogic environments We found sem:uuid-string() function from documentation and seems like a good point to start with. However we are not sure if this method returns unique across environments. Can someone guide or provide more information on GUID generation, any third party open source library which we can use. Regards, Abhinav -- Sent from my iPhone ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general