Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-05 Thread Roshan Dawrani
Hi Patricio, Some thoughts inline. 2011/1/6 Patricio Echagüe > Roshan, the first 64 bits does contain the version. The method > UUID.timestamp() indeed takes it out before returning. You are right in that > point. I based my comment on the UUID spec. > I know 64 bits have the version, but time

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-05 Thread Patricio Echagüe
Roshan, the first 64 bits does contain the version. The method UUID.timestamp() indeed takes it out before returning. You are right in that point. I based my comment on the UUID spec. What I am not convinced is that the framework should provide support to create an almost identical UUID where only

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-05 Thread Roshan Dawrani
Hi Patricio, Thanks for your comment. Replying inline. 2011/1/5 Patricio Echagüe > Roshan, just a comment in your solution. The time returned is not a simple > long. It also contains some bits indicating the version. I don't think so. The version bits from the most significant 64 bits of the

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-05 Thread Patricio Echagüe
Roshan, just a comment in your solution. The time returned is not a simple long. It also contains some bits indicating the version. On the other hand, you are assuming that the same machine is processing your request and recreating a UUID base on a long you provide. The clockseqAndNode id will vary

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-05 Thread Nate McCall
It was our original intention on discussing this feature was to have back-and-forth conversion from timestamps (we were modelling similar functionality in Pycassa). It's lack of inclusion may have just been an oversight. We will add this in Hector trunk shortly - thanks for the complete code sample

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Roshan Dawrani
Ok, found the solution - finally ! - by applying opposite of what createTime() does in TimeUUIDUtils. Ideally I would have preferred for this solution to come from Hector API, so I didn't have to be tied to the private createTime() implementation. ==

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Roshan Dawrani
If I use *com.eaio.uuid.UUID* directly, then I am able to do what I need (attached a Java program for the same), but unfortunately I need to deal with *java.util.UUID *in my application and I don't have its equivalent com.eaio.uuid.UUID at the point where I need the timestamp value. Any suggestion

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Roshan Dawrani
Hi Victor / Patricio, I have been using Hector library's TimeUUIDUtils. I also just looked at TimeUUIDUtilsTest also but didn't find anything similar being tested there. Here is what I am trying and it's not working - I am creating a Time UUID, extracting its timestamp value and with that I creat

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Patricio Echagüe
In Hector framework, take a look at TimeUUIDUtils.java You can create a UUID using TimeUUIDUtils.getTimeUUID(long time); or TimeUUIDUtils.getTimeUUID(ClockResolution clock) and later on, TimeUUIDUtils.getTimeFromUUID(..) or just UUID.timestamp(); There are some example in TimeUUIDUtilsTest.jav

Re: Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Roshan Dawrani
Hello Victor, It is actually not that I need the 2 UUIDs to be exactly same - they need to be same timestamp wise. So, what I need is to extract the timestamp portion from a time UUID (say, U1) and then later in the cycle, use the same long timestamp value to re-create a UUID (say, U2) that is eq

Converting a TimeUUID to a long (timestamp) and vice-versa

2011-01-04 Thread Roshan Dawrani
Hi, I am having a little difficulty converting a time UUID to its timestamp equivalent and back. Can someone please help? Here is what I am trying. Is it not the right way to do it? === UUID someUUID = TimeUUIDUtils.getUniqueTimeUUID