uuid

How big is the chance to get a Java UUID.randomUUID collision? [duplicate]

大城市里の小女人 提交于 2019-11-27 14:20:15
问题 This question already has answers here : How good is Java's UUID.randomUUID? (10 answers) Closed 5 years ago . I need to create some uniques files in Java and i plan to use UUID.randomUUID to generate their names. Is there any chance to get a collision for this? Should i do something like bellow os I shouldn't worry about this? Integer attemptsToGenerateUUID = 1; while (true) { UUID fileUUID = UUID.randomUUID(); if (fileDoesNotExistwith this UUID name) { save file; break; }

Is there a 128 bit integer in C++?

微笑、不失礼 提交于 2019-11-27 13:50:54
I need to store a 128 bits long UUID in a variable. Is there a 128-bit datatype in C++? I do not need arithmetic operations, I just want to easily store and read the value very fast. A new feature from C++11 would be fine, too. GCC and Clang support __int128 Patrik Beck Checkout boost's implementation : #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; int128_t v = 1; This is better than strings and arrays, especially if you need to do arithmetic operations with it. Although GCC does provide __int128 , it is supported only for targets (processors) which have an

How to generate a GUID in VBScript?

99封情书 提交于 2019-11-27 12:01:42
问题 I want to generate GUID strings in VBScript. I know that there's no built-in function in VBScript for generating one. I don't want to use random-generated GUIDs. Maybe there is an ActiveX object that can be created using CreateObject() that is sure to be installed on (newer) Windows versions that can generate a GUID? 回答1: How Can I Create a GUID Using a Script? (in: Hey, Scripting Guy! Blog) says this: Set TypeLib = CreateObject("Scriptlet.TypeLib") Wscript.Echo TypeLib.Guid However, note

Creating a UUID from a string with no dashes

自闭症网瘾萝莉.ら 提交于 2019-11-27 11:27:14
How would I create a java.util.UUID from a string with no dashes? "5231b533ba17478798a3f2df37de2aD7" => #uuid "5231b533-ba17-4787-98a3-f2df37de2aD7" Clojure's #uuid tagged literal is a pass-through to java.util.UUID/fromString . And, fromString splits it by the "-" and converts it into two Long values. (The format for UUID is standardized to 8-4-4-4-12 hex digits, but the "-" are really only there for validation and visual identification.) The straight forward solution is to reinsert the "-" and use java.util.UUID/fromString . (defn uuid-from-string [data] (java.util.UUID/fromString (clojure

Mysql基于GTID主从复制

一曲冷凌霜 提交于 2019-11-27 11:13:54
Mysql5.6基于GTID全局事务的复制 什么是 GTID ?   GTID(Global Transaction Identifiers)是全局事务标识 当使用GTIDS时,在主上提交的每一个事务都会被识别和跟踪,并且运用到所有从MySQL,而且配置主从或者主从切换时不再需要指定 master_log_files和master_log_pos;由于GTID-base复制是完全基于事务的,所以能很简单的决定主从复制的一致性; 官方建议Binlog采用Row格式 MySQL 5.1.12 开始,可以用以下三种模式来实现: 基于SQL语句的复制(statement-based replication, SBR), 基于行的复制(row-based replication, RBR), 混合模式复制(mixed-based replication, MBR)。 相应地,binlog的格式也有三种:STATEMENT,ROW,MIXED。 MBR 模式中,SBR 模式是默认的。 基于混合模式的复制:它是根据事件的类型实时的改变binlog的格式。当设置为混合模式时,默认为基于语句的格式,但在特定的情况下它会自动的转变为基于行的模式。 SBR 的优点: 历史悠久,技术成熟 binlog文件较小 binlog中包含了所有数据 库更改信息,可以据此来审核数据库的安全等情况

Platform-independent GUID generation in C++?

浪子不回头ぞ 提交于 2019-11-27 11:11:44
What is the best way to programmatically generate a GUID or UUID in C++ without relying on a platform-specific tool? I am trying to make unique identifiers for objects in a simulation, but can't rely on Microsoft's implementation as the project is cross-platform. Notes: Since this is for a simulator, I don't really need cryptographic randomness. It would be best if this is a 32 bit number. Anonymous If you can afford to use Boost, then there is a UUID library that should do the trick. It's very straightforward to use - check the documentation and this answer . on linux: man uuid on win: check

How to efficient insert and fetch UUID in Core Data

半世苍凉 提交于 2019-11-27 10:56:28
问题 I am looking for an efficient way to store and search UUID in Core Data. Those UUID are generated by many iOS devices in a distributed system. Each of those devices may store about 20-50k UUIDs. It is obvious that storing UUID as String in Core Data will hurt the efficiency of indexing on it. But after a series of research I found that storing UUID as Binary Data in Core Data (and index it) may be less efficient than storing it as String . As there is no BINARY-like or VARBINARY-like data

Using a UUID as a primary key in Django models (generic relations impact)

落花浮王杯 提交于 2019-11-27 10:46:38
For a number of reasons^, I'd like to use a UUID as a primary key in some of my Django models. If I do so, will I still be able to use outside apps like "contrib.comments", "django-voting" or "django-tagging" which use generic relations via ContentType? Using "django-voting" as an example, the Vote model looks like this: class Vote(models.Model): user = models.ForeignKey(User) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() object = generic.GenericForeignKey('content_type', 'object_id') vote = models.SmallIntegerField(choices=SCORES) This app seems to be

Storing UUID as base64 String

我们两清 提交于 2019-11-27 10:12:32
I have been experimenting with using UUIDs as database keys. I want to take up the least amount of bytes as possible, while still keeping the UUID representation human readable. I think that I have gotten it down to 22 bytes using base64 and removing some trailing "==" that seem to be unnecessary to store for my purposes. Are there any flaws with this approach? Basically my test code does a bunch of conversions to get the UUID down to a 22 byte String, then converts it back into a UUID. import java.io.IOException; import java.util.UUID; public class UUIDTest { public static void main(String[]

How can I use UUIDs in SQLAlchemy?

我与影子孤独终老i 提交于 2019-11-27 09:19:35
问题 Is there a way to define a column (primary key) as a UUID in SQLAlchemy if using PostgreSQL (Postgres)? 回答1: The sqlalchemy postgres dialect supports UUID columns. This is easy (and the question is specifically postgres) -- I don't understand why the other answers are all so complicated. Here is an example: from sqlalchemy.dialects.postgresql import UUID from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Foo(db.Model): id = db.Column(db.Integer, primary_key=True) uuid = db.Column