nose 0.1.0pre → 0.1.0pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,398 @@
1
+ # frozen_string_literal: true
2
+
3
+ NoSE::Plans::ExecutionPlans.new do
4
+ Schema 'rubis_expert'
5
+
6
+ DefaultMix :browsing
7
+
8
+ Group 'BrowseCategories', browsing: 4.44,
9
+ bidding: 7.65,
10
+ write_medium: 7.65,
11
+ write_heavy: 7.65 do
12
+ Plan 'Authentication' do
13
+ Select users.password
14
+ Param users.id, :==
15
+ Lookup 'user_data', [users.id, :==]
16
+ end
17
+
18
+ Plan 'Categories' do
19
+ Select categories['*']
20
+ Param categories.dummy, :==, 1
21
+ Lookup 'category_list', [categories.dummy, :==]
22
+ end
23
+ end
24
+
25
+ Group 'ViewBidHistory', browsing: 2.38,
26
+ bidding: 1.54,
27
+ write_medium: 1.54,
28
+ write_heavy: 1.54 do
29
+ Plan 'ItemName' do
30
+ Select items.name
31
+ Param items.id, :==
32
+ Lookup 'items_with_category', [items.id, :==]
33
+ end
34
+
35
+ Plan 'Bids' do
36
+ Select bids['*'], users.id, users.nickname
37
+ Param items.id, :==
38
+ Lookup 'item_bids', [items.id, :==]
39
+ end
40
+ end
41
+
42
+ Group 'ViewItem', browsing: 22.95,
43
+ bidding: 14.17,
44
+ write_medium: 14.17,
45
+ write_heavy: 14.17 do
46
+ Plan 'ItemData' do
47
+ Select items['*']
48
+ Param items.id, :==
49
+ Lookup 'items_with_category', [items.id, :==]
50
+ end
51
+
52
+ Plan 'Bids' do
53
+ Select bids['*']
54
+ Param items.id, :==
55
+ Lookup 'item_bids', [items.id, :==]
56
+ end
57
+ end
58
+
59
+ Group 'SearchItemsByCategory', browsing: 27.77,
60
+ bidding: 15.94,
61
+ write_medium: 15.94,
62
+ write_heavy: 15.94 do
63
+ Plan 'ItemList' do
64
+ Select items['*']
65
+ Param categories.id, :==
66
+ Param items.end_date, :>=
67
+ Lookup 'items_by_category',
68
+ [categories.id, :==],
69
+ [items.end_date, :>=], limit: 25
70
+ Lookup 'items_with_category', [items.id, :==]
71
+ end
72
+ end
73
+
74
+ Group 'SearchItemsByRegion', browsing: 8.26,
75
+ bidding: 6.34,
76
+ write_medium: 6.34,
77
+ write_heavy: 6.34 do
78
+ Plan 'UserList' do
79
+ Select users.id
80
+ Param regions.id, :==
81
+ Lookup 'users_by_region',
82
+ [regions.id, :==]
83
+ end
84
+
85
+ Plan 'ItemList' do
86
+ Select items['*']
87
+ Param categories.id, :==
88
+ Param items.end_date, :>=
89
+ Lookup 'items_by_category',
90
+ [categories.id, :==],
91
+ # limit multiplied by 5 since we have to filter by region
92
+ [items.end_date, :>=], limit: 25 * 5
93
+ Lookup 'items_with_category', [items.id, :==]
94
+ end
95
+ end
96
+
97
+ Group 'BrowseRegions', browsing: 3.21,
98
+ bidding: 5.39,
99
+ write_medium: 5.39,
100
+ write_heavy: 5.39 do
101
+ Plan 'Regions' do
102
+ Select regions['*']
103
+ Param regions.dummy, :==, 1
104
+ Lookup 'region_list', [regions.dummy, :==]
105
+ Lookup 'regions', [regions.id, :==]
106
+ end
107
+ end
108
+
109
+ Group 'ViewUserInfo', browsing: 4.41,
110
+ bidding: 2.48,
111
+ write_medium: 2.48,
112
+ write_heavy: 2.48 do
113
+ Plan 'UserData' do
114
+ Select users['*'], regions.name
115
+ Param users.id, :==
116
+ Lookup 'user_data', [users.id, :==]
117
+ end
118
+
119
+ Plan 'CommentsReceived' do
120
+ Select comments['*']
121
+ Param users.id, :==
122
+ Lookup 'user_comments_received', [users.id, :==]
123
+ Lookup 'commenter', [comments.id, :==]
124
+ end
125
+ end
126
+
127
+ Group 'RegisterItem', bidding: 0.53,
128
+ write_medium: 0.53 * 10,
129
+ write_heavy: 0.53 * 100 do
130
+ Plan 'InsertItem' do
131
+ Param items.id, :==
132
+ Param categories.id, :==
133
+ Param items.name, :==
134
+ Param items.description, :==
135
+ Param items.initial_price, :==
136
+ Param items.quantity, :==
137
+ Param items.reserve_price, :==
138
+ Param items.buy_now, :==
139
+ Param items.nb_of_bids, :==
140
+ Param items.max_bid, :==
141
+ Param items.start_date, :==
142
+ Param items.end_date, :==
143
+ Insert 'items_with_category'
144
+ end
145
+
146
+ Plan 'AddToSold' do
147
+ Param items.id, :==
148
+ Param items.end_date, :==
149
+ Param users.id, :==
150
+ Insert 'user_items_sold'
151
+ end
152
+
153
+ Plan 'AddToCategory' do
154
+ Param items.id, :==
155
+ Param items.end_date, :==
156
+ Param categories.id, :==
157
+ Insert 'items_by_category'
158
+ end
159
+ end
160
+
161
+ Group 'RegisterUser', bidding: 1.07,
162
+ write_medium: 1.07 * 10,
163
+ write_heavy: 1.07 * 100 do
164
+ Plan 'AddUser' do
165
+ Support do
166
+ Plan 'GetRegionName' do
167
+ Select regions.name
168
+ Param regions.id, :==
169
+ Lookup 'regions', [regions.id, :==]
170
+ end
171
+ end
172
+
173
+ Param users.id, :==
174
+ Param users.firstname, :==
175
+ Param users.lastname, :==
176
+ Param users.nickname, :==
177
+ Param users.password, :==
178
+ Param users.email, :==
179
+ Param users.rating, :==, 0
180
+ Param users.balance, :==, 0
181
+ Param users.creation_date, :==
182
+ Param regions.id, :==
183
+ Param regions.name, :==
184
+ Insert 'user_data'
185
+ end
186
+
187
+ Plan 'AddToRegion' do
188
+ Param users.id, :==
189
+ Param users.nickname, :==
190
+ Param regions.id, :==
191
+ Insert 'users_by_region'
192
+ end
193
+ end
194
+
195
+ Group 'BuyNow', bidding: 1.16,
196
+ write_medium: 1.16,
197
+ write_heavy: 1.16 do
198
+ Plan 'Authentication' do
199
+ Select users.password
200
+ Param users.id, :==
201
+ Lookup 'user_data', [users.id, :==]
202
+ end
203
+
204
+ Plan 'ItemData' do
205
+ Select items['*']
206
+ Param items.id, :==
207
+ Lookup 'items_with_category', [items.id, :==]
208
+ end
209
+ end
210
+
211
+ Group 'StoreBuyNow', bidding: 1.10,
212
+ write_medium: 1.10 * 10,
213
+ write_heavy: 1.10 * 100 do
214
+ Plan 'ReduceQuantity' do
215
+ Support do
216
+ Plan 'OldQuantity' do
217
+ Select items.quantity, items.end_date, categories.id
218
+ Param items.id, :==
219
+ Lookup 'items_with_category', [items.id, :==]
220
+ end
221
+ end
222
+
223
+ Param items.id, :==
224
+ Param items.end_date, :==
225
+ Insert 'items_with_category', items.id, categories.id, items.quantity,
226
+ items.end_date
227
+ Delete 'items_by_category'
228
+ Insert 'items_by_category', categories.id, items.end_date, items.id
229
+ end
230
+
231
+ Plan 'AddToBought' do
232
+ Param users.id, :==
233
+ Param items.id, :==
234
+ Param buynow.id, :==
235
+ Param buynow.qty, :==
236
+ Param buynow.date, :==
237
+ Insert 'user_buynow'
238
+ end
239
+ end
240
+
241
+ Group 'PutBid', bidding: 5.40,
242
+ write_medium: 5.40,
243
+ write_heavy: 5.40 do
244
+ Plan 'Authentication' do
245
+ Select users.password
246
+ Param users.id, :==
247
+ Lookup 'user_data', [users.id, :==]
248
+ end
249
+
250
+ Plan 'ItemData' do
251
+ Select items['*']
252
+ Param items.id, :==
253
+ Lookup 'items_with_category', [items.id, :==]
254
+ end
255
+
256
+ Plan 'Bids' do
257
+ Select bids['*']
258
+ Param items.id, :==
259
+ Lookup 'item_bids', [items.id, :==]
260
+ end
261
+ end
262
+
263
+ Group 'StoreBid', bidding: 3.74,
264
+ write_medium: 3.74 * 10,
265
+ write_heavy: 3.74 * 100 do
266
+ Plan 'AddBid' do
267
+ Support do
268
+ Plan 'GetMaxBid' do
269
+ Select items.max_bid, items.end_date
270
+ Param items.id, :==
271
+ Lookup 'item_bids', [items.id, :==], limit: 1
272
+ end
273
+ end
274
+
275
+ Param items.id, :==
276
+ Param items.nb_of_bids, :==
277
+ Param users.id, :==
278
+ Param bids.id, :==
279
+ Param bids.qty, :==
280
+ Param bids.bid, :==
281
+ Param bids.date, :==
282
+ Insert 'item_bids'
283
+ end
284
+
285
+ Plan 'UpdateItem' do
286
+ Support do
287
+ Plan 'GetItemData' do
288
+ Select categories.id, items.max_bid, items.end_date, items.nb_of_bids
289
+ Param items.id, :==
290
+ Lookup 'items_with_category', [items.id, :==]
291
+ end
292
+ end
293
+
294
+ Param items.id, :==
295
+ Insert 'items_with_category', items.id, categories.id,
296
+ items.max_bid, items.end_date, items.nb_of_bids
297
+ end
298
+
299
+ Plan 'AddToUserBids' do
300
+ Param users.id, :==
301
+ Param items.id, :==
302
+ Param items.end_date, :==
303
+ Param bids.id, :==
304
+ Param bids.qty, :==
305
+ Insert 'user_items_bid_on'
306
+ end
307
+ end
308
+
309
+ Group 'PutComment', bidding: 0.46,
310
+ write_medium: 0.46,
311
+ write_heavy: 0.46 do
312
+ Plan 'Authentication' do
313
+ Select users.password
314
+ Param users.id, :==
315
+ Lookup 'user_data', [users.id, :==]
316
+ end
317
+
318
+ Plan 'ItemData' do
319
+ Select items['*']
320
+ Param items.id, :==
321
+ Lookup 'items_with_category', [items.id, :==]
322
+ end
323
+
324
+ Plan 'UserData' do
325
+ Select users['*']
326
+ Param users.id, :==
327
+ Lookup 'user_data', [users.id, :==]
328
+ end
329
+ end
330
+
331
+ Group 'StoreComment', bidding: 0.45,
332
+ write_medium: 0.45 * 10,
333
+ write_heavy: 0.45 * 100 do
334
+ Plan 'UpdateRating' do
335
+ Support do
336
+ Plan 'GetRating' do
337
+ Select users.rating, regions.id
338
+ Param users.id, :==
339
+ Lookup 'user_data', [users.id, :==]
340
+ end
341
+ end
342
+
343
+ Param users.id, :==
344
+ Insert 'user_data', users.id, users.rating, regions.id
345
+ end
346
+
347
+ Plan 'InsertComment' do
348
+ Param comments.id, :==
349
+ Param comments.rating, :==
350
+ Param comments.date, :==
351
+ Param comments.comment, :==
352
+ Param items.id, :==
353
+ Param users.id, :==
354
+ Insert 'user_comments_received'
355
+ end
356
+ end
357
+
358
+ Group 'AboutMe', bidding: 1.71,
359
+ write_medium: 1.71,
360
+ write_heavy: 1.71 do
361
+ Plan 'UserData' do
362
+ Select users['*']
363
+ Param users.id, :==
364
+ Lookup 'user_data', [users.id, :==]
365
+ end
366
+
367
+ Plan 'CommentsReceived' do
368
+ Select comments['*']
369
+ Param users.id, :==
370
+ Lookup 'user_comments_received', [users.id, :==]
371
+ Lookup 'commenter', [comments.id, :==]
372
+ end
373
+
374
+ Plan 'BuyNow' do
375
+ Select items['*']
376
+ Param users.id, :==
377
+ Param buynow.date, :>=
378
+ Lookup 'user_buynow', [users.id, :==], [buynow.date, :>=]
379
+ Lookup 'items_with_category', [items.id, :==]
380
+ end
381
+
382
+ Plan 'ItemsSold' do
383
+ Select items['*']
384
+ Param users.id, :==
385
+ Param items.end_date, :>=
386
+ Lookup 'user_items_sold', [users.id, :==], [items.end_date, :>=]
387
+ Lookup 'items_with_category', [items.id, :==]
388
+ end
389
+
390
+ Plan 'ItemsBid' do
391
+ Select items['*']
392
+ Param users.id, :==
393
+ Param items.end_date, :>=
394
+ Lookup 'user_items_bid_on', [users.id, :==], [items.end_date, :>=]
395
+ Lookup 'items_with_category', [items.id, :==]
396
+ end
397
+ end
398
+ end
data/schemas/ebay.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/nose.rb'
4
+
5
+ NoSE::Schema.new do
6
+ Model 'ebay'
7
+
8
+ Index 'users_by_id' do
9
+ Hash users.UserID
10
+ Extra users['*']
11
+ Path users.UserID
12
+ end
13
+
14
+ Index 'items_by_id' do
15
+ Hash items.ItemID
16
+ Extra items['*']
17
+ Path items.ItemID
18
+ end
19
+
20
+ Index 'likes_by_user' do
21
+ Hash users.UserID
22
+ Ordered likes.LikedAt, likes.LikeID, items.ItemID
23
+ Path users.UserID, users.likes, likes.item
24
+ end
25
+
26
+ Index 'likes_by_item' do
27
+ Hash items.ItemID
28
+ Ordered likes.LikedAt, likes.LikeID, users.UserID
29
+ Path items.ItemID, items.likes, likes.user
30
+ end
31
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/nose.rb'
4
+
5
+ NoSE::Schema.new do
6
+ Model 'rubis'
7
+
8
+ SimpleIndex 'categories'
9
+ SimpleIndex 'regions'
10
+ SimpleIndex 'items'
11
+ SimpleIndex 'comments'
12
+
13
+ Index 'users_by_region' do
14
+ Hash regions.id
15
+ Ordered users.id
16
+ Extra users.nickname
17
+ Path regions.id, regions.users
18
+ end
19
+
20
+ Index 'users' do
21
+ Hash users.id
22
+ Ordered regions.id
23
+ Extra users['*']
24
+ Path users.id, users.region
25
+ end
26
+
27
+ Index 'bids' do
28
+ Hash bids.id
29
+ Ordered users.id, items.id
30
+ Extra bids['*']
31
+ Path users.id, users.bids, bids.item
32
+ end
33
+
34
+ Index 'buynow' do
35
+ Hash buynow.id
36
+ Ordered items.id
37
+ Extra buynow['*']
38
+ Path buynow.id, buynow.item
39
+ end
40
+
41
+ Index 'all_categories' do
42
+ Hash categories.dummy
43
+ Ordered categories.id
44
+ Path categories.id
45
+ end
46
+
47
+ Index 'all_regions' do
48
+ Hash regions.dummy
49
+ Ordered regions.id
50
+ Path regions.id
51
+ end
52
+
53
+ Index 'bids_by_item' do
54
+ Hash items.id
55
+ Ordered bids.id
56
+ Path items.id, items.bids
57
+ end
58
+
59
+ Index 'items_by_category' do
60
+ Hash categories.id
61
+ Ordered items.end_date, items.id
62
+ Path categories.id, categories.items
63
+ end
64
+
65
+ Index 'items_by_region' do
66
+ Hash regions.id
67
+ Ordered categories.id, items.end_date, items.id, users.id
68
+ Path regions.id, regions.users, users.items_sold, items.category
69
+ end
70
+
71
+ Index 'comments_by_user' do
72
+ Hash users.id
73
+ Ordered comments.id
74
+ Path users.id, users.comments_received
75
+ end
76
+
77
+ Index 'user_items_sold' do
78
+ Hash users.id
79
+ Ordered items.end_date, items.id
80
+ Path users.id, users.items_sold
81
+ end
82
+
83
+ Index 'buynow_by_user' do
84
+ Hash users.id
85
+ Ordered buynow.date, buynow.id
86
+ Path users.id, users.bought_now
87
+ end
88
+
89
+ Index 'bids_by_user' do
90
+ Hash users.id
91
+ Ordered bids.date, bids.id
92
+ Path users.id, users.bids
93
+ end
94
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/nose.rb'
4
+
5
+ NoSE::Schema.new do
6
+ Model 'rubis'
7
+
8
+ Index 'users_by_region' do
9
+ Hash regions.id
10
+ Ordered users.id
11
+ Extra users.nickname
12
+ Path regions.id, regions.users
13
+ end
14
+
15
+ Index 'user_data' do
16
+ Hash users.id
17
+ Ordered regions.id
18
+ Extra users['*'], regions.name
19
+ Path users.id, users.region
20
+ end
21
+
22
+ Index 'user_buynow' do
23
+ Hash users.id
24
+ Ordered buynow.date, buynow.id, items.id
25
+ Extra buynow.qty
26
+ Path users.id, users.bought_now, buynow.item
27
+ end
28
+
29
+ Index 'user_items_bid_on' do
30
+ Hash users.id
31
+ Ordered items.end_date, bids.id, items.id
32
+ Extra bids.qty
33
+ Path users.id, users.bids, bids.item
34
+ end
35
+
36
+ Index 'user_items_sold' do
37
+ Hash users.id
38
+ Ordered items.end_date, items.id
39
+ Path users.id, users.items_sold
40
+ end
41
+
42
+ Index 'user_comments_received' do
43
+ Hash users.id
44
+ Ordered comments.id, items.id
45
+ Extra comments['*']
46
+ Path users.id, users.comments_received, comments.item
47
+ end
48
+
49
+ Index 'commenter' do
50
+ Hash comments.id
51
+ Ordered users.id
52
+ Extra users.nickname
53
+ Path comments.id, comments.from_user
54
+ end
55
+
56
+ Index 'items_with_category' do
57
+ Hash items.id
58
+ Ordered categories.id
59
+ Extra items['*']
60
+ Path items.id, items.category
61
+ end
62
+
63
+ Index 'item_bids' do
64
+ Hash items.id
65
+ Ordered bids.id, users.id
66
+ Extra items.max_bid, users.nickname, bids.qty, bids.bid, bids.date
67
+ Path items.id, items.bids, bids.user
68
+ end
69
+
70
+ Index 'items_by_category' do
71
+ Hash categories.id
72
+ Ordered items.end_date, items.id
73
+ Path categories.id, categories.items
74
+ end
75
+
76
+ Index 'category_list' do
77
+ Hash categories.dummy
78
+ Ordered categories.id
79
+ Extra categories.name
80
+ Path categories.id
81
+ end
82
+
83
+ Index 'region_list' do
84
+ Hash regions.dummy
85
+ Ordered regions.id
86
+ Extra regions.name
87
+ Path regions.id
88
+ end
89
+
90
+ Index 'regions' do
91
+ Hash regions.id
92
+ Extra regions.name
93
+ Path regions.id
94
+ end
95
+ end
data/workloads/eac.rb ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ NoSE::Workload.new do
4
+ Model 'eac'
5
+
6
+ # Server session exists
7
+ Q 'SELECT Server.ServerID FROM Server WHERE ' \
8
+ 'Server.ServerID = ?', 3
9
+
10
+ # Get sessions by GUID
11
+ Q 'SELECT Session.SessionID FROM ' \
12
+ 'Session.player WHERE player.PlayerID = ?', 3
13
+
14
+ # Get player session
15
+ Q 'SELECT states.PosX, states.PosY, states.PosZ, ' \
16
+ 'states.ServerTimestamp FROM ' \
17
+ 'Server.sessions.states WHERE Server.ServerID = ? AND ' \
18
+ 'sessions.player.PlayerID = ? ORDER BY states.ServerTimestamp', 6
19
+
20
+ # Get new data
21
+ Q 'SELECT states.PosX, states.PosY, states.PosZ, ' \
22
+ 'states.ServerTimestamp, sessions.player.PlayerID FROM ' \
23
+ 'Server.sessions.states WHERE sessions.player.IsAdmin = 0 AND ' \
24
+ 'Server.ServerID = ? AND states.ServerTimestamp > ? AND ' \
25
+ 'states.ServerTimestamp <= ? ORDER BY states.ServerTimestamp', 6
26
+
27
+ # Get server information
28
+ Q 'SELECT Server.ServerName, Server.ServerIP FROM ' \
29
+ 'Server WHERE Server.ServerID = ?', 2
30
+
31
+ # Add new player
32
+ Q 'INSERT INTO Player SET PlayerID=?, PlayerName=?, PlayerFlags=?, ' \
33
+ 'IsAdmin=?', 4
34
+
35
+ # Record new state
36
+ Q 'INSERT INTO PlayerState SET StateID=?, PosX=?, PosY=?, PosZ=?, ' \
37
+ 'ClientTimestamp=?, ServerTimestamp=? AND CONNECT TO session(?)', 71
38
+
39
+ Q 'INSERT INTO Session SET SessionID=?, TimeStarted=?, TimeEnded=? ' \
40
+ 'AND CONNECT TO server(?), player(?)', 4
41
+
42
+ Q 'INSERT INTO Server SET ServerID=?, ServerIP=?, ' \
43
+ 'ServerName=?', 1
44
+ end
data/workloads/ebay.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Insipired by the blog post below on data modeling in Cassandra
4
+ # www.ebaytechblog.com/2012/07/16/cassandra-data-modeling-best-practices-part-1/
5
+
6
+ NoSE::Workload.new do
7
+ Model 'ebay'
8
+
9
+ # Define queries and their relative weights
10
+ Q 'SELECT users.* FROM users WHERE users.UserID = ? -- 1'
11
+ Q 'SELECT items.* FROM items WHERE items.ItemID = ?'
12
+ Q 'SELECT items.* FROM items.likes.user WHERE user.UserID = ? ORDER BY likes.LikedAt'
13
+ Q 'SELECT users.* FROM users.likes.item WHERE item.ItemID = ? ORDER BY likes.LikedAt'
14
+
15
+ Q 'INSERT INTO items SET ItemID = ?, Title = ?, Desc = ?'
16
+ Q 'INSERT INTO users SET UserID = ?, Name = ?, Email = ?'
17
+ Q 'INSERT INTO likes SET LikeID = ?, LikedAt = ? AND CONNECT TO user(?), item(?)'
18
+ end