blob: 812f1a7f912a24afd73bc563e7acd6330d0240be [file] [log] [blame]
Till Westmann5b431ca2015-10-01 19:16:11 -07001<!--
2 ! Licensed to the Apache Software Foundation (ASF) under one
3 ! or more contributor license agreements. See the NOTICE file
4 ! distributed with this work for additional information
5 ! regarding copyright ownership. The ASF licenses this file
6 ! to you under the Apache License, Version 2.0 (the
7 ! "License"); you may not use this file except in compliance
8 ! with the License. You may obtain a copy of the License at
9 !
10 ! http://www.apache.org/licenses/LICENSE-2.0
11 !
12 ! Unless required by applicable law or agreed to in writing,
13 ! software distributed under the License is distributed on an
14 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ! KIND, either express or implied. See the License for the
16 ! specific language governing permissions and limitations
17 ! under the License.
18 !-->
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070019<!DOCTYPE html>
20
21<html>
22<head>
23 <title>AsterixDB TinySocial Demo</title>
24
25 <style>
26 .pretty-printed {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070027 background-color: #eeeeee;
28 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070029 }
30
31 .how-to-run {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070032 background-color: #c8c8c8;
33 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070034 }
35
36 .result-output {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070037 background-color: #BED8E5;
38 margin-bottom: 1em;
39 overflow-x: scroll;
40 overflow-y: none;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070041 }
42
43 body {
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070044 font-family : "Helvetica";
45 margin-bottom: 1em;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070046 }
47 </style>
48
49 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
50 <script src="../js/asterix-sdk-stable.js"></script>
51 <script src="js/demo.js"></script>
52</head>
53<body>
54 <h1>AQL: Querying TinySocial AsterixDB</h1>
55
56 <h2>Query 0-A - Exact-Match Lookup</h2>
57 <div class="sample-query">
58
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070059 <div class="pretty-printed"><pre>
60 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070061
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070062 for $user in dataset FacebookUsers
63 where $user.id = 8
64 return $user;
65 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070066
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070067 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070068 var expression0a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070069 .ForClause("$user", new AExpression("dataset FacebookUsers"))
70 .WhereClause(new AExpression("$user.id = 8"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070071 .ReturnClause("$user");
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070072 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070073
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070074 <div class="result-output" id="result0a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070075 </div>
76
77 <button id="run0a">Run #0-A</button>
78 </div>
79 <hr/>
80 <h2>Query 0-B - Range Scan</h2>
81 <div class="sample-query">
82
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070083 <div class="pretty-printed"><pre>
84 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070085
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -070086 for $user in dataset FacebookUsers
87 where $user.id >= 2 and $user.id <= 4
88 return $user;
89 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070090
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070091 <div class="how-to-run"><pre><code class="javascript">
92 var expression0b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -070093 .ForClause("$user", new AExpression("dataset FacebookUsers"))
94 .WhereClause().and(new AExpression("$user.id >= 2"), new AExpression("$user.id <= 4"))
95 .ReturnClause("$user");
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -070096 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070097
genia.likes.science@gmail.com38612632013-05-28 13:11:52 -070098 <div class="result-output" id="result0b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -070099 </div>
100
101 <button id="run0b">Run #0-B</button>
102 </div>
103 <hr/>
104
105 <h2>Query 1 - Other Query Filters</h2>
106 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700107 <div class="pretty-printed"><pre>
108 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700109
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700110 for $user in dataset FacebookUsers
111 where $user.user-since >= datetime('2010-07-22T00:00:00')
112 and $user.user-since <= datetime('2012-07-29T23:59:59')
113 return $user;
114 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700115
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700116 <div class="how-to-run"><pre><code class="javascript">
117 var expression1 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700118 .ForClause("$user", new AExpression("dataset FacebookUsers"))
119 .WhereClause().and(
120 new AExpression("$user.user-since >= datetime('2010-07-22T00:00:00')"),
121 new AExpression("$user.user-since <= datetime('2012-07-29T23:59:59')")
122 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700123 .ReturnClause("$user");
124 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700125
126 <div class="result-output" id="result1">
127 </div>
128
129 <button id="run1">Run #1</button>
130 </div>
131 <hr/>
132
133 <h2>Query 2-A - Equijoin</h2>
134 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700135 <div class="pretty-printed"><pre>
136 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700137
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700138 for $user in dataset FacebookUsers
139 for $message in dataset FacebookMessages
140 where $message.author-id = $user.id
141 return {
142 "uname": $user.name,
143 "message": $message.message
144 };
145 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700146
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700147 <div class="how-to-run"><pre><code class="javascript">
148 var expression2a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700149 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
150 .ForClause ("$message", new AExpression("dataset FacebookMessages"))
151 .WhereClause(new AExpression("$message.author-id = $user.id"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700152 .ReturnClause({
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700153 "uname" : "$user.name",
154 "message" : "$message.message"
155 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700156 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700157
158 <div class="result-output" id="result2a">
159 </div>
160
161 <button id="run2a">Run #2-A</button>
162 </div>
163 <hr/>
164
165 <h2>Query 2-B - Index join</h2>
166 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700167 <div class="pretty-printed"><pre>
168 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700169
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700170 for $user in dataset FacebookUsers
171 for $message in dataset FacebookMessages
172 where $message.author-id /*+ indexnl */ = $user.id
173 return {
174 "uname": $user.name,
175 "message": $message.message
176 };
177 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700178
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700179 <div class="how-to-run"><pre><code class="javascript">
180 var expression2b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700181 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
182 .ForClause ("$message", new AExpression("dataset FacebookMessages"))
183 .WhereClause(new AExpression("$message.author-id /*+ indexnl */ = $user.id"))
184 .ReturnClause({
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700185 "uname" : "$user.name",
186 "message" : "$message.message"
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700187 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700188 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700189
190 <div class="result-output" id="result2b">
191 </div>
192
193 <button id="run2b">Run #2-B</button>
194 </div>
195 <hr/>
196
197 <h2>Query 3 - Nested Outer Join</h2>
198 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700199 <div class="pretty-printed"><pre>
200 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700201
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700202 for $user in dataset FacebookUsers
203 return {
204 "uname": $user.name,
205 "messages": for $message in dataset FacebookMessages
206 where $message.author-id = $user.id
207 return $message.message
208 };
209 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700210
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700211 <div class="how-to-run"><pre><code class="javascript">
212 var expression3messages = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700213 .ForClause("$message", new AExpression("dataset FacebookMessages"))
214 .WhereClause(new AExpression("$message.author-id = $user.id"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700215 .ReturnClause("$message.message");
216
217 var expression3 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700218 .ForClause ("$user", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700219 .ReturnClause({
220 "uname": "$user.name",
221 "messages" : expression3messages
222 });
223 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700224
225 <div class="result-output" id="result3">
226 </div>
227
228 <button id="run3">Run #3</button>
229 </div>
230 <hr/>
231
232 <h2>Query 4 - Theta Join</h2>
233 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700234 <div class="pretty-printed"><pre>
235 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700236
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700237 for $t in dataset TweetMessages
238 return {
239 "message": $t.message-text,
240 "nearby-messages": for $t2 in dataset TweetMessages
241 where spatial-distance($t.sender-location, $t2.sender-location) <= 1
242 return { "msgtxt":$t2.message-text}
243 };
244 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700245
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700246 <div class="how-to-run"><pre><code class="javascript">
247 var expression4messages = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700248 .ForClause( "$t2", new AExpression("dataset TweetMessages"))
249 .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700250 .ReturnClause({ "msgtxt" : "$t2.message-text" });
251
252 var expression4 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700253 .ForClause( "$t", new AExpression("dataset TweetMessages"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700254 .ReturnClause({
255 "message" : "$t.message-text",
256 "nearby-messages" : expression4messages
257 });
258 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700259
260 <div class="result-output" id="result4">
261 </div>
262
263 <button id="run4">Run #4</button>
264 </div>
265 <hr/>
266
267 <h2>Query 5 - Fuzzy Join</h2>
268 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700269 <div class="pretty-printed"><pre>
270 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700271
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700272 set simfunction "edit-distance";
273 set simthreshold "3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700274
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700275 for $fbu in dataset FacebookUsers
276 return {
277 "id": $fbu.id,
278 "name": $fbu.name,
279 "similar-users": for $t in dataset TweetMessages
280 let $tu := $t.user
281 where $tu.name ~= $fbu.name
282 return {
283 "twitter-screenname": $tu.screen-name,
284 "twitter-name": $tu.name
285 }
286 };
287 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700288
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700289 <div class="how-to-run"><pre><code class="javascript">
290 var similarUsersExpression = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700291 .ForClause("$t", new AExpression("dataset TweetMessages"))
292 .LetClause ("$tu", new AExpression("$t.user"))
293 .WhereClause(new AExpression("$tu.name ~= $fbu.name"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700294 .ReturnClause({
295 "twitter-screenname": "$tu.screen-name",
296 "twitter-name": "$tu.name"
297 });
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700298
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700299 var expression5 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700300 .ForClause ("$fbu", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700301 .ReturnClause(
302 {
303 "id" : "$fbu.id",
304 "name" : "$fbu.name",
305 "similar-users" : similarUsersExpression
306 }
307 );
308 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700309
310 <div class="result-output" id="result5">
311 </div>
312
313 <button id="run5">Run #5</button>
314 </div>
315 <hr/>
316
317 <h2>Query 6 - Existential Quantification</h2>
318 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700319 <div class="pretty-printed"><pre>
320 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700321
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700322 for $fbu in dataset FacebookUsers
323 where (some $e in $fbu.employment satisfies is-null($e.end-date))
324 return $fbu;
325 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700326
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700327 <div class="how-to-run"><pre><code class="javascript">
328 var expression6 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700329 .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers"))
330 .WhereClause(
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700331 new QuantifiedExpression (
332 "some" ,
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700333 {"$e" : new AExpression("$fbu.employment") },
334 new FunctionExpression("is-null", new AExpression("$e.end-date"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700335 )
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700336 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700337 .ReturnClause("$fbu");
338 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700339
340 <div class="result-output" id="result6">
341 </div>
342
343 <button id="run6">Run #6</button>
344 </div>
345 <hr/>
346
347 <h2>Query 7 - Universal Quantification</h2>
348 <div class="sample-query">
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700349 <div class="pretty-printed"><pre>
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700350 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700351
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700352 for $fbu in dataset FacebookUsers
353 where (every $e in $fbu.employment satisfies not(is-null($e.end-date)))
354 return $fbu;
355 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700356
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700357 <div class="how-to-run"><pre><code class="javascript">
358 var expression7 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700359 .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
360 .WhereClause(
361 new QuantifiedExpression (
362 "every" ,
363 {"$e" : new AExpression("$fbu.employment") },
364 new FunctionExpression("not", new FunctionExpression("is-null", new AExpression("$e.end-date")))
365 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700366 )
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700367 .ReturnClause("$fbu");
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700368 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700369
370 <div class="result-output" id="result7">
371 </div>
372
373 <button id="run7">Run #7</button>
374 </div>
375 <hr/>
376
377 <h2>Query 8 - Simple Aggregation</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 count(for $fbu in dataset FacebookUsers return $fbu);
383 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700384
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700385 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700386 var expression8 = new FunctionExpression(
387 "count",
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700388 new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700389 .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700390 .ReturnClause("$fbu")
genia.likes.science@gmail.com18f3bf22013-06-12 07:45:02 -0700391 );
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700392 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700393
394 <div class="result-output" id="result8">
395 </div>
396
397 <button id="run8">Run #8</button>
398 </div>
399 <hr/>
400
401 <h2>Query 9-A - Grouping and Aggregation</h2>
402 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700403 <div class="pretty-printed"><pre>
404 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700405
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700406 for $t in dataset TweetMessages
407 group by $uid := $t.user.screen-name with $t
408 return {
409 "user": $uid,
410 "count": count($t)
411 };
412 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700413
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700414 <div class="how-to-run"><pre><code class="javascript">
415 var expression9a = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700416 .ForClause("$t", new AExpression("dataset TweetMessages"))
417 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700418 .ReturnClause(
419 {
420 "user" : "$uid",
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700421 "count" : new FunctionExpression("count", new AExpression("$t"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700422 }
423 );
424 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700425
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700426 <div class="result-output" id="result9a">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700427 </div>
428
429 <button id="run9a">Run #9-A</button>
430 </div>
431 <hr/>
432
433 <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
434 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700435 <div class="pretty-printed"><pre>
436 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700437
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700438 for $t in dataset TweetMessages
439 /*+ hash*/
440 group by $uid := $t.user.screen-name with $t
441 return {
442 "user": $uid,
443 "count": count($t)
444 };
445 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700446
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700447 <div class="how-to-run"><pre><code class="javascript">
448 var expression9b = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700449 .ForClause("$t", new AExpression("dataset TweetMessages"))
450 .AQLClause("/*+ hash*/")
451 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700452 .ReturnClause(
453 {
454 "user" : "$uid",
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700455 "count" : new FunctionExpression("count", new AExpression("$t"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700456 }
457 );
458 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700459
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700460 <div class="result-output" id="result9b">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700461 </div>
462
463 <button id="run9b">Run #9-B</button>
464 </div>
465 <hr/>
466
467 <h2>Query 10 - Grouping and Limits</h2>
468 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700469 <div class="pretty-printed"><pre>
470 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700471
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700472 for $t in dataset TweetMessages
473 group by $uid := $t.user.screen-name with $t
474 let $c := count($t)
475 order by $c desc
476 limit 3
477 return {
478 "user": $uid,
479 "count": $c
480 };
481 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700482
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700483 <div class="how-to-run"><pre><code class="javascript">
484 var expression10 = new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700485 .ForClause("$t", new AExpression("dataset TweetMessages"))
486 .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
487 .LetClause("$c", new FunctionExpression("count", new AExpression("$t")))
488 .OrderbyClause( new AExpression("$c"), "desc" )
489 .LimitClause(new AExpression("3"))
490 .ReturnClause(
491 {
492 "user" : "$uid",
493 "count" : "$c"
494 }
495 );
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700496 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700497
genia.likes.science@gmail.comfba7cc82013-05-31 04:04:08 -0700498 <div class="result-output" id="result10">
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700499 </div>
500
501 <button id="run10">Run #10</button>
502 </div>
503 <hr/>
504
505 <h2>Query 11 - Left Outer Fuzzy Join</h2>
506 <div class="sample-query">
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700507 <div class="pretty-printed"><pre>
508 use dataverse TinySocial;
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700509
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700510 set simfunction "jaccard";
511 set simthreshold "0.3";
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700512
genia.likes.science@gmail.com80121c92013-05-29 04:58:04 -0700513 for $t in dataset TweetMessages
514 return {
515 "tweet": $t,
516 "similar-tweets": for $t2 in dataset TweetMessages
517 where $t2.referred-topics ~= $t.referred-topics
518 and $t2.tweetid != $t.tweetid
519 return $t2.referred-topics
520 };
521 </pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700522
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700523 <div class="how-to-run"><pre><code class="javascript">
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700524 var expression11 = new FLWOGRExpression()
525 .ForClause( "$t", new AExpression("dataset TweetMessages"))
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700526 .ReturnClause({
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700527 "tweet" : new AExpression("$t"),
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700528 "similar-tweets": new FLWOGRExpression()
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700529 .ForClause( "$t2", new AExpression("dataset TweetMessages"))
530 .WhereClause().and(
531 new AExpression("$t2.referred-topics ~= $t.referred-topics"),
532 new AExpression("$t2.tweetid != $t.tweetid")
533 )
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700534 .ReturnClause("$t2.referred-topics")
genia.likes.science@gmail.comd2795fb2013-07-14 15:48:04 -0700535 });
genia.likes.science@gmail.comf8cca192013-06-13 15:45:53 -0700536 </code></pre></div>
genia.likes.science@gmail.com512454d2013-05-28 03:32:20 -0700537
538 <div class="result-output" id="result11">
539 </div>
540
541 <button id="run11">Run #11</button>
542 </div>
543
544</body>
545</html>