New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YCQL] comparable TIMEUUID #801
Comments
@patrick-li A So it will be sorted as you expect on a clustering key, and it is also possible (but see details below) to "compare" with a timestamp value. For the latter use-case, one must be careful though since multiple timeuuids can have the same timestamp value and then they will be compared by the clock/node component.
Also see this comment for some more details. Also, just to note since you mentioned them, |
@m-iancu , thanks for quick response and reminding. You may update your online docs 'API Reference/YCQL/UUID & TIMEUUID'. |
'minTimeuuid()' looks like what I want ? TIMEUUID = minTimeuuid() ? |
Will twice call 'minTimeuuid()' return same TIMEUUID? |
@patrick-li Yes calling
If I understand correctly, you needs something like the function |
I forked off this sub-issue into its own issue (#802), as a separate enhancement request. |
no, not current time. but an existing timestamp like '2019-01-24T05:26:51.123' |
I guess my requirement may break the TIMEUUID uniqueness. the length of the TIMEUUID is longer/stronger enough for a specific timestamp, no duplicate TIMEUUID can be generated or most likely. if there is a constructor with a timestamp, sometime the TIMEUUID will be duplicate. OK. Thank you guys. |
hi @patrick-li a) I think it is possible for us to implement a builtin function/constructor for timeuuid which takes a timestamp and returns a unique timeuuid whose timestamp component is the specified timestamp. It is just that we don't have such a built-in yet. Hence, filed #802 as an enhancement request. I couldn't find anything in JDK 8 also where you could do the same in the application and insert as a timeuuid into the database. b) In the interim, want to understand your requirement better. Suppose your table is:
and assume we had a builtin So the question is, do you want:
to end up with 2 rows or 1 row (where the second one overwrites the first row because the primary key matches)? I am guessing you want the above to end up as two different rows, correct? |
Yes, exactly. Sometime, id1 + id2 + timestamp got to be duplicate. then missing record(s), only the last one saved. I wrote a local one = timestamp(UTC number) * 100 + random() * 100. if TIMEUUID works, that's the best. |
How about this instead, where you use a 2-part clustering column based on a timestamp (ts) and uuid (rand_uuid). See example below. You could bind in a application generated uuid (using Java) as the tie-breaker for the rand_uuid column. [You could also use timeuuid type instead for rand_uuid column and use now() as the tiebreaker.]
But your queries wouldn't have to care about the rand_uuid column. They could simply be like:
|
cool. let me have a try. |
Jira Link: DB-4712
There is a data type
TIMEUUID
. and two functionstotimestamp()
andtounixtimestamp
. it acts like an unique timestamp.My question is whether it can be sorted/order by, >='2019-01-24T05:26:51' , <= '2019-01-24T05:26:51', or as clustering key.
Thanks.
The text was updated successfully, but these errors were encountered: