TimeUUID in future

34 views
Skip to first unread message

Malte

unread,
Jul 25, 2016, 5:03:39 AM7/25/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi there,

We are using timeseries for a table and would like to set the TimeUUID column to a point of time in future. There we cannot use UUIDs.now().

Is there any way to generate a UUID where the timestamp is in future?

All the best,

Malte

Kevin Gallardo

unread,
Jul 25, 2016, 5:41:25 AM7/25/16
to java-dri...@lists.datastax.com
Hi, 

Providing your own timestamp to generate a UUID is deliberately not something provided by the driver. 
However, there is a workaround for providing a timestamp to generate a UUID explained here : http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/utils/UUIDs.html#timeBased--.

There are a few utility methods in the driver's UUIDs class to help dealing with UUIDs. There are methods like UUIDs#startOf() and UUIDs#endOf() that accept a timestamp, but please note that those are not suitable for inserting UUID data in Cassandra, they are valid only for range queries on UUID columns.

Cheers.

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.



--
Kévin Gallardo.
Software Engineer in Drivers and Tools Team, at DataStax.

Reply all
Reply to author
Forward
0 new messages