blob: 9d98546e1cf12e7d88f5fd11df173d9b1b3605bf [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 {
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -07009 background-color: #eeeeee;
10 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070011 }
12
13 .how-to-run {
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070014 background-color: #c8c8c8;
15 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070016 }
17
18 .result-output {
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070019 background-color: #BED8E5;
20 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070021 }
22
23 body {
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070024 font-family : "Helvetica";
25 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070026 }
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
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070039 <div class="pretty-printed"><pre>
40 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070041
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070042 for $user in dataset FacebookUsers
43 where $user.id = 8
44 return $user;
45 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070046
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070047 <div class="how-to-run"><pre><code class="javascript">
48 var expression0a = new FLWOGRExpression({
49 "dataverse" : "TinySocial",
50 "success" : function(res) {
51 $('#result0a').html(res["results"]);
52 }
53 })
54 .bind( new ForClause("user", null, new AsterixExpression().set(["dataset FacebookUsers"])) )
55 .bind( new WhereClause(new BooleanExpression("$user.id = 8")));
56 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070057
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070058 <div class="result-output" id="result0a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070059 </div>
60
61 <button id="run0a">Run #0-A</button>
62 </div>
63 <hr/>
64 <h2>Query 0-B - Range Scan</h2>
65 <div class="sample-query">
66
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070067 <div class="pretty-printed"><pre>
68 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070069
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070070 for $user in dataset FacebookUsers
71 where $user.id >= 2 and $user.id <= 4
72 return $user;
73 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070074
genia.likes.science@gmail.com5ca104c2013-05-29 05:39:26 -070075 <div class="how-to-run"><pre>
76 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070077
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070078 <div class="result-output" id="result0b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070079 </div>
80
81 <button id="run0b">Run #0-B</button>
82 </div>
83 <hr/>
84
85 <h2>Query 1 - Other Query Filters</h2>
86 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070087 <div class="pretty-printed"><pre>
88 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070089
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070090 for $user in dataset FacebookUsers
91 where $user.user-since >= datetime('2010-07-22T00:00:00')
92 and $user.user-since <= datetime('2012-07-29T23:59:59')
93 return $user;
94 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070095
96 <div class="how-to-run">
97 </div>
98
99 <div class="result-output" id="result1">
100 </div>
101
102 <button id="run1">Run #1</button>
103 </div>
104 <hr/>
105
106 <h2>Query 2-A - Equijoin</h2>
107 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700108 <div class="pretty-printed"><pre>
109 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700110
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700111 for $user in dataset FacebookUsers
112 for $message in dataset FacebookMessages
113 where $message.author-id = $user.id
114 return {
115 "uname": $user.name,
116 "message": $message.message
117 };
118 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700119
120 <div class="how-to-run">
121 </div>
122
123 <div class="result-output" id="result2a">
124 </div>
125
126 <button id="run2a">Run #2-A</button>
127 </div>
128 <hr/>
129
130 <h2>Query 2-B - Index join</h2>
131 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700132 <div class="pretty-printed"><pre>
133 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700134
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700135 for $user in dataset FacebookUsers
136 for $message in dataset FacebookMessages
137 where $message.author-id /*+ indexnl */ = $user.id
138 return {
139 "uname": $user.name,
140 "message": $message.message
141 };
142 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700143
144 <div class="how-to-run">
145 </div>
146
147 <div class="result-output" id="result2b">
148 </div>
149
150 <button id="run2b">Run #2-B</button>
151 </div>
152 <hr/>
153
154 <h2>Query 3 - Nested Outer Join</h2>
155 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700156 <div class="pretty-printed"><pre>
157 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700158
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700159 for $user in dataset FacebookUsers
160 return {
161 "uname": $user.name,
162 "messages": for $message in dataset FacebookMessages
163 where $message.author-id = $user.id
164 return $message.message
165 };
166 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700167
168 <div class="how-to-run">
169 </div>
170
171 <div class="result-output" id="result3">
172 </div>
173
174 <button id="run3">Run #3</button>
175 </div>
176 <hr/>
177
178 <h2>Query 4 - Theta Join</h2>
179 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700180 <div class="pretty-printed"><pre>
181 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700182
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700183 for $t in dataset TweetMessages
184 return {
185 "message": $t.message-text,
186 "nearby-messages": for $t2 in dataset TweetMessages
187 where spatial-distance($t.sender-location, $t2.sender-location) <= 1
188 return { "msgtxt":$t2.message-text}
189 };
190 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700191
192 <div class="how-to-run">
193 </div>
194
195 <div class="result-output" id="result4">
196 </div>
197
198 <button id="run4">Run #4</button>
199 </div>
200 <hr/>
201
202 <h2>Query 5 - Fuzzy Join</h2>
203 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700204 <div class="pretty-printed"><pre>
205 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700206
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700207 set simfunction "edit-distance";
208 set simthreshold "3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700209
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700210 for $fbu in dataset FacebookUsers
211 return {
212 "id": $fbu.id,
213 "name": $fbu.name,
214 "similar-users": for $t in dataset TweetMessages
215 let $tu := $t.user
216 where $tu.name ~= $fbu.name
217 return {
218 "twitter-screenname": $tu.screen-name,
219 "twitter-name": $tu.name
220 }
221 };
222 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700223
224 <div class="how-to-run">
225 </div>
226
227 <div class="result-output" id="result5">
228 </div>
229
230 <button id="run5">Run #5</button>
231 </div>
232 <hr/>
233
234 <h2>Query 6 - Existential Quantification</h2>
235 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700236 <div class="pretty-printed"><pre>
237 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700238
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700239 for $fbu in dataset FacebookUsers
240 where (some $e in $fbu.employment satisfies is-null($e.end-date))
241 return $fbu;
242 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700243
244 <div class="how-to-run">
245 </div>
246
247 <div class="result-output" id="result6">
248 </div>
249
250 <button id="run6">Run #6</button>
251 </div>
252 <hr/>
253
254 <h2>Query 7 - Universal Quantification</h2>
255 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700256 <div class="pretty-printed"><pre><pre>
257 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700258
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700259 for $fbu in dataset FacebookUsers
260 where (every $e in $fbu.employment satisfies not(is-null($e.end-date)))
261 return $fbu;
262 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700263
264 <div class="how-to-run">
265 </div>
266
267 <div class="result-output" id="result7">
268 </div>
269
270 <button id="run7">Run #7</button>
271 </div>
272 <hr/>
273
274 <h2>Query 8 - Simple Aggregation</h2>
275 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700276 <div class="pretty-printed"><pre>
277 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700278
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700279 count(for $fbu in dataset FacebookUsers return $fbu);
280 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700281
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700282 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700283 var expression8 = new FunctionExpression(
284 "count",
285 new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
genia.likes.science@gmail.com5749ef92013-06-12 07:59:25 -0700286 .bind(new ReturnClause("$fbu"))
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700287 );
288
289 OR
290
291 var expression8 = new FunctionExpression()
292 .fn("count")
293 .expression(
294 new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
genia.likes.science@gmail.com5749ef92013-06-12 07:59:25 -0700295 .bind(new ReturnClause("$fbu"))
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700296 );
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700297 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700298
299 <div class="result-output" id="result8">
300 </div>
301
302 <button id="run8">Run #8</button>
303 </div>
304 <hr/>
305
306 <h2>Query 9-A - Grouping and Aggregation</h2>
307 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700308 <div class="pretty-printed"><pre>
309 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700310
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700311 for $t in dataset TweetMessages
312 group by $uid := $t.user.screen-name with $t
313 return {
314 "user": $uid,
315 "count": count($t)
316 };
317 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700318
319 <div class="how-to-run">
320 </div>
321
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700322 <div class="result-output" id="result9a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700323 </div>
324
325 <button id="run9a">Run #9-A</button>
326 </div>
327 <hr/>
328
329 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
330 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700331 <div class="pretty-printed"><pre>
332 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700333
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700334 for $t in dataset TweetMessages
335 /*+ hash*/
336 group by $uid := $t.user.screen-name with $t
337 return {
338 "user": $uid,
339 "count": count($t)
340 };
341 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700342
343 <div class="how-to-run">
344 </div>
345
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700346 <div class="result-output" id="result9b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700347 </div>
348
349 <button id="run9b">Run #9-B</button>
350 </div>
351 <hr/>
352
353 <h2>Query 10 - Grouping and Limits</h2>
354 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700355 <div class="pretty-printed"><pre>
356 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700357
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700358 for $t in dataset TweetMessages
359 group by $uid := $t.user.screen-name with $t
360 let $c := count($t)
361 order by $c desc
362 limit 3
363 return {
364 "user": $uid,
365 "count": $c
366 };
367 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700368
369 <div class="how-to-run">
370 </div>
371
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700372 <div class="result-output" id="result10">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700373 </div>
374
375 <button id="run10">Run #10</button>
376 </div>
377 <hr/>
378
379 <h2>Query 11 - Left Outer Fuzzy Join</h2>
380 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700381 <div class="pretty-printed"><pre>
382 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700383
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700384 set simfunction "jaccard";
385 set simthreshold "0.3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700386
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700387 for $t in dataset TweetMessages
388 return {
389 "tweet": $t,
390 "similar-tweets": for $t2 in dataset TweetMessages
391 where $t2.referred-topics ~= $t.referred-topics
392 and $t2.tweetid != $t.tweetid
393 return $t2.referred-topics
394 };
395 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700396
397 <div class="how-to-run">
398 </div>
399
400 <div class="result-output" id="result11">
401 </div>
402
403 <button id="run11">Run #11</button>
404 </div>
405
406</body>
407</html>