kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 1e93fea50873e996e6387ae52f7b19d69b39ac6e8edd3d1a8ea0815d383cdc39 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-02-23 18:15 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-03-31 16:37 +02:00 |
| Parents | 34f2d0656c1d |
2 files changed
modified changelog/README.md +1 −0
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | |
| 7 | 7 | - [improvement] JAVA-1011: Expose PoolingOptions default values. |
| 8 | 8 | - [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections. |
| 9 | +- [improvement] JAVA-851: Improve UUIDs javadoc with regard to user-provided timestamps. | |
| 9 | 10 | |
| 10 | 11 | |
| 11 | 12 | ### 3.0.0 |
modified driver-core/src/main/java/com/datastax/driver/core/utils/UUIDs.java +16 −20
| @@ -141,6 +141,16 @@ | ||
| 141 | 141 | * UUID generated by this method are suitable for use with the |
| 142 | 142 | * {@code timeuuid} Cassandra type. In particular the generated UUID |
| 143 | 143 | * includes the timestamp of its generation. |
| 144 | + * <p/> | |
| 145 | + * Note that there is no way to provide your own timestamp. This is deliberate, as we feel that this does not | |
| 146 | + * conform to the UUID specification, and therefore don't want to encourage it through the API. | |
| 147 | + * If you want to do it anyway, use the following workaround: | |
| 148 | + * <pre> | |
| 149 | + * Random random = new Random(); | |
| 150 | + * UUID uuid = new UUID(UUIDs.startOf(userProvidedTimestamp).getMostSignificantBits(), random.nextLong()); | |
| 151 | + * </pre> | |
| 152 | + * If you simply need to perform a range query on a {@code timeuuid} column, use the "fake" UUID generated by | |
| 153 | + * {@link #startOf(long)} and {@link #endOf(long)}. | |
| 144 | 154 | * |
| 145 | 155 | * @return a new time-based UUID. |
| 146 | 156 | */ |
| @@ -157,14 +167,16 @@ | ||
| 157 | 167 | * <p/> |
| 158 | 168 | * The UUID created by this method <b>are not unique</b> and as such are |
| 159 | 169 | * <b>not</b> suitable for anything else than querying a specific time |
| 160 | - * range. In particular, you should not insert such UUID. | |
| 170 | + * range. In particular, you should not insert such UUID. "True" UUID from | |
| 171 | + * user-provided timestamps are not supported (see {@link #timeBased()} | |
| 172 | + * for more explanations). | |
| 161 | 173 | * <p/> |
| 162 | 174 | * Also, the timestamp to provide as parameter must be a unix timestamp (as |
| 163 | 175 | * returned by {@link System#currentTimeMillis} or {@link java.util.Date#getTime}), |
| 164 | - * not a UUID 100-nanoseconds intervals since 15 October 1582. In other | |
| 176 | + * not a UUID 100-nanoseconds interval since 15 October 1582. In other | |
| 165 | 177 | * words, given a UUID {@code uuid}, you should never do |
| 166 | 178 | * {@code startOf(uuid.timestamp())} but rather |
| 167 | - * {@code startOf(unixTimestamp(uuid.timestamp()))}. | |
| 179 | + * {@code startOf(unixTimestamp(uuid))}. | |
| 168 | 180 | * <p/> |
| 169 | 181 | * Lastly, please note that Cassandra's timeuuid sorting is not compatible |
| 170 | 182 | * with {@link UUID#compareTo} and hence the UUID created by this method |
| @@ -182,23 +194,7 @@ | ||
| 182 | 194 | * Creates a "fake" time-based UUID that sorts as the biggest possible |
| 183 | 195 | * version 1 UUID generated at the provided timestamp. |
| 184 | 196 | * <p/> |
| 185 | - * Such created UUID are useful in queries to select a time range of a | |
| 186 | - * {@code timeuuid} column. | |
| 187 | - * <p/> | |
| 188 | - * The UUID created by this method <b>are not unique</b> and as such are | |
| 189 | - * <b>not</b> suitable for anything else than querying a specific time | |
| 190 | - * range. In particular, you should not insert such UUID. | |
| 191 | - * <p/> | |
| 192 | - * Also, the timestamp to provide as parameter must be a unix timestamp (as | |
| 193 | - * returned by {@link System#currentTimeMillis} or {@link java.util.Date#getTime}), | |
| 194 | - * not a UUID 100-nanoseconds intervals since 15 October 1582. In other | |
| 195 | - * words, given a UUID {@code uuid}, you should never do | |
| 196 | - * {@code startOf(uuid.timestamp())} but rather | |
| 197 | - * {@code startOf(unixTimestamp(uuid.timestamp()))}. | |
| 198 | - * <p/> | |
| 199 | - * Lastly, please note that Cassandra's timeuuid sorting is not compatible | |
| 200 | - * with {@link UUID#compareTo} and hence the UUID created by this method | |
| 201 | - * are not necessarily upper bound for that latter method. | |
| 197 | + * See {@link #startOf(long)} for explanations about the intended usage of such UUID. | |
| 202 | 198 | * |
| 203 | 199 | * @param timestamp the unix timestamp for which the created UUID must be an |
| 204 | 200 | * upper bound. |