def aggregate(ts = Time.now.floor)
      ts = ts.to_i
      aggr = {}
      # Find all counters from the index
      index_key = generate_index_key(ts, '*')
      counters = Cequel::Record.redis.keys(index_key)
      counters.each do |cnt|
        _tmp = cnt.split(SEPARATOR)
        _ts = _tmp[2].to_i
        aggr[_ts] = {} unless aggr.has_key?(_ts)

        clazz = _tmp[3]
        _clazz = clazz.constantize

        _attrs = _tmp[4.._tmp.length]

        args = {}
        _clazz.key_column_names.each_with_index do |k, i|
          args[k] = _attrs[i]
        end

        obj = _clazz.public_send(:get_cached, args)

        # construct the keys for all counters matching this patter
        _attrs << '*'
        counters_search_key = generate_key_prefix(_ts, clazz, _attrs)
        counter_keys = Cequel::Record.redis.keys(counters_search_key)
        counter_keys.each do |c_key|
          val = Cequel::Record.redis.get(c_key)
          if val
            aggr[_ts][obj] = aggr[_ts].fetch(obj, 0) + val.to_i
          else
            aggr[_ts][obj] = aggr[_ts].fetch(obj, 0) + 1
          end
        end
      end
      aggr

    end
def aggregate(ts = Time.now.floor)
      ts = ts.to_i
      aggr = {}
      # Find all counters from the index
      index_key = generate_index_key(ts, '*')
      counters = Cequel::Record.redis.keys(index_key)
      counters.each do |cnt|
        _tmp = cnt.split(SEPARATOR)
        _ts = _tmp[2].to_i
        aggr[_ts] = {} unless aggr.has_key?(_ts)

        clazz = _tmp[3]
        _clazz = clazz.constantize

        _attrs = _tmp[4.._tmp.length]

        args = {}
        _clazz.key_column_names.each_with_index do |k, i|
          args[k] = _attrs[i]
        end

        obj = _clazz.public_send(:get_cached, args)

        # construct the keys for all counters matching this patter
        _attrs << '*'
        counters_search_key = generate_key_prefix(_ts, clazz, _attrs)
        counter_keys = Cequel::Record.redis.keys(counters_search_key)
        counter_keys.each do |c_key|
          val = Cequel::Record.redis.get(c_key)
          if val
            aggr[_ts][obj] = aggr[_ts].fetch(obj, 0) + val.to_i
          else
            aggr[_ts][obj] = aggr[_ts].fetch(obj, 0) + 1
          end
        end
      end
      aggr

    end
Aggregates all the counters available. Aggregation of only time specific
   events can be done by passing the `ts` parameter.
 @param [Time] ts The time at which aggregation has to be done.
 @return [Hash{Fixnum => Hash{ Obj => Fixnum }}] The counts of each object