blob: c3a98b606ae36ae31feaf49b65a25fad5bf2187a [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">
283 var expression8 = new FunctionExpression({
284 "function" : "count",
285 "expression" : new ForClause(
286 "fbu", null, new AsterixExpression().set(["dataset FacebookUsers"])
287 ).bind(
288 {"return" : new AsterixExpression().set(["$fbu"])}
289 ),
290 "dataverse" : "TinySocial",
291 "success" : function(res) {
292 $('#result8').html(res["results"]);
293 }
294 });
295 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700296
297 <div class="result-output" id="result8">
298 </div>
299
300 <button id="run8">Run #8</button>
301 </div>
302 <hr/>
303
304 <h2>Query 9-A - Grouping and Aggregation</h2>
305 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700306 <div class="pretty-printed"><pre>
307 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700308
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700309 for $t in dataset TweetMessages
310 group by $uid := $t.user.screen-name with $t
311 return {
312 "user": $uid,
313 "count": count($t)
314 };
315 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700316
317 <div class="how-to-run">
318 </div>
319
320 <div class="result-output" id="result9">
321 </div>
322
323 <button id="run9a">Run #9-A</button>
324 </div>
325 <hr/>
326
327 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
328 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700329 <div class="pretty-printed"><pre>
330 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700331
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700332 for $t in dataset TweetMessages
333 /*+ hash*/
334 group by $uid := $t.user.screen-name with $t
335 return {
336 "user": $uid,
337 "count": count($t)
338 };
339 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700340
341 <div class="how-to-run">
342 </div>
343
344 <div class="result-output" id="result10">
345 </div>
346
347 <button id="run9b">Run #9-B</button>
348 </div>
349 <hr/>
350
351 <h2>Query 10 - Grouping and Limits</h2>
352 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700353 <div class="pretty-printed"><pre>
354 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700355
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700356 for $t in dataset TweetMessages
357 group by $uid := $t.user.screen-name with $t
358 let $c := count($t)
359 order by $c desc
360 limit 3
361 return {
362 "user": $uid,
363 "count": $c
364 };
365 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700366
367 <div class="how-to-run">
368 </div>
369
370 <div class="result-output" id="result11">
371 </div>
372
373 <button id="run10">Run #10</button>
374 </div>
375 <hr/>
376
377 <h2>Query 11 - Left Outer Fuzzy Join</h2>
378 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700379 <div class="pretty-printed"><pre>
380 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700381
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700382 set simfunction "jaccard";
383 set simthreshold "0.3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700384
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700385 for $t in dataset TweetMessages
386 return {
387 "tweet": $t,
388 "similar-tweets": for $t2 in dataset TweetMessages
389 where $t2.referred-topics ~= $t.referred-topics
390 and $t2.tweetid != $t.tweetid
391 return $t2.referred-topics
392 };
393 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700394
395 <div class="how-to-run">
396 </div>
397
398 <div class="result-output" id="result11">
399 </div>
400
401 <button id="run11">Run #11</button>
402 </div>
403
404</body>
405</html>