This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE daily_aggregate_precip ( | |
wsid text, | |
year int, | |
month int, | |
day int, | |
precipitation counter, | |
PRIMARY KEY ((wsid), year, month, day) | |
) WITH CLUSTERING ORDER BY (year DESC, month DESC, day DESC); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE daily_aggregate_temperature ( | |
wsid text, | |
year int, | |
month int, | |
day int, | |
high double, | |
low double, | |
mean double, | |
variance double, | |
stdev double, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE raw_weather_data ( | |
wsid text, // Composite of Air Force Datsav3 station number and NCDC WBAN number | |
year int, // Year collected | |
month int, // Month collected | |
day int, // Day collected | |
hour int, // Hour collected | |
temperature double, // Air temperature (degrees Celsius) | |
dewpoint double, // Dew point temperature (degrees Celsius) | |
pressure double, // Sea level pressure (hectopascals) | |
wind_direction int, // Wind direction in degrees. 0-359 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION state_group_and_total( state map<text, int>, type text, amount int ) | |
CALLED ON NULL INPUT | |
RETURNS map<text, int> | |
LANGUAGE java AS ' | |
Integer count = (Integer) state.get(type); if (count == null) count = amount; else count = count + amount; state.put(type, count); return state; ' ; | |
CREATE OR REPLACE AGGREGATE group_and_total(text, int) | |
SFUNC state_group_and_total | |
STYPE map<text, int> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION state_group_and_count( state map<text, int>, type text ) | |
CALLED ON NULL INPUT | |
RETURNS map<text, int> | |
LANGUAGE java AS ' | |
Integer count = (Integer) state.get(type); if (count == null) count = 1; else count++; state.put(type, count); return state; ' ; | |
CREATE OR REPLACE AGGREGATE group_and_count(text) | |
SFUNC state_group_and_count | |
STYPE map<text, int> | |
INITCOND {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION maxI(current int, candidate int) | |
CALLED ON NULL INPUT | |
RETURNS int LANGUAGE java AS | |
'if (current == null) return candidate; else return Math.max(current, candidate);' ; | |
CREATE AGGREGATE maxAgg(int) | |
SFUNC maxI | |
STYPE int | |
INITCOND null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE keyvalue(key text , value int ); | |
INSERT INTO keyvalue (key, value ) VALUES ( 'chris', 5); | |
INSERT INTO keyvalue (key, value ) VALUES ( 'luke', 10); | |
INSERT INTO keyvalue (key, value ) VALUES ( 'patrick', 15); | |
INSERT INTO keyvalue (key, value ) VALUES ( 'haddad', 20); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.datastax.driver.core.*; | |
task buildSchema << { | |
Cluster cluster = Cluster.builder().addContactPoint("localhost").build() | |
Session session = cluster.connect() | |
new File("src/main/resources/schema/tables.cql").eachLine { line -> | |
println("Executing $line") | |
session.execute(line) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '1.2.1.RELEASE' | |
cassandraDriverVersion = "2.1.4" | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class SpringConfiguringClass extends MetricsConfigurerAdapter { | |
@Inject | |
private Session session; | |
@Override | |
public MetricRegistry getMetricRegistry() { | |
return session.getCluster().getMetrics().getRegistry(); | |
} |