· 7 years ago · Oct 23, 2018, 09:14 AM
1---
2tags:
3 group: schema
4statements:
5- name: create-keyspace
6 prepared: false
7 statement: |
8 create keyspace if not exists <<KEYSPACE:fallout>>
9 WITH replication = <<replication:{'class': 'SimpleStrategy', 'replication_factor': '1'}>>
10 AND durable_writes = <<durable_writes:true>>;
11- name: create-table
12 prepared: false
13 statement: |
14 CREATE TABLE <<KEYSPACE:fallout>>.trades (
15 instrumentid timeuuid,
16 day text,
17 second int,
18 millisecond int,
19 price double ,
20 volume double,
21 PRIMARY KEY((instrumentid, day), second, millisecond)
22 )
23 WITH CLUSTERING ORDER BY (second DESC, millisecond DESC)
24 AND compaction = <<compaction:{'class': 'SizeTieredCompactionStrategy'}>>
25 AND compression = <<compression:{'class': 'LZ4Compressor'}>>;
26---
27tags:
28 group: write-uniform
29statements:
30 - name: write-trades
31 prepared: true
32 statement: |
33 insert into <<KEYSPACE:fallout>>.trades (instrumentid, day, second, millisecond, price, volume)
34 values (?instrumentid, ?day, ?second, ?millisecond, ?price, ?volume);
35 bindings:
36 instrumentid: compose Mod(<<instruments:30000>>); ToEpochTimeUUID() -> timeuuid
37 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
38 second: compose Div(<<instruments:30000>>); Div(1000); Mod(86400) -> int
39 millisecond: compose Div(<<instruments:30000>>); Mod(1000) -> int
40 price: normal(1000, 100) -> double
41 volume: normal(1000000, 1000) -> double
42---
43tags:
44 group: write-hot
45statements:
46 - name: write-trades
47 prepared: true
48 statement: |
49 insert into <<KEYSPACE:fallout>>.trades (instrumentid, day, second, millisecond, price, volume)
50 values (?instrumentid, ?day, ?second, ?millisecond, ?price, ?volume);
51 bindings:
52 instrumentid: compose zipf(<<instruments:30000>>, 0.99); ToEpochTimeUUID() -> timeuuid
53 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
54 second: compose Div(1000); Mod(86400) -> int
55 millisecond: compose Mod(1000) -> int
56 price: normal(1000, 100) -> double
57 volume: normal(1000000, 1000) -> double
58---
59tags:
60 group: query-latest-uniform
61statements:
62 - name: latest
63 prepared: true
64 statement: |
65 select * from <<KEYSPACE:fallout>>.trades
66 where instrumentid = ?instrumentid and day = ?day
67 ORDER BY second DESC, millisecond DESC LIMIT 1
68 bindings:
69 instrumentid: compose Mod(<<instruments:30000>>); ToEpochTimeUUID() -> timeuuid
70 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
71---
72tags:
73 group: query-latest-hot
74statements:
75 - name: latest
76 prepared: true
77 statement: |
78 select * from <<KEYSPACE:fallout>>.trades
79 where instrumentid = ?instrumentid and day = ?day
80 ORDER BY second DESC, millisecond DESC LIMIT 1
81 bindings:
82 instrumentid: compose zipf(<<instruments:30000>>, 0.99); ToEpochTimeUUID() -> timeuuid
83 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
84---
85tags:
86 group: query-range-uniform
87statements:
88 - name: range
89 prepared: true
90 statement: |
91 select * from <<KEYSAPCE:fallout>>.trades
92 where instrumentid = ?instrumentid and day = ?day and second <= ?second
93 ORDER BY second DESC, millisecond DESC LIMIT 100
94 bindings:
95 instrumentid: compose Mod(<<instruments:30000>>); ToEpochTimeUUID() -> timeuuid
96 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
97 second: compose Div(<<instruments:30000>>); Div(1000); Mod(86400) -> int
98---
99tags:
100 group: query-range-hot
101statements:
102 - name: range
103 prepared: true
104 statement: |
105 select * from <<KEYSAPCE:fallout>>.trades
106 where instrumentid = ?instrumentid and day = ?day and second <= ?second
107 ORDER BY second DESC, millisecond DESC LIMIT 100
108 bindings:
109 instrumentid: compose zipf(<<instruments:30000>>, 0.99); ToEpochTimeUUID() -> timeuuid
110 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
111 second: compose Div(1000); Mod(86400) -> int
112---
113tags:
114 group: verify-uniform
115statements:
116 - name: verify
117 prepared: true
118 statement: |
119 select * from <<KEYSPACE:fallout>>.trades
120 where instrumentid = ?instrumentid and day = ?day and second = ?second
121 and millisecond = ?millisecond
122 bindings:
123 instrumentid: compose Mod(<<instruments:30000>>); ToEpochTimeUUID() -> timeuuid
124 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
125 second: compose Div(<<instruments:30000>>); Div(1000); Mod(86400) -> int
126 millisecond: compose Div(<<instruments:30000>>); Mod(1000) -> int
127 price: normal(1000, 100) -> double
128 volume: normal(1000000, 1000) -> double
129---
130tags:
131 group: verify-hot
132statements:
133 - name: verify
134 prepared: true
135 statement: |
136 select * from <<KEYSPACE:fallout>>.trades
137 where instrumentid = ?instrumentid and day = ?day and second = ?second
138 and millisecond = ?millisecond
139 bindings:
140 instrumentid: compose zipf(<<instruments:30000>>, 0.99); ToEpochTimeUUID() -> timeuuid
141 day: compose Div(<<instruments:30000>>); StringDateWrapper("YYYY-MM-dd") -> text
142 second: compose Div(1000); Mod(86400) -> int
143 millisecond: compose Mod(1000) -> int
144 price: normal(1000, 100) -> double
145 volume: normal(1000000, 1000) -> double