Commit 263f09d
authored
Make
* Make Uuids use ThreadLocalRandom
Before this commit `Uuids` used to initiate `Random `at the point when it needs
a random number.
Not only it is not effecient it also produced bad distribution which
resulted in `should_generate_unique_random_uuids_Random` to fail, due to
inability of `Uuids::random `generate unique vales.
* Fix `Uuids.random` to get better distribution
Before this commit it used `random.nextBytes` which made it generate an `int`
and crop it to `byte`, since it is quasi random, it produces bad
distribution and lead to have more UUID collisions.Uuids have better random distribution (#494)1 parent 2a62541 commit 263f09d
File tree
1 file changed
+10
-3
lines changed- core/src/main/java/com/datastax/oss/driver/api/core/uuid
1 file changed
+10
-3
lines changedLines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
235 | | - | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| |||
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
284 | | - | |
| 285 | + | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
| |||
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
303 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
304 | 311 | | |
305 | 312 | | |
306 | 313 | | |
| |||
0 commit comments