In Cassandra terminology, what is TimeUUID?
Asked Answered
Q

3

23

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

Quadriceps answered 10/4, 2010 at 17:9 Comment(0)
S
8

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.

Slice answered 10/4, 2010 at 17:23 Comment(1)
The actual point of TimeUUID, as I understand it, is to give you a unique primary key that sorts by time. You would use it where in an RDBMS you'd have something with an integer primary key and also a date field. See arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model for examples.Bloke
S
12

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.

Smelt answered 10/4, 2010 at 17:28 Comment(4)
If it's random, then why is it called "Time"? To me, time implies something that can be put in order (like a timestamp.)Waaf
It's not random in the usual sense. TimeUUID is a unique key that is based on time. So the order of keys is based on time.Smelt
why does it say it's 128 bit number A universally unique identifier (UUID) is a 128-bit numberWelldone
Chris, I don't get it.. it looks correct.128-bit = 16 bytesSmelt
S
8

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.

Slice answered 10/4, 2010 at 17:23 Comment(1)
The actual point of TimeUUID, as I understand it, is to give you a unique primary key that sorts by time. You would use it where in an RDBMS you'd have something with an integer primary key and also a date field. See arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model for examples.Bloke
M
-2

to indicate a unique "row" in a ColumnFamily

Mime answered 10/4, 2010 at 17:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.