Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Cassandra terminology, what is TimeUUID?

Tags:

In Cassandra terminology, what is TimeUUID and when is it used?

like image 863
knorv Avatar asked Apr 10 '10 17:04

knorv


People also ask

What is Timeuuid in Cassandra?

TIMEUUID is a universal unique identifier variant that includes time information.

What is UUID data type in Cassandra?

The UUID (universally unique id) comparator type for avoiding collisions in column names. The UUID (universally unique id) comparator type is used to avoid collisions in column names. Alternatively, you can use the timeuuid. Timeuuid types can be entered as integers for CQL input.


2 Answers

TimeUUID is a random global unique identifier. 16 bytes.

Sample hex presentation: a4a70900-24e1-11df-8924-001ff3591711

See http://en.wikipedia.org/wiki/Universally_Unique_Identifier

It may serve as a primary key in terms of relational database or when you need to store a list of values under some key.

For example check this open source twitter example based on cassandra:

http://twissandra.com/

http://github.com/ericflo/twissandra

User = {     'a4a70900-24e1-11df-8924-001ff3591711': {         'id': 'a4a70900-24e1-11df-8924-001ff3591711',         'username': 'ericflo',         'password': '****',     }, }  Username = {     'ericflo': {         'id': 'a4a70900-24e1-11df-8924-001ff3591711',     }, }  Friends = {     'a4a70900-24e1-11df-8924-001ff3591711': {         # friend id: timestamp of when the friendship was added         '10cf667c-24e2-11df-8924-001ff3591711': '1267413962580791',         '343d5db2-24e2-11df-8924-001ff3591711': '1267413990076949',         '3f22b5f6-24e2-11df-8924-001ff3591711': '1267414008133277',     }, } 

Here user is assigned a unique key a4a70900-24e1-11df-8924-001ff3591711 which is used to refer to the user from other places.

like image 75
Andriy B Avatar answered Sep 18 '22 20:09

Andriy B


TimeUUID is one of six concrete implementations of the abstract class AbstractType.

For ColumnFamilies you have the possiblity to specify an attribute called CompareWith. (SuperColumns have a similar CompareSubcolumnsWith attribute).

Valid values for this attribute are classes that implements the abstract class AbstractType (eg. TimeUUID). The CompareWith attribute tells Cassandra how to sort the columns for slicing operations.

If you are using Java and using cassandra with TimeUUID I would recommend to read this section of the cassandra FAQ.

like image 26
Schildmeijer Avatar answered Sep 21 '22 20:09

Schildmeijer