Skip to content

Instantly share code, notes, and snippets.

@natbusa
Created November 11, 2013 21:39
Show Gist options
  • Select an option

  • Save natbusa/7420906 to your computer and use it in GitHub Desktop.

Select an option

Save natbusa/7420906 to your computer and use it in GitHub Desktop.
Cassandra timeseries: a signal decomposition.
CREATE KEYSPACE iot WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } ;
USE iot;
create table signals (
sid bigint,
year int,
month int,
day int,
hour int,
min int,
sec int,
value float,
PRIMARY KEY ( (sid, year, month, day, hour), min, sec )
);
INSERT INTO signals (sid,year,month,day,hour,min,sec,value) VALUES (1,2013,11,11,22,34,13,1.4);
INSERT INTO signals (sid,year,month,day,hour,min,sec,value) VALUES (1,2013,11,11,22,37,28,1.6);
INSERT INTO signals (sid,year,month,day,hour,min,sec,value) VALUES (1,2013,11,11,22,37,29,1.8);
INSERT INTO signals (sid,year,month,day,hour,min,sec,value) VALUES (1,2013,11,11,23,34,13,2.0);
SELECT * FROM signals where sid=1 AND year=2013 AND month=11 AND day=11 AND hour=22;
SELECT * FROM signals where sid=1 AND year=2013 AND month=11 AND day=11 AND hour=23;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment