Till Westmann | 5b431ca | 2015-10-01 19:16:11 -0700 | [diff] [blame^] | 1 | <!-- |
| 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 19 | <!DOCTYPE html> |
| 20 | |
| 21 | <html> |
| 22 | <head> |
| 23 | <title>AsterixDB TinySocial Demo</title> |
| 24 | |
| 25 | <style> |
| 26 | .pretty-printed { |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 27 | background-color: #eeeeee; |
| 28 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | .how-to-run { |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 32 | background-color: #c8c8c8; |
| 33 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | .result-output { |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 37 | background-color: #BED8E5; |
| 38 | margin-bottom: 1em; |
| 39 | overflow-x: scroll; |
| 40 | overflow-y: none; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | body { |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 44 | font-family : "Helvetica"; |
| 45 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 46 | } |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 59 | <div class="pretty-printed"><pre> |
| 60 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 61 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 62 | for $user in dataset FacebookUsers |
| 63 | where $user.id = 8 |
| 64 | return $user; |
| 65 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 66 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 67 | <div class="how-to-run"><pre><code class="javascript"> |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 68 | var expression0a = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 69 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 70 | .WhereClause(new AExpression("$user.id = 8")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 71 | .ReturnClause("$user"); |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 72 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 73 | |
genia.likes.science@gmail.com | 3861263 | 2013-05-28 13:11:52 -0700 | [diff] [blame] | 74 | <div class="result-output" id="result0a"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 75 | </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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 83 | <div class="pretty-printed"><pre> |
| 84 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 85 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 86 | for $user in dataset FacebookUsers |
| 87 | where $user.id >= 2 and $user.id <= 4 |
| 88 | return $user; |
| 89 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 90 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 91 | <div class="how-to-run"><pre><code class="javascript"> |
| 92 | var expression0b = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 93 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 96 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 97 | |
genia.likes.science@gmail.com | 3861263 | 2013-05-28 13:11:52 -0700 | [diff] [blame] | 98 | <div class="result-output" id="result0b"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 99 | </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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 107 | <div class="pretty-printed"><pre> |
| 108 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 109 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 110 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 115 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 116 | <div class="how-to-run"><pre><code class="javascript"> |
| 117 | var expression1 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 118 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 123 | .ReturnClause("$user"); |
| 124 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 125 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 135 | <div class="pretty-printed"><pre> |
| 136 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 137 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 138 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 146 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 147 | <div class="how-to-run"><pre><code class="javascript"> |
| 148 | var expression2a = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 149 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 152 | .ReturnClause({ |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 153 | "uname" : "$user.name", |
| 154 | "message" : "$message.message" |
| 155 | }); |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 156 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 157 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 167 | <div class="pretty-printed"><pre> |
| 168 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 169 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 170 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 178 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 179 | <div class="how-to-run"><pre><code class="javascript"> |
| 180 | var expression2b = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 181 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 185 | "uname" : "$user.name", |
| 186 | "message" : "$message.message" |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 187 | }); |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 188 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 189 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 199 | <div class="pretty-printed"><pre> |
| 200 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 201 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 202 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 210 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 211 | <div class="how-to-run"><pre><code class="javascript"> |
| 212 | var expression3messages = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 213 | .ForClause("$message", new AExpression("dataset FacebookMessages")) |
| 214 | .WhereClause(new AExpression("$message.author-id = $user.id")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 215 | .ReturnClause("$message.message"); |
| 216 | |
| 217 | var expression3 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 218 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 219 | .ReturnClause({ |
| 220 | "uname": "$user.name", |
| 221 | "messages" : expression3messages |
| 222 | }); |
| 223 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 224 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 234 | <div class="pretty-printed"><pre> |
| 235 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 236 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 237 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 245 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 246 | <div class="how-to-run"><pre><code class="javascript"> |
| 247 | var expression4messages = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 248 | .ForClause( "$t2", new AExpression("dataset TweetMessages")) |
| 249 | .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 250 | .ReturnClause({ "msgtxt" : "$t2.message-text" }); |
| 251 | |
| 252 | var expression4 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 253 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 254 | .ReturnClause({ |
| 255 | "message" : "$t.message-text", |
| 256 | "nearby-messages" : expression4messages |
| 257 | }); |
| 258 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 259 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 269 | <div class="pretty-printed"><pre> |
| 270 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 271 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 272 | set simfunction "edit-distance"; |
| 273 | set simthreshold "3"; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 274 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 275 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 288 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 289 | <div class="how-to-run"><pre><code class="javascript"> |
| 290 | var similarUsersExpression = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 291 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 294 | .ReturnClause({ |
| 295 | "twitter-screenname": "$tu.screen-name", |
| 296 | "twitter-name": "$tu.name" |
| 297 | }); |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 298 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 299 | var expression5 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 300 | .ForClause ("$fbu", new AExpression("dataset FacebookUsers")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 301 | .ReturnClause( |
| 302 | { |
| 303 | "id" : "$fbu.id", |
| 304 | "name" : "$fbu.name", |
| 305 | "similar-users" : similarUsersExpression |
| 306 | } |
| 307 | ); |
| 308 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 309 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 319 | <div class="pretty-printed"><pre> |
| 320 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 321 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 322 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 326 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 327 | <div class="how-to-run"><pre><code class="javascript"> |
| 328 | var expression6 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 329 | .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers")) |
| 330 | .WhereClause( |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 331 | new QuantifiedExpression ( |
| 332 | "some" , |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 333 | {"$e" : new AExpression("$fbu.employment") }, |
| 334 | new FunctionExpression("is-null", new AExpression("$e.end-date")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 335 | ) |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 336 | ) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 337 | .ReturnClause("$fbu"); |
| 338 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 339 | |
| 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.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 349 | <div class="pretty-printed"><pre> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 350 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 351 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 352 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 356 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 357 | <div class="how-to-run"><pre><code class="javascript"> |
| 358 | var expression7 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 359 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 366 | ) |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 367 | .ReturnClause("$fbu"); |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 368 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 369 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 379 | <div class="pretty-printed"><pre> |
| 380 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 381 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 382 | count(for $fbu in dataset FacebookUsers return $fbu); |
| 383 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 384 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 385 | <div class="how-to-run"><pre><code class="javascript"> |
genia.likes.science@gmail.com | 18f3bf2 | 2013-06-12 07:45:02 -0700 | [diff] [blame] | 386 | var expression8 = new FunctionExpression( |
| 387 | "count", |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 388 | new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 389 | .ForClause("$fbu", new AExpression("dataset FacebookUsers")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 390 | .ReturnClause("$fbu") |
genia.likes.science@gmail.com | 18f3bf2 | 2013-06-12 07:45:02 -0700 | [diff] [blame] | 391 | ); |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 392 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 393 | |
| 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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 403 | <div class="pretty-printed"><pre> |
| 404 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 405 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 406 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 413 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 414 | <div class="how-to-run"><pre><code class="javascript"> |
| 415 | var expression9a = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 416 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 417 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 418 | .ReturnClause( |
| 419 | { |
| 420 | "user" : "$uid", |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 421 | "count" : new FunctionExpression("count", new AExpression("$t")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 422 | } |
| 423 | ); |
| 424 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 425 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 426 | <div class="result-output" id="result9a"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 427 | </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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 435 | <div class="pretty-printed"><pre> |
| 436 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 437 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 438 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 446 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 447 | <div class="how-to-run"><pre><code class="javascript"> |
| 448 | var expression9b = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 449 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 450 | .AQLClause("/*+ hash*/") |
| 451 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 452 | .ReturnClause( |
| 453 | { |
| 454 | "user" : "$uid", |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 455 | "count" : new FunctionExpression("count", new AExpression("$t")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 456 | } |
| 457 | ); |
| 458 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 459 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 460 | <div class="result-output" id="result9b"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 461 | </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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 469 | <div class="pretty-printed"><pre> |
| 470 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 471 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 472 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 482 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 483 | <div class="how-to-run"><pre><code class="javascript"> |
| 484 | var expression10 = new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 485 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 496 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 497 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 498 | <div class="result-output" id="result10"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 499 | </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.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 507 | <div class="pretty-printed"><pre> |
| 508 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 509 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 510 | set simfunction "jaccard"; |
| 511 | set simthreshold "0.3"; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 512 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 513 | 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.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 522 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 523 | <div class="how-to-run"><pre><code class="javascript"> |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 524 | var expression11 = new FLWOGRExpression() |
| 525 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 526 | .ReturnClause({ |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 527 | "tweet" : new AExpression("$t"), |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 528 | "similar-tweets": new FLWOGRExpression() |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 529 | .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.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 534 | .ReturnClause("$t2.referred-topics") |
genia.likes.science@gmail.com | d2795fb | 2013-07-14 15:48:04 -0700 | [diff] [blame] | 535 | }); |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 536 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 537 | |
| 538 | <div class="result-output" id="result11"> |
| 539 | </div> |
| 540 | |
| 541 | <button id="run11">Run #11</button> |
| 542 | </div> |
| 543 | |
| 544 | </body> |
| 545 | </html> |