blob: 3a8d353558603dc54d22d3277618230f56758084 [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
51 <div class="result-output" id="result0A">
52 </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
71 <div class="result-output" id="result0B">
72 </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/>
278 "expression" : new ForClause("fbu", null, new AsterixExpression().set(["dataset FacebookUsers"])).bind({"return" : "$fbu"}),<br/>
279 "dataverse" : "TinySocial"<br/>
280 }).run();
281 </div>
282
283 <div class="result-output" id="result8">
284 </div>
285
286 <button id="run8">Run #8</button>
287 </div>
288 <hr/>
289
290 <h2>Query 9-A - Grouping and Aggregation</h2>
291 <div class="sample-query">
292 <div class="pretty-printed">
293 use dataverse TinySocial;<br/><br/>
294
295 for $t in dataset TweetMessages<br/>
296 group by $uid := $t.user.screen-name with $t<br/>
297 return {<br/>
298 "user": $uid,<br/>
299 "count": count($t)<br/>
300 };<br/>
301 </div>
302
303 <div class="how-to-run">
304 </div>
305
306 <div class="result-output" id="result9">
307 </div>
308
309 <button id="run9a">Run #9-A</button>
310 </div>
311 <hr/>
312
313 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
314 <div class="sample-query">
315 <div class="pretty-printed">
316 use dataverse TinySocial;<br/><br/>
317
318 for $t in dataset TweetMessages<br/>
319 /*+ hash*/<br/>
320 group by $uid := $t.user.screen-name with $t<br/>
321 return {<br/>
322 "user": $uid,<br/>
323 "count": count($t)<br/>
324 };<br/>
325 </div>
326
327 <div class="how-to-run">
328 </div>
329
330 <div class="result-output" id="result10">
331 </div>
332
333 <button id="run9b">Run #9-B</button>
334 </div>
335 <hr/>
336
337 <h2>Query 10 - Grouping and Limits</h2>
338 <div class="sample-query">
339 <div class="pretty-printed">
340 use dataverse TinySocial;<br/><br/>
341
342 for $t in dataset TweetMessages<br/>
343 group by $uid := $t.user.screen-name with $t<br/>
344 let $c := count($t)<br/>
345 order by $c desc<br/>
346 limit 3<br/>
347 return {<br/>
348 "user": $uid,<br/>
349 "count": $c<br/>
350 };<br/>
351 </div>
352
353 <div class="how-to-run">
354 </div>
355
356 <div class="result-output" id="result11">
357 </div>
358
359 <button id="run10">Run #10</button>
360 </div>
361 <hr/>
362
363 <h2>Query 11 - Left Outer Fuzzy Join</h2>
364 <div class="sample-query">
365 <div class="pretty-printed">
366 use dataverse TinySocial;<br/><br/>
367
368 set simfunction "jaccard";<br/>
369 set simthreshold "0.3";<br/><br/>
370
371 for $t in dataset TweetMessages<br/>
372 return {<br/>
373 "tweet": $t,<br/>
374 "similar-tweets": for $t2 in dataset TweetMessages<br/>
375 where $t2.referred-topics ~= $t.referred-topics<br/>
376 and $t2.tweetid != $t.tweetid<br/>
377 return $t2.referred-topics<br/>
378 };<br/>
379 </div>
380
381 <div class="how-to-run">
382 </div>
383
384 <div class="result-output" id="result11">
385 </div>
386
387 <button id="run11">Run #11</button>
388 </div>
389
390</body>
391</html>