blob: d9c21a092ab67550d88ebfaa210cc6ab7060c67d [file] [log] [blame]
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -07001<!DOCTYPE html>
2
3<html>
4<head>
5 <title>AsterixDB TinySocial Demo</title>
6
7 <style>
8 .pretty-printed {
9 background-color: #eeeeee;
10 margin-bottom: 1em;
11 }
12
13 .how-to-run {
14 background-color: #c8c8c8;
15 margin-bottom: 1em;
16 }
17
18 .result-output {
19 background-color: #BED8E5;
20 margin-bottom: 1em;
21 }
22
23 body {
24 font-family : "Helvetica";
25 margin-bottom: 1em;
26 }
27 </style>
28
29 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
30 <script src="../js/asterix-sdk-stable.js"></script>
31 <script src="js/demo.js"></script>
32</head>
33<body>
34 <h1>AQL: Querying TinySocial AsterixDB</h1>
35
36 <h2>Query 0-A - Exact-Match Lookup</h2>
37 <div class="sample-query">
38
39 <div class="pretty-printed">
40 use dataverse TinySocial;<br/><br/>
41
42 for $user in dataset FacebookUsers<br/>
43 where $user.id = 8<br/>
44 return $user;<br/>
45 </div>
46
47 <div class="how-to-run">
48 javascript here
49 </div>
50
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070051 <div class="result-output" id="result0a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070052 </div>
53
54 <button id="run0a">Run #0-A</button>
55 </div>
56 <hr/>
57 <h2>Query 0-B - Range Scan</h2>
58 <div class="sample-query">
59
60 <div class="pretty-printed">
61 use dataverse TinySocial;<br/><br/>
62
63 for $user in dataset FacebookUsers<br/>
64 where $user.id >= 2 and $user.id <= 4<br/>
65 return $user;<br/>
66 </div>
67
68 <div class="how-to-run">
69 </div>
70
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070071 <div class="result-output" id="result0b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070072 </div>
73
74 <button id="run0b">Run #0-B</button>
75 </div>
76 <hr/>
77
78 <h2>Query 1 - Other Query Filters</h2>
79 <div class="sample-query">
80 <div class="pretty-printed">
81 use dataverse TinySocial;<br/><br/>
82
83 for $user in dataset FacebookUsers<br/>
84 where $user.user-since >= datetime('2010-07-22T00:00:00')<br/>
85 and $user.user-since <= datetime('2012-07-29T23:59:59')<br/>
86 return $user;<br/>
87 </div>
88
89 <div class="how-to-run">
90 </div>
91
92 <div class="result-output" id="result1">
93 </div>
94
95 <button id="run1">Run #1</button>
96 </div>
97 <hr/>
98
99 <h2>Query 2-A - Equijoin</h2>
100 <div class="sample-query">
101 <div class="pretty-printed">
102 use dataverse TinySocial;<br/><br/>
103
104 for $user in dataset FacebookUsers<br/>
105 for $message in dataset FacebookMessages<br/>
106 where $message.author-id = $user.id<br/>
107 return {<br/>
108 "uname": $user.name,<br/>
109 "message": $message.message<br/>
110 };<br/>
111 </div>
112
113 <div class="how-to-run">
114 </div>
115
116 <div class="result-output" id="result2a">
117 </div>
118
119 <button id="run2a">Run #2-A</button>
120 </div>
121 <hr/>
122
123 <h2>Query 2-B - Index join</h2>
124 <div class="sample-query">
125 <div class="pretty-printed">
126 use dataverse TinySocial;<br/><br/>
127
128 for $user in dataset FacebookUsers<br/>
129 for $message in dataset FacebookMessages<br/>
130 where $message.author-id /*+ indexnl */ = $user.id<br/>
131 return {<br/>
132 "uname": $user.name,<br/>
133 "message": $message.message<br/>
134 };<br/>
135 </div>
136
137 <div class="how-to-run">
138 </div>
139
140 <div class="result-output" id="result2b">
141 </div>
142
143 <button id="run2b">Run #2-B</button>
144 </div>
145 <hr/>
146
147 <h2>Query 3 - Nested Outer Join</h2>
148 <div class="sample-query">
149 <div class="pretty-printed">
150 use dataverse TinySocial;<br/><br/>
151
152 for $user in dataset FacebookUsers<br/>
153 return {<br/>
154 "uname": $user.name,<br/>
155 "messages": for $message in dataset FacebookMessages<br/>
156 where $message.author-id = $user.id<br/>
157 return $message.message<br/>
158 };<br/>
159 </div>
160
161 <div class="how-to-run">
162 </div>
163
164 <div class="result-output" id="result3">
165 </div>
166
167 <button id="run3">Run #3</button>
168 </div>
169 <hr/>
170
171 <h2>Query 4 - Theta Join</h2>
172 <div class="sample-query">
173 <div class="pretty-printed">
174 use dataverse TinySocial;<br/><br/>
175
176 for $t in dataset TweetMessages<br/>
177 return {<br/>
178 "message": $t.message-text,<br/>
179 "nearby-messages": for $t2 in dataset TweetMessages<br/>
180 where spatial-distance($t.sender-location, $t2.sender-location) <= 1<br/>
181 return { "msgtxt":$t2.message-text}<br/>
182 };<br/>
183 </div>
184
185 <div class="how-to-run">
186 </div>
187
188 <div class="result-output" id="result4">
189 </div>
190
191 <button id="run4">Run #4</button>
192 </div>
193 <hr/>
194
195 <h2>Query 5 - Fuzzy Join</h2>
196 <div class="sample-query">
197 <div class="pretty-printed">
198 use dataverse TinySocial;<br/><br/>
199
200 set simfunction "edit-distance";<br/>
201 set simthreshold "3";<br/><br/>
202
203 for $fbu in dataset FacebookUsers<br/>
204 return {<br/>
205 "id": $fbu.id,<br/>
206 "name": $fbu.name,<br/>
207 "similar-users": for $t in dataset TweetMessages<br/>
208 let $tu := $t.user<br/>
209 where $tu.name ~= $fbu.name<br/>
210 return {<br/>
211 "twitter-screenname": $tu.screen-name,<br/>
212 "twitter-name": $tu.name<br/>
213 }<br/>
214 };<br/>
215 </div>
216
217 <div class="how-to-run">
218 </div>
219
220 <div class="result-output" id="result5">
221 </div>
222
223 <button id="run5">Run #5</button>
224 </div>
225 <hr/>
226
227 <h2>Query 6 - Existential Quantification</h2>
228 <div class="sample-query">
229 <div class="pretty-printed">
230 use dataverse TinySocial;<br/><br/>
231
232 for $fbu in dataset FacebookUsers<br/>
233 where (some $e in $fbu.employment satisfies is-null($e.end-date))<br/>
234 return $fbu;<br/>
235 </div>
236
237 <div class="how-to-run">
238 </div>
239
240 <div class="result-output" id="result6">
241 </div>
242
243 <button id="run6">Run #6</button>
244 </div>
245 <hr/>
246
247 <h2>Query 7 - Universal Quantification</h2>
248 <div class="sample-query">
249 <div class="pretty-printed">
250 use dataverse TinySocial;<br/><br/>
251
252 for $fbu in dataset FacebookUsers<br/>
253 where (every $e in $fbu.employment satisfies not(is-null($e.end-date))) <br/>
254 return $fbu;<br/>
255 </div>
256
257 <div class="how-to-run">
258 </div>
259
260 <div class="result-output" id="result7">
261 </div>
262
263 <button id="run7">Run #7</button>
264 </div>
265 <hr/>
266
267 <h2>Query 8 - Simple Aggregation</h2>
268 <div class="sample-query">
269 <div class="pretty-printed">
270 use dataverse TinySocial;<br/><br/>
271
272 count(for $fbu in dataset FacebookUsers return $fbu);<br/>
273 </div>
274
275 <div class="how-to-run">
276 var expression8 = new FunctionExpression({<br/>
277 "function" : "count",<br/>
genia.likes.science@gmail.com2e713492013-05-28 04:53:58 -0700278 "expression" : new ForClause(<br/>
279 "fbu", null, new AsterixExpression().set(["dataset FacebookUsers"])<br/>
280 ).bind(<br/>
281 {"return" : new AsterixExpression().set(["$fbu"])}<br/>
282 ),<br/>
283 "dataverse" : "TinySocial",<br/>
284 "success" : function(res) {<br/>
285 $('#result8').html(res["results"]);<br/>
286 }<br/>
287 }).run();<br/>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700288 </div>
289
290 <div class="result-output" id="result8">
291 </div>
292
293 <button id="run8">Run #8</button>
294 </div>
295 <hr/>
296
297 <h2>Query 9-A - Grouping and Aggregation</h2>
298 <div class="sample-query">
299 <div class="pretty-printed">
300 use dataverse TinySocial;<br/><br/>
301
302 for $t in dataset TweetMessages<br/>
303 group by $uid := $t.user.screen-name with $t<br/>
304 return {<br/>
305 "user": $uid,<br/>
306 "count": count($t)<br/>
307 };<br/>
308 </div>
309
310 <div class="how-to-run">
311 </div>
312
313 <div class="result-output" id="result9">
314 </div>
315
316 <button id="run9a">Run #9-A</button>
317 </div>
318 <hr/>
319
320 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
321 <div class="sample-query">
322 <div class="pretty-printed">
323 use dataverse TinySocial;<br/><br/>
324
325 for $t in dataset TweetMessages<br/>
326 /*+ hash*/<br/>
327 group by $uid := $t.user.screen-name with $t<br/>
328 return {<br/>
329 "user": $uid,<br/>
330 "count": count($t)<br/>
331 };<br/>
332 </div>
333
334 <div class="how-to-run">
335 </div>
336
337 <div class="result-output" id="result10">
338 </div>
339
340 <button id="run9b">Run #9-B</button>
341 </div>
342 <hr/>
343
344 <h2>Query 10 - Grouping and Limits</h2>
345 <div class="sample-query">
346 <div class="pretty-printed">
347 use dataverse TinySocial;<br/><br/>
348
349 for $t in dataset TweetMessages<br/>
350 group by $uid := $t.user.screen-name with $t<br/>
351 let $c := count($t)<br/>
352 order by $c desc<br/>
353 limit 3<br/>
354 return {<br/>
355 "user": $uid,<br/>
356 "count": $c<br/>
357 };<br/>
358 </div>
359
360 <div class="how-to-run">
361 </div>
362
363 <div class="result-output" id="result11">
364 </div>
365
366 <button id="run10">Run #10</button>
367 </div>
368 <hr/>
369
370 <h2>Query 11 - Left Outer Fuzzy Join</h2>
371 <div class="sample-query">
372 <div class="pretty-printed">
373 use dataverse TinySocial;<br/><br/>
374
375 set simfunction "jaccard";<br/>
376 set simthreshold "0.3";<br/><br/>
377
378 for $t in dataset TweetMessages<br/>
379 return {<br/>
380 "tweet": $t,<br/>
381 "similar-tweets": for $t2 in dataset TweetMessages<br/>
382 where $t2.referred-topics ~= $t.referred-topics<br/>
383 and $t2.tweetid != $t.tweetid<br/>
384 return $t2.referred-topics<br/>
385 };<br/>
386 </div>
387
388 <div class="how-to-run">
389 </div>
390
391 <div class="result-output" id="result11">
392 </div>
393
394 <button id="run11">Run #11</button>
395 </div>
396
397</body>
398</html>