简体   繁体   中英

Cassandra column family for different data types

Below is the data which I need to represent in my Cassandra Column Family.

rowKey           e1_name                    e1_schemaname                   e1_last_modified_date
123             (ByteArray value)           abc (some string)               some_date

userId is the rowKey here. And e1_name , e1_schemaname and e1_last_modified_date are the columns specifically for e1 . All those three columns contain value specifically for e1 column. In the same way, I will be having for another columns such as below.

 e2_name                    e2_schemaname                   e2_last_modified_date
(ByteArray value)           abc (some string)               some_date

 e3_name                    e3_schemaname                   e3_last_modified_date
(ByteArray value)           abc (some string)               some_date

Now I am thinking, how should I go ahead and create a Dynamic Column Family for my above use case. The problem that I am facing is, each colums will have its own datatype. For e1 , I will be having e1_name which is ByteArray, e1_schemaname which will be UTF8, e1_last_modified_date which is DateType. And same for e2 series and e3 series as well.

This is what I have but I don't think so this will work.

create column family USER_DATA
with key_validation_class = 'UTF8Type'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and gc_grace = 86400

Can anyone help me in designing the column family for the above use case?

You can use "BytesType".

You can easily convert "BytesType" to/from your desired data type using AbstractSerializer.toByteBuffer() and AbstractSerializer.fromByteBuffer()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM