1

赫克托:赫克托核心1.0-5,卡桑德拉1.1.2

I have a user_event CF created through cqlsh as follows:
user_event(
user_name text,
event_id timeuuid,
event_data text,
PRIMARY KEY(user_name, event_id))

我试图在 Hector 中编写的查询是:选择当前时间之前给定用户的最后 5 个事件。

我的代码如下:

    ...    
    {
        Composite start = compositeFrom(TimeUUIDUtils.getUniqueTimeUUIDinMillis(),
        Composite.ComponentEquality.EQUAL);
        Composite end = compositeFrom(TimeUUIDUtils.getUniqueTimeUUIDinMillis(),
Composite.ComponentEquality.GREATER_THAN_EQUAL);

        List<HColumn<Composite, String>> cList= dao.getCompositeQueryIterator(key,  start,  end, stringSerializer);...
     }

        public static Composite compositeFrom(UUID componentName, Composite.ComponentEquality equalityOp) 
        {
          Composite composite = new Composite();
          composite.addComponent(0, componentName, equalityOp);
          return composite;
        }

我无法弄清楚用于开始和结束组合的运算符和值,以便我将取回按时间排序的最后 n 个事件。另外,另一个问题: getUniqueTimeUUIDinMillis() 是否适合用于 event_id 或者我应该创建一个单独的时间戳列并对其进行切片?

4

0 回答 0