incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Morton <aa...@thelastpickle.com>
Subject Re: Get all the data for x number of seconds from CQL?
Date Wed, 18 Dec 2013 02:26:47 GMT
> Is it possible to get all the data for last 5 seconds or 10 seconds or 30 seconds by using
the id column?
Not using the current table.

Try this 

CREATE TABLE test1 (
	day 			integer,
	timestamp 	integer,
	count 		integer, 
      	record_name 	text,
      	record_value 	blob,
      PRIMARY KEY (day, timestamp, record_name)
    )

Store the day as YYYYMMDD and the timestamp as before, you can then do queries like 

select * from test1 where day = 20131218 and timestamp > X and timestamp < y;

Cheers

-----------------
Aaron Morton
New Zealand
@aaronmorton

Co-Founder & Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 13/12/2013, at 11:28 am, Techy Teck <comptechgeeky@gmail.com> wrote:

> Below is my CQL table - 
> 
>     CREATE TABLE test1 (
>       id text,
>       record_name text,
>       record_value blob,
>       PRIMARY KEY (id, record_name)
>     )
> 
> here id column will have data like this - 
> 
>     timestamp.count
>     
> And here timestamp is in milliseconds but rounded up to nearest seconds. So as an example,
data in `id column` will be like this - 
> 
>     1386882930000.1
>     
> And a single row in the above table will be like this - 
> 
>     1386882930000.1 | event_name | hello-world
>     
> Now my question is - 
> 
> Is it possible to get all the data for last 5 seconds or 10 seconds or 30 seconds by
using the id column?
> 
> I am running Cassandra 1.2.9


Mime
View raw message