使用maxTimeuuid/minTimeuuid进行CQL timeuuid比较

Nis*_*nde 0 cql cassandra datastax-enterprise

我在Mac OS X上使用Datastax cassandra发行版(dsc-cassandra-1.2.6).我想使用timeuuid类型,并正在尝试对它们进行查询.

这是我的表:

CREATE TABLE test_t (
  canon_key text,
  t timeuuid,
  PRIMARY KEY (canon_key, t)
)
Run Code Online (Sandbox Code Playgroud)

现在让我说我得到一排.

cqlsh:pagedb> select canon_key, t, dateOf(t), unixTimestampOf(t) from test_t where canon_key = 'xxx' and t >= minTimeuuid('2013-08-08 18:43:58-0700');                 
 canon_key | t                                    | dateOf(t)                | unixTimestampOf(t)

-----------+--------------------------------------+--------------------------+--------------------

       xxx | 287d3c30-0095-11e3-9268-a7d2e09193eb | 2013-08-08 18:43:58-0700 |      1376012638067
Run Code Online (Sandbox Code Playgroud)

现在,我想删除这一行.我没有看到这样做的好方法,因为timeuuid类型没有相等运算符.

我添加的数据的性质是这样的,我(可能)甚至不介意这样做:

cqlsh:pagedb>从test_t中选择canon_key,t,dateOf(t),unixTimestampOf(t)其中canon_key ='xxx'和t> = minTimeuuid('2013-08-08 18:43:58-0700')和t < = maxTimeuuid('2013-08-08 18:43:58-0700');

但根据文档(http://cassandra.apache.org/doc/cql3/CQL.html#usingdates),这将无法正常工作.引述:"请注意,t> = maxTimeuuid('2013-01-01 00:05 + 0000')仍然不会选择在'2013-01-01 00:05 + 0000'生成的时间长度,并且基本上相当于t> maxTimeuuid('2013-01-01 00:05 + 0000')."

那么..我该如何删除这一行?

jbe*_*lis 5

你的前提是错误的- minTimeuuid并且maxTimeuuid确实存在允许上timeuuids平等的操作,但这并不意味着简单的平等是不支持:

cqlsh:foo> insert into test_t (canon_key, t) values ('k', now());
cqlsh:foo> select * from test_t;

 canon_key | t
-----------+--------------------------------------
         k | 27609890-0209-11e3-b862-59d5a2b25b8f

(1 rows)

cqlsh:foo> delete from test_t where canon_key = 'k' and t = 27609890-0209-11e3-b862-59d5a2b25b8f;
cqlsh:foo> select * from test_t;

(0 rows)
Run Code Online (Sandbox Code Playgroud)