卡桑德拉范围查询

use*_*714 5 cassandra

我是Cassandra的新手,正在尝试数据建模和范围查询.

出于学习目的,我想开发一个数据库,我可以在其中存储LogType和Log生成时间的日志行.我必须回答以下问题:

按日期范围之间的LogType查找日志.

我将我的数据库建模为2个列族:1)日志

create column family log with comparator = 'UTF8Type' 
and key_validation_class = 'LexicalUUIDType'
and column_metadata=[{column_name: block, validation_class: UTF8Type}];
Run Code Online (Sandbox Code Playgroud)

我打算用他们的logid来存储日志行

例如: set log['7561a442-24e2-11df-8924-001ff3591711'][blocks]='someText|11-17-2011 23:40:42|sometext';

2)

create column family ltype with column_type = 'Super'
and comparator = 'TimeUUIDType'
and subcomparator = 'UTF8Type'
and column_metadata=[{column_name: id, validation_class: LexicalUUIDType}];
Run Code Online (Sandbox Code Playgroud)

在此列系列中,我将存储日志类型以及时间和日志列系列中的日志行ID:

ex: set ltype[ltype1][12307245916538][id]='7561a442-24e2-11df-8924-001ff3591711';
Run Code Online (Sandbox Code Playgroud)

我想在给定日志和日期范围的类型时得到结果.

有人可以指导我如何在超级列族上运行范围查询吗?

zzn*_*ate 6

关于Cassandra的时间序列数据建模的文章:

http://rubyscale.com/2011/basic-time-series-with-cassandra/

对于时间序列,你真的想要做更大的行 - 可能在每行10k-50k列附近作为起点(取决于你的负载).如果您将密钥作为"日期存储桶"的功能,则可以完全避免使用超级列:

[datetime] _ [5秒间隔](粒度再次取决于负载)

这样您的密钥就可以重新创建,而您只是发布了一个带有所需存储桶密钥的multi_get.

更一般的数据建模概述:

http://www.datastax.com/docs/0.8/ddl/index