如何在使用Datastax C#驱动程序的timeuuid数据类型的CQL查询中创建“大于”或“小于”where-conditions?“大于”where-condition on timeuuid使用Datastax C#Cassandra驱动程序
我有卡桑德拉一个表,用于存储时间戳归类为timeuuid cookie的历史:
CREATE TABLE cookie_history (
cookie_id text,
create_date timeuuid,
item_id text,
PRIMARY KEY ((cookie_id), create_date)
);
该表是用C#类映射使用Datastax C#卡桑德拉司机询问:
[Table("cookie_history")]
public class CookieHistoryDataEntry
{
[PartitionKey(1)]
[Column("cookie_id")]
public string CookieID;
[ClusteringKey(1)]
[Column("create_date")]
public Guid CreateDate;
[Column("item_id")]
public string ItemID;
}
对于给定的cookie,我希望给定时间戳后的所有项目。
var myTimeUuid = new Guid("5812e74d-ba49-11e3-8d27-27303e6a4831");
var table = session.GetTable<CookieHistoryDataEntry>();
var query = table.Where(x => x.CookieID == myCookieId
&& x.CreateDate > myTimeUuid);
但这(x.CreateDate> myTimeUuid)给了我一个编译时错误:
Operator '>' cannot be applied to operands of type 'System.Guid' and 'System.Guid'
我使用的日期作为我的专栏的关键。我使用日期的Guid表示来避免发生的事件与列键的冲突。为了解决这个“大于”不支持的问题,我将查询最新的X条目和内存中的日期过滤器。 – user628904
我认为此线程中的讨论与您的情况非常相关:http://stackoverflow.com/questions/5086192/sql-server-using-datetime-as-primary-key –
链接讨论的要点是当我们也将用户特定的密钥视为标识符的一部分时,我们只有相同时间戳的条目碰撞。但我不能假定这是因为我的一些条目在时间戳记中没有“时间部分”(但仅包含“日期部分”),所以我需要使用timeuuid来避免列键中的冲突。 – user628904