genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>AsterixDB TinySocial Demo</title> |
| 6 | |
| 7 | <style> |
| 8 | .pretty-printed { |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 9 | background-color: #eeeeee; |
| 10 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | .how-to-run { |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 14 | background-color: #c8c8c8; |
| 15 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | .result-output { |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 19 | background-color: #BED8E5; |
| 20 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | body { |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 24 | font-family : "Helvetica"; |
| 25 | margin-bottom: 1em; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 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 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 39 | <div class="pretty-printed"><pre> |
| 40 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 41 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 42 | for $user in dataset FacebookUsers |
| 43 | where $user.id = 8 |
| 44 | return $user; |
| 45 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 46 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 47 | <div class="how-to-run"><pre><code class="javascript"> |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 48 | var expression0a = new FLWOGRExpression() |
| 49 | .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers"))) |
| 50 | .bind( new WhereClause(new AExpression().set("$user.id = 8"))) |
| 51 | .ReturnClause("$user"); |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 52 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 53 | |
genia.likes.science@gmail.com | 3861263 | 2013-05-28 13:11:52 -0700 | [diff] [blame] | 54 | <div class="result-output" id="result0a"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 55 | </div> |
| 56 | |
| 57 | <button id="run0a">Run #0-A</button> |
| 58 | </div> |
| 59 | <hr/> |
| 60 | <h2>Query 0-B - Range Scan</h2> |
| 61 | <div class="sample-query"> |
| 62 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 63 | <div class="pretty-printed"><pre> |
| 64 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 65 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 66 | for $user in dataset FacebookUsers |
| 67 | where $user.id >= 2 and $user.id <= 4 |
| 68 | return $user; |
| 69 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 70 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 71 | <div class="how-to-run"><pre><code class="javascript"> |
| 72 | var expression0b = new FLWOGRExpression() |
| 73 | .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers"))) |
| 74 | .bind( new WhereClause().and( |
| 75 | new AExpression().set("$user.id >= 2"), |
| 76 | new AExpression().set("$user.id <= 4") |
| 77 | )) |
| 78 | .ReturnClause("$user"); |
| 79 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 80 | |
genia.likes.science@gmail.com | 3861263 | 2013-05-28 13:11:52 -0700 | [diff] [blame] | 81 | <div class="result-output" id="result0b"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 82 | </div> |
| 83 | |
| 84 | <button id="run0b">Run #0-B</button> |
| 85 | </div> |
| 86 | <hr/> |
| 87 | |
| 88 | <h2>Query 1 - Other Query Filters</h2> |
| 89 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 90 | <div class="pretty-printed"><pre> |
| 91 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 92 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 93 | for $user in dataset FacebookUsers |
| 94 | where $user.user-since >= datetime('2010-07-22T00:00:00') |
| 95 | and $user.user-since <= datetime('2012-07-29T23:59:59') |
| 96 | return $user; |
| 97 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 98 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 99 | <div class="how-to-run"><pre><code class="javascript"> |
| 100 | var expression1 = new FLWOGRExpression() |
| 101 | .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers"))) |
| 102 | .bind( new WhereClause().and( |
| 103 | new AExpression().set("$user.user-since >= datetime('2010-07-22T00:00:00')"), |
| 104 | new AExpression().set("$user.user-since <= datetime('2012-07-29T23:59:59')") |
| 105 | )) |
| 106 | .ReturnClause("$user"); |
| 107 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 108 | |
| 109 | <div class="result-output" id="result1"> |
| 110 | </div> |
| 111 | |
| 112 | <button id="run1">Run #1</button> |
| 113 | </div> |
| 114 | <hr/> |
| 115 | |
| 116 | <h2>Query 2-A - Equijoin</h2> |
| 117 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 118 | <div class="pretty-printed"><pre> |
| 119 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 120 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 121 | for $user in dataset FacebookUsers |
| 122 | for $message in dataset FacebookMessages |
| 123 | where $message.author-id = $user.id |
| 124 | return { |
| 125 | "uname": $user.name, |
| 126 | "message": $message.message |
| 127 | }; |
| 128 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 129 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 130 | <div class="how-to-run"><pre><code class="javascript"> |
| 131 | var expression2a = new FLWOGRExpression() |
| 132 | .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers"))) |
| 133 | .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages"))) |
| 134 | .bind( new WhereClause (new AExpression().set("$message.author-id = $user.id"))) |
| 135 | .ReturnClause({ |
| 136 | "uname" : "$user.name", |
| 137 | "message" : "$message.message" |
| 138 | }); |
| 139 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 140 | |
| 141 | <div class="result-output" id="result2a"> |
| 142 | </div> |
| 143 | |
| 144 | <button id="run2a">Run #2-A</button> |
| 145 | </div> |
| 146 | <hr/> |
| 147 | |
| 148 | <h2>Query 2-B - Index join</h2> |
| 149 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 150 | <div class="pretty-printed"><pre> |
| 151 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 152 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 153 | for $user in dataset FacebookUsers |
| 154 | for $message in dataset FacebookMessages |
| 155 | where $message.author-id /*+ indexnl */ = $user.id |
| 156 | return { |
| 157 | "uname": $user.name, |
| 158 | "message": $message.message |
| 159 | }; |
| 160 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 161 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 162 | <div class="how-to-run"><pre><code class="javascript"> |
| 163 | var expression2b = new FLWOGRExpression() |
| 164 | .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers"))) |
| 165 | .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages"))) |
| 166 | .bind( new WhereClause (new AExpression().set("$message.author-id /*+ indexnl */ = $user.id"))) |
| 167 | .ReturnClause( |
| 168 | { |
| 169 | "uname" : "$user.name", |
| 170 | "message" : "$message.message" |
| 171 | } |
| 172 | ); |
| 173 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 174 | |
| 175 | <div class="result-output" id="result2b"> |
| 176 | </div> |
| 177 | |
| 178 | <button id="run2b">Run #2-B</button> |
| 179 | </div> |
| 180 | <hr/> |
| 181 | |
| 182 | <h2>Query 3 - Nested Outer Join</h2> |
| 183 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 184 | <div class="pretty-printed"><pre> |
| 185 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 186 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 187 | for $user in dataset FacebookUsers |
| 188 | return { |
| 189 | "uname": $user.name, |
| 190 | "messages": for $message in dataset FacebookMessages |
| 191 | where $message.author-id = $user.id |
| 192 | return $message.message |
| 193 | }; |
| 194 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 195 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 196 | <div class="how-to-run"><pre><code class="javascript"> |
| 197 | var expression3messages = new FLWOGRExpression() |
| 198 | .bind( new ForClause("message", new AExpression().set("dataset FacebookMessages"))) |
| 199 | .bind( new WhereClause(new AExpression().set("$message.author-id = $user.id"))) |
| 200 | .ReturnClause("$message.message"); |
| 201 | |
| 202 | var expression3 = new FLWOGRExpression() |
| 203 | .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers"))) |
| 204 | .ReturnClause({ |
| 205 | "uname": "$user.name", |
| 206 | "messages" : expression3messages |
| 207 | }); |
| 208 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 209 | |
| 210 | <div class="result-output" id="result3"> |
| 211 | </div> |
| 212 | |
| 213 | <button id="run3">Run #3</button> |
| 214 | </div> |
| 215 | <hr/> |
| 216 | |
| 217 | <h2>Query 4 - Theta Join</h2> |
| 218 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 219 | <div class="pretty-printed"><pre> |
| 220 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 221 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 222 | for $t in dataset TweetMessages |
| 223 | return { |
| 224 | "message": $t.message-text, |
| 225 | "nearby-messages": for $t2 in dataset TweetMessages |
| 226 | where spatial-distance($t.sender-location, $t2.sender-location) <= 1 |
| 227 | return { "msgtxt":$t2.message-text} |
| 228 | }; |
| 229 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 230 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 231 | <div class="how-to-run"><pre><code class="javascript"> |
| 232 | var expression4messages = new FLWOGRExpression() |
| 233 | .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages"))) |
| 234 | .bind( new WhereClause( new AExpression().set("spatial-distance($t.sender-location, $t2.sender-location) <= 1"))) |
| 235 | .ReturnClause({ "msgtxt" : "$t2.message-text" }); |
| 236 | |
| 237 | var expression4 = new FLWOGRExpression() |
| 238 | .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") )) |
| 239 | .ReturnClause({ |
| 240 | "message" : "$t.message-text", |
| 241 | "nearby-messages" : expression4messages |
| 242 | }); |
| 243 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 244 | |
| 245 | <div class="result-output" id="result4"> |
| 246 | </div> |
| 247 | |
| 248 | <button id="run4">Run #4</button> |
| 249 | </div> |
| 250 | <hr/> |
| 251 | |
| 252 | <h2>Query 5 - Fuzzy Join</h2> |
| 253 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 254 | <div class="pretty-printed"><pre> |
| 255 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 256 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 257 | set simfunction "edit-distance"; |
| 258 | set simthreshold "3"; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 259 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 260 | for $fbu in dataset FacebookUsers |
| 261 | return { |
| 262 | "id": $fbu.id, |
| 263 | "name": $fbu.name, |
| 264 | "similar-users": for $t in dataset TweetMessages |
| 265 | let $tu := $t.user |
| 266 | where $tu.name ~= $fbu.name |
| 267 | return { |
| 268 | "twitter-screenname": $tu.screen-name, |
| 269 | "twitter-name": $tu.name |
| 270 | } |
| 271 | }; |
| 272 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 273 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 274 | <div class="how-to-run"><pre><code class="javascript"> |
| 275 | var similarUsersExpression = new FLWOGRExpression() |
| 276 | .bind( new ForClause ("t", new AQLClause().set("dataset TweetMessages"))) |
| 277 | .bind( new LetClause ("tu", new AExpression().set("$t.user"))) |
| 278 | .bind( new WhereClause (new AExpression().set("$tu.name ~= $fbu.name"))) |
| 279 | .ReturnClause({ |
| 280 | "twitter-screenname": "$tu.screen-name", |
| 281 | "twitter-name": "$tu.name" |
| 282 | }); |
| 283 | |
| 284 | var expression5 = new FLWOGRExpression() |
| 285 | .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers"))) |
| 286 | .ReturnClause( |
| 287 | { |
| 288 | "id" : "$fbu.id", |
| 289 | "name" : "$fbu.name", |
| 290 | "similar-users" : similarUsersExpression |
| 291 | } |
| 292 | ); |
| 293 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 294 | |
| 295 | <div class="result-output" id="result5"> |
| 296 | </div> |
| 297 | |
| 298 | <button id="run5">Run #5</button> |
| 299 | </div> |
| 300 | <hr/> |
| 301 | |
| 302 | <h2>Query 6 - Existential Quantification</h2> |
| 303 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 304 | <div class="pretty-printed"><pre> |
| 305 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 306 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 307 | for $fbu in dataset FacebookUsers |
| 308 | where (some $e in $fbu.employment satisfies is-null($e.end-date)) |
| 309 | return $fbu; |
| 310 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 311 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 312 | <div class="how-to-run"><pre><code class="javascript"> |
| 313 | var expression6 = new FLWOGRExpression() |
| 314 | .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers"))) |
| 315 | .bind( new WhereClause ( |
| 316 | new QuantifiedExpression ( |
| 317 | "some" , |
| 318 | {"$e" : new AQLClause().set("$fbu.employment") }, |
| 319 | new AQLClause().set("is-null($e.end-date)") |
| 320 | ) |
| 321 | )) |
| 322 | .ReturnClause("$fbu"); |
| 323 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 324 | |
| 325 | <div class="result-output" id="result6"> |
| 326 | </div> |
| 327 | |
| 328 | <button id="run6">Run #6</button> |
| 329 | </div> |
| 330 | <hr/> |
| 331 | |
| 332 | <h2>Query 7 - Universal Quantification</h2> |
| 333 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 334 | <div class="pretty-printed"><pre><pre> |
| 335 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 336 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 337 | for $fbu in dataset FacebookUsers |
| 338 | where (every $e in $fbu.employment satisfies not(is-null($e.end-date))) |
| 339 | return $fbu; |
| 340 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 341 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 342 | <div class="how-to-run"><pre><code class="javascript"> |
| 343 | var expression7 = new FLWOGRExpression() |
| 344 | .bind( new ForClause ( |
| 345 | "fbu", |
| 346 | new AQLClause().set("dataset FacebookUsers") |
| 347 | )) |
| 348 | .bind( new WhereClause ( |
| 349 | new QuantifiedExpression ( |
| 350 | "every" , |
| 351 | {"$e" : new AQLClause().set("$fbu.employment") }, |
| 352 | new AQLClause().set("not(is-null($e.end-date))") |
| 353 | ) |
| 354 | )) |
| 355 | .ReturnClause("$fbu"); |
| 356 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 357 | |
| 358 | <div class="result-output" id="result7"> |
| 359 | </div> |
| 360 | |
| 361 | <button id="run7">Run #7</button> |
| 362 | </div> |
| 363 | <hr/> |
| 364 | |
| 365 | <h2>Query 8 - Simple Aggregation</h2> |
| 366 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 367 | <div class="pretty-printed"><pre> |
| 368 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 369 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 370 | count(for $fbu in dataset FacebookUsers return $fbu); |
| 371 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 372 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 373 | <div class="how-to-run"><pre><code class="javascript"> |
genia.likes.science@gmail.com | 18f3bf2 | 2013-06-12 07:45:02 -0700 | [diff] [blame] | 374 | var expression8 = new FunctionExpression( |
| 375 | "count", |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 376 | new FLWOGRExpression() |
| 377 | .bind( new ForClause("fbu", new AQLClause().set("dataset FacebookUsers"))) |
| 378 | .ReturnClause("$fbu") |
genia.likes.science@gmail.com | 18f3bf2 | 2013-06-12 07:45:02 -0700 | [diff] [blame] | 379 | ); |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 380 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 381 | |
| 382 | <div class="result-output" id="result8"> |
| 383 | </div> |
| 384 | |
| 385 | <button id="run8">Run #8</button> |
| 386 | </div> |
| 387 | <hr/> |
| 388 | |
| 389 | <h2>Query 9-A - Grouping and Aggregation</h2> |
| 390 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 391 | <div class="pretty-printed"><pre> |
| 392 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 393 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 394 | for $t in dataset TweetMessages |
| 395 | group by $uid := $t.user.screen-name with $t |
| 396 | return { |
| 397 | "user": $uid, |
| 398 | "count": count($t) |
| 399 | }; |
| 400 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 401 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 402 | <div class="how-to-run"><pre><code class="javascript"> |
| 403 | var expression9a = new FLWOGRExpression() |
| 404 | .bind( new ForClause("t", new AExpression().set("dataset TweetMessages"))) |
| 405 | .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") ) |
| 406 | .ReturnClause( |
| 407 | { |
| 408 | "user" : "$uid", |
| 409 | "count" : new FunctionExpression("count", new AExpression().set("$t")) |
| 410 | } |
| 411 | ); |
| 412 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 413 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 414 | <div class="result-output" id="result9a"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 415 | </div> |
| 416 | |
| 417 | <button id="run9a">Run #9-A</button> |
| 418 | </div> |
| 419 | <hr/> |
| 420 | |
| 421 | <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2> |
| 422 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 423 | <div class="pretty-printed"><pre> |
| 424 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 425 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 426 | for $t in dataset TweetMessages |
| 427 | /*+ hash*/ |
| 428 | group by $uid := $t.user.screen-name with $t |
| 429 | return { |
| 430 | "user": $uid, |
| 431 | "count": count($t) |
| 432 | }; |
| 433 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 434 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 435 | <div class="how-to-run"><pre><code class="javascript"> |
| 436 | var expression9b = new FLWOGRExpression() |
| 437 | .bind( new ForClause("t", new AExpression().set("dataset TweetMessages"))) |
| 438 | .bind( new AQLClause().set("/*+ hash*/")) |
| 439 | .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") ) |
| 440 | .ReturnClause( |
| 441 | { |
| 442 | "user" : "$uid", |
| 443 | "count" : new FunctionExpression("count", new AExpression().set("$t")) |
| 444 | } |
| 445 | ); |
| 446 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 447 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 448 | <div class="result-output" id="result9b"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 449 | </div> |
| 450 | |
| 451 | <button id="run9b">Run #9-B</button> |
| 452 | </div> |
| 453 | <hr/> |
| 454 | |
| 455 | <h2>Query 10 - Grouping and Limits</h2> |
| 456 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 457 | <div class="pretty-printed"><pre> |
| 458 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 459 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 460 | for $t in dataset TweetMessages |
| 461 | group by $uid := $t.user.screen-name with $t |
| 462 | let $c := count($t) |
| 463 | order by $c desc |
| 464 | limit 3 |
| 465 | return { |
| 466 | "user": $uid, |
| 467 | "count": $c |
| 468 | }; |
| 469 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 470 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 471 | <div class="how-to-run"><pre><code class="javascript"> |
| 472 | var expression10 = new FLWOGRExpression() |
| 473 | .bind( new ForClause("t", new AExpression().set("dataset TweetMessages"))) |
| 474 | .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") ) |
| 475 | .bind( new LetClause( |
| 476 | "c", |
| 477 | new FunctionExpression("count", new AExpression().set("$t")) |
| 478 | )) |
| 479 | .bind( new OrderbyClause( new AExpression().set("$c"), "desc" ) ) |
| 480 | .bind( new LimitClause(new AExpression().set("3")) ) |
| 481 | .ReturnClause( |
| 482 | { |
| 483 | "user" : "$uid", |
| 484 | "count" : "$c" |
| 485 | } |
| 486 | ); |
| 487 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 488 | |
genia.likes.science@gmail.com | fba7cc8 | 2013-05-31 04:04:08 -0700 | [diff] [blame] | 489 | <div class="result-output" id="result10"> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 490 | </div> |
| 491 | |
| 492 | <button id="run10">Run #10</button> |
| 493 | </div> |
| 494 | <hr/> |
| 495 | |
| 496 | <h2>Query 11 - Left Outer Fuzzy Join</h2> |
| 497 | <div class="sample-query"> |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 498 | <div class="pretty-printed"><pre> |
| 499 | use dataverse TinySocial; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 500 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 501 | set simfunction "jaccard"; |
| 502 | set simthreshold "0.3"; |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 503 | |
genia.likes.science@gmail.com | 80121c9 | 2013-05-29 04:58:04 -0700 | [diff] [blame] | 504 | for $t in dataset TweetMessages |
| 505 | return { |
| 506 | "tweet": $t, |
| 507 | "similar-tweets": for $t2 in dataset TweetMessages |
| 508 | where $t2.referred-topics ~= $t.referred-topics |
| 509 | and $t2.tweetid != $t.tweetid |
| 510 | return $t2.referred-topics |
| 511 | }; |
| 512 | </pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 513 | |
genia.likes.science@gmail.com | f8cca19 | 2013-06-13 15:45:53 -0700 | [diff] [blame] | 514 | <div class="how-to-run"><pre><code class="javascript"> |
| 515 | var expression11 = new FLWOGRExpression() |
| 516 | .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") )) |
| 517 | .ReturnClause({ |
| 518 | "tweet" : new AExpression().set("$t"), |
| 519 | "similar-tweets": new FLWOGRExpression() |
| 520 | .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages") )) |
| 521 | .bind( new WhereClause().and( |
| 522 | new AExpression().set("$t2.referred-topics ~= $t.referred-topics"), |
| 523 | new AExpression().set("$t2.tweetid != $t.tweetid") |
| 524 | )) |
| 525 | .ReturnClause("$t2.referred-topics") |
| 526 | }); |
| 527 | </code></pre></div> |
genia.likes.science@gmail.com | 512454d | 2013-05-28 03:32:20 -0700 | [diff] [blame] | 528 | |
| 529 | <div class="result-output" id="result11"> |
| 530 | </div> |
| 531 | |
| 532 | <button id="run11">Run #11</button> |
| 533 | </div> |
| 534 | |
| 535 | </body> |
| 536 | </html> |