blob: a78bed4b816e87a272ed8d9248f755383acee80a [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
CREATE KEYSPACE ks_0 WITH replication = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1' } AND durable_writes = true;
CREATE TYPE ks_0.btype (
a text
);
CREATE TYPE ks_0.xtype (
d text
);
CREATE TYPE ks_0.ztype (
c text,
a int
);
CREATE TYPE ks_0.ctype (
z frozen<ks_0.ztype>,
x frozen<ks_0.xtype>
);
CREATE TYPE ks_0.atype (
c frozen<ks_0.ctype>
);
CREATE TABLE ks_0.cyclist_mv (
cid uuid,
age int,
birthday date,
country text,
name text,
PRIMARY KEY (cid)
) WITH additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = ''
AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE INDEX cyclist_by_country ON ks_0.cyclist_mv (country);
CREATE TABLE ks_0.rank_by_year_and_name (
race_year int,
race_name text,
rank int,
cyclist_name text,
PRIMARY KEY ((race_year, race_name), rank)
) WITH CLUSTERING ORDER BY (rank DESC)
AND additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = ''
AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE INDEX rrank ON ks_0.rank_by_year_and_name (rank);
CREATE INDEX ryear ON ks_0.rank_by_year_and_name (race_year);
CREATE TABLE ks_0.ztable (
zkey text,
a frozen<ks_0.atype>,
PRIMARY KEY (zkey)
) WITH additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.1
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = ''
AND compaction = {'class':'org.apache.cassandra.db.compaction.LeveledCompactionStrategy','max_threshold':'32','min_threshold':'4','sstable_size_in_mb':'95'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE MATERIALIZED VIEW ks_0.cyclist_by_a_age AS
SELECT * FROM ks_0.cyclist_mv
WHERE age IS NOT NULL AND cid IS NOT NULL
PRIMARY KEY (age, cid) WITH additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = ''
AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE MATERIALIZED VIEW ks_0.cyclist_by_age AS
SELECT
age,
cid,
birthday,
country,
name
FROM ks_0.cyclist_mv
WHERE age IS NOT NULL AND cid IS NOT NULL
PRIMARY KEY (age, cid) WITH additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = 'simple view'
AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE MATERIALIZED VIEW ks_0.cyclist_by_r_age AS
SELECT
age,
cid,
birthday,
country,
name
FROM ks_0.cyclist_mv
WHERE age IS NOT NULL AND cid IS NOT NULL
PRIMARY KEY (age, cid) WITH additional_write_policy = '99p'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys':'ALL','rows_per_partition':'NONE'}
AND comment = ''
AND compaction = {'class':'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy','max_threshold':'32','min_threshold':'4'}
AND compression = {'chunk_length_in_kb':'64','class':'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND extensions = {}
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';
CREATE FUNCTION ks_0.avgfinal(state tuple<int, bigint>)
CALLED ON NULL INPUT
RETURNS double
LANGUAGE java
AS 'double r = 0; if (state.getInt(0) == 0) return null; r = state.getLong(1); r /= state.getInt(0); return Double.valueOf(r);';
CREATE FUNCTION ks_0.avgstate(state tuple<int, bigint>,val int)
CALLED ON NULL INPUT
RETURNS tuple<int, bigint>
LANGUAGE java
AS 'if (val !=null) { state.setInt(0, state.getInt(0)+1); state.setLong(1, state.getLong(1)+val.intValue()); } return state;';
CREATE AGGREGATE ks_0.average(int)
SFUNC avgstate
STYPE tuple<int, bigint>
FINALFUNC avgfinal
INITCOND (0,0);
CREATE AGGREGATE ks_0.mean(int)
SFUNC avgstate
STYPE tuple<int, bigint>
FINALFUNC avgfinal
INITCOND (0,0);