Ian Maxon | e2b799e | 2015-11-24 18:20:03 -0800 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | | Generated by Apache Maven Doxia at 2015-11-24 |
| 4 | | Rendered using Apache Maven Fluido Skin 1.3.0 |
| 5 | --> |
| 6 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 7 | <head> |
| 8 | <meta charset="UTF-8" /> |
| 9 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 10 | <meta name="Date-Revision-yyyymmdd" content="20151124" /> |
| 11 | <meta http-equiv="Content-Language" content="en" /> |
| 12 | <title>AsterixDB – AsterixDB Javascript SDK</title> |
| 13 | <link rel="stylesheet" href="../css/apache-maven-fluido-1.3.0.min.css" /> |
| 14 | <link rel="stylesheet" href="../css/site.css" /> |
| 15 | <link rel="stylesheet" href="../css/print.css" media="print" /> |
| 16 | |
| 17 | |
| 18 | <script type="text/javascript" src="../js/apache-maven-fluido-1.3.0.min.js"></script> |
| 19 | |
| 20 | |
| 21 | |
| 22 | <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| 23 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| 24 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| 25 | })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| 26 | |
| 27 | ga('create', 'UA-41536543-1', 'uci.edu'); |
| 28 | ga('send', 'pageview');</script> |
| 29 | |
| 30 | </head> |
| 31 | <body class="topBarDisabled"> |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | <div class="container-fluid"> |
| 37 | <div id="banner"> |
| 38 | <div class="pull-left"> |
| 39 | <a href="http://asterixdb.apache.org/" id="bannerLeft"> |
| 40 | <img src="../images/asterixlogo.png" alt="AsterixDB"/> |
| 41 | </a> |
| 42 | </div> |
| 43 | <div class="pull-right"> </div> |
| 44 | <div class="clear"><hr/></div> |
| 45 | </div> |
| 46 | |
| 47 | <div id="breadcrumbs"> |
| 48 | <ul class="breadcrumb"> |
| 49 | |
| 50 | |
| 51 | <li id="publishDate">Last Published: 2015-11-24</li> |
| 52 | |
| 53 | |
| 54 | |
| 55 | <li id="projectVersion" class="pull-right">Version: 0.8.7-incubating</li> |
| 56 | |
| 57 | <li class="divider pull-right">|</li> |
| 58 | |
| 59 | <li class="pull-right"> <a href="../index.html" title="Documentation Home"> |
| 60 | Documentation Home</a> |
| 61 | </li> |
| 62 | |
| 63 | </ul> |
| 64 | </div> |
| 65 | |
| 66 | |
| 67 | <div class="row-fluid"> |
| 68 | <div id="leftColumn" class="span3"> |
| 69 | <div class="well sidebar-nav"> |
| 70 | |
| 71 | |
| 72 | <ul class="nav nav-list"> |
| 73 | <li class="nav-header">Documentation</li> |
| 74 | |
| 75 | <li> |
| 76 | |
| 77 | <a href="../install.html" title="Installing and Managing AsterixDB using Managix"> |
| 78 | <i class="none"></i> |
| 79 | Installing and Managing AsterixDB using Managix</a> |
| 80 | </li> |
| 81 | |
| 82 | <li> |
| 83 | |
| 84 | <a href="../yarn.html" title="Deploying AsterixDB using YARN"> |
| 85 | <i class="none"></i> |
| 86 | Deploying AsterixDB using YARN</a> |
| 87 | </li> |
| 88 | |
| 89 | <li> |
| 90 | |
| 91 | <a href="../aql/primer.html" title="AsterixDB 101: An ADM and AQL Primer"> |
| 92 | <i class="none"></i> |
| 93 | AsterixDB 101: An ADM and AQL Primer</a> |
| 94 | </li> |
| 95 | |
| 96 | <li> |
| 97 | |
| 98 | <a href="../aql/primer-sql-like.html" title="AsterixDB 101: An ADM and AQL Primer (For SQL Fans)"> |
| 99 | <i class="none"></i> |
| 100 | AsterixDB 101: An ADM and AQL Primer (For SQL Fans)</a> |
| 101 | </li> |
| 102 | |
| 103 | <li class="active"> |
| 104 | |
| 105 | <a href="#"><i class="none"></i>AsterixDB Javascript SDK</a> |
| 106 | </li> |
| 107 | |
| 108 | <li> |
| 109 | |
| 110 | <a href="../aql/datamodel.html" title="Asterix Data Model (ADM)"> |
| 111 | <i class="none"></i> |
| 112 | Asterix Data Model (ADM)</a> |
| 113 | </li> |
| 114 | |
| 115 | <li> |
| 116 | |
| 117 | <a href="../aql/manual.html" title="Asterix Query Language (AQL)"> |
| 118 | <i class="none"></i> |
| 119 | Asterix Query Language (AQL)</a> |
| 120 | </li> |
| 121 | |
| 122 | <li> |
| 123 | |
| 124 | <a href="../aql/functions.html" title="AQL Functions"> |
| 125 | <i class="none"></i> |
| 126 | AQL Functions</a> |
| 127 | </li> |
| 128 | |
| 129 | <li> |
| 130 | |
| 131 | <a href="../aql/allens.html" title="AQL Allen's Relations Functions"> |
| 132 | <i class="none"></i> |
| 133 | AQL Allen's Relations Functions</a> |
| 134 | </li> |
| 135 | |
| 136 | <li> |
| 137 | |
| 138 | <a href="../aql/similarity.html" title="AQL Support of Similarity Queries"> |
| 139 | <i class="none"></i> |
| 140 | AQL Support of Similarity Queries</a> |
| 141 | </li> |
| 142 | |
| 143 | <li> |
| 144 | |
| 145 | <a href="../aql/externaldata.html" title="Accessing External Data"> |
| 146 | <i class="none"></i> |
| 147 | Accessing External Data</a> |
| 148 | </li> |
| 149 | |
| 150 | <li> |
| 151 | |
| 152 | <a href="../feeds/tutorial.html" title="Support for Data Ingestion in AsterixDB"> |
| 153 | <i class="none"></i> |
| 154 | Support for Data Ingestion in AsterixDB</a> |
| 155 | </li> |
| 156 | |
| 157 | <li> |
| 158 | |
| 159 | <a href="../udf.html" title="Support for User Defined Functions in AsterixDB"> |
| 160 | <i class="none"></i> |
| 161 | Support for User Defined Functions in AsterixDB</a> |
| 162 | </li> |
| 163 | |
| 164 | <li> |
| 165 | |
| 166 | <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration"> |
| 167 | <i class="none"></i> |
| 168 | Filter-Based LSM Index Acceleration</a> |
| 169 | </li> |
| 170 | |
| 171 | <li> |
| 172 | |
| 173 | <a href="../api.html" title="HTTP API to AsterixDB"> |
| 174 | <i class="none"></i> |
| 175 | HTTP API to AsterixDB</a> |
| 176 | </li> |
| 177 | </ul> |
| 178 | |
| 179 | |
| 180 | |
| 181 | <hr class="divider" /> |
| 182 | |
| 183 | <div id="poweredBy"> |
| 184 | <div class="clear"></div> |
| 185 | <div class="clear"></div> |
| 186 | <div class="clear"></div> |
| 187 | <a href="https://code.google.com/p/hyracks/" title="Hyracks" class="builtBy"> |
| 188 | <img class="builtBy" alt="Hyracks" src="../images/hyrax_ts.png" /> |
| 189 | </a> |
| 190 | </div> |
| 191 | </div> |
| 192 | </div> |
| 193 | |
| 194 | |
| 195 | <div id="bodyColumn" class="span9" > |
| 196 | |
| 197 | <!-- ! Licensed to the Apache Software Foundation (ASF) under one |
| 198 | ! or more contributor license agreements. See the NOTICE file |
| 199 | ! distributed with this work for additional information |
| 200 | ! regarding copyright ownership. The ASF licenses this file |
| 201 | ! to you under the Apache License, Version 2.0 (the |
| 202 | ! "License"); you may not use this file except in compliance |
| 203 | ! with the License. You may obtain a copy of the License at |
| 204 | ! |
| 205 | ! http://www.apache.org/licenses/LICENSE-2.0 |
| 206 | ! |
| 207 | ! Unless required by applicable law or agreed to in writing, |
| 208 | ! software distributed under the License is distributed on an |
| 209 | ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 210 | ! KIND, either express or implied. See the License for the |
| 211 | ! specific language governing permissions and limitations |
| 212 | ! under the License. |
| 213 | ! --><h1>AsterixDB Javascript SDK</h1> |
| 214 | <div class="section"> |
| 215 | <h2><a name="Obtaining_and_Including"></a>Obtaining and Including</h2> |
| 216 | <p><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/bindings/asterix-sdk-stable.js">Download</a> the javascript SDK and include it like any other javascript library by adding the following line in the appropriate HTML file:</p> |
| 217 | |
| 218 | <div class="source"> |
| 219 | <div class="source"> |
| 220 | <pre><script src="path/to/asterix-sdk-stable.js"></script> |
| 221 | </pre></div></div></div> |
| 222 | <div class="section"> |
| 223 | <h2><a name="Interactive_Demos"></a>Interactive Demos</h2> |
| 224 | <p>There are two interactive demos that are available for download. Both of the demos illustrate how the javascript API would be used in an application:</p> |
| 225 | |
| 226 | <ul> |
| 227 | |
| 228 | <li><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/demos/tweetbook-demo.zip">Tweetbook Demo</a>: a contrived geo-spatial application dealing with artificial Tweets allowing spatial, temporal, and keyword-based filtering.</li> |
| 229 | |
| 230 | <li><a class="externalLink" href="http://asterixdb.ics.uci.edu/download/demos/admaql101-demo.zip">ADM/AQL 101 Demo</a>: an interactive version of all of the examples that are provided in the following section.</li> |
| 231 | </ul></div> |
| 232 | <div class="section"> |
| 233 | <h2><a name="The_javascript_SDK:_by_example"></a>The javascript SDK: by example</h2> |
| 234 | <p>In this section, we explore how to form AQL queries using the javascript SDK. The queries from <a href="primer.html">AsterixDB 101: An ADM and AQL Primer</a> are used as examples here. For each AQL statement, the equivalent javascript expression is shown below it, followed by the results of executing the query.</p> |
| 235 | <div class="section"> |
| 236 | <h3><a name="Query_0-A_-_Exact-Match_Lookup"></a>Query 0-A - Exact-Match Lookup</h3> |
| 237 | <div class="section"> |
| 238 | <div class="section"> |
| 239 | <div class="section"> |
| 240 | <h6><a name="AQL"></a>AQL</h6> |
| 241 | |
| 242 | <div class="source"> |
| 243 | <div class="source"> |
| 244 | <pre>use dataverse TinySocial; |
| 245 | |
| 246 | for $user in dataset FacebookUsers |
| 247 | where $user.id = 8 |
| 248 | return $user; |
| 249 | </pre></div></div></div> |
| 250 | <div class="section"> |
| 251 | <h6><a name="JS"></a>JS</h6> |
| 252 | |
| 253 | <div class="source"> |
| 254 | <div class="source"> |
| 255 | <pre>var expression0a = new FLWOGRExpression() |
| 256 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 257 | .WhereClause(new AExpression("$user.id = 8")) |
| 258 | .ReturnClause("$user"); |
| 259 | </pre></div></div></div> |
| 260 | <div class="section"> |
| 261 | <h6><a name="Results"></a>Results</h6> |
| 262 | |
| 263 | <div class="source"> |
| 264 | <div class="source"> |
| 265 | <pre>{ "id": { int32: 8 } , "alias": "Nila", "name": "NilaMilliron", "user-since": { datetime: 1199182200000}, "friend-ids": { unorderedlist: [{ int32: 3 } ]}, "employment": { orderedlist: [{ "organization-name": "Plexlane", "start-date": { date: 1267315200000}, "end-date": null } ]} } |
| 266 | </pre></div></div></div></div></div></div> |
| 267 | <div class="section"> |
| 268 | <h3><a name="Query_0-B_-_Range_Scan"></a>Query 0-B - Range Scan</h3> |
| 269 | <div class="section"> |
| 270 | <div class="section"> |
| 271 | <div class="section"> |
| 272 | <h6><a name="AQL"></a>AQL</h6> |
| 273 | |
| 274 | <div class="source"> |
| 275 | <div class="source"> |
| 276 | <pre>use dataverse TinySocial; |
| 277 | |
| 278 | for $user in dataset FacebookUsers |
| 279 | where $user.id >= 2 and $user.id <= 4 |
| 280 | return $user; |
| 281 | </pre></div></div></div> |
| 282 | <div class="section"> |
| 283 | <h6><a name="JS"></a>JS</h6> |
| 284 | |
| 285 | <div class="source"> |
| 286 | <div class="source"> |
| 287 | <pre>var expression0b = new FLWOGRExpression() |
| 288 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 289 | .WhereClause().and(new AExpression("$user.id >= 2"), new AExpression("$user.id <= 4")) |
| 290 | .ReturnClause("$user"); |
| 291 | </pre></div></div></div> |
| 292 | <div class="section"> |
| 293 | <h6><a name="Results"></a>Results</h6> |
| 294 | |
| 295 | <div class="source"> |
| 296 | <div class="source"> |
| 297 | <pre>{ "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} } |
| 298 | { "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} } |
| 299 | { "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} } |
| 300 | </pre></div></div></div></div></div></div> |
| 301 | <div class="section"> |
| 302 | <h3><a name="Query_1_-_Other_Query_Filters"></a>Query 1 - Other Query Filters</h3> |
| 303 | <div class="section"> |
| 304 | <div class="section"> |
| 305 | <div class="section"> |
| 306 | <h6><a name="AQL"></a>AQL</h6> |
| 307 | |
| 308 | <div class="source"> |
| 309 | <div class="source"> |
| 310 | <pre>use dataverse TinySocial; |
| 311 | |
| 312 | for $user in dataset FacebookUsers |
| 313 | where $user.user-since >= datetime('2010-07-22T00:00:00') |
| 314 | and $user.user-since <= datetime('2012-07-29T23:59:59') |
| 315 | return $user; |
| 316 | </pre></div></div></div> |
| 317 | <div class="section"> |
| 318 | <h6><a name="JS"></a>JS</h6> |
| 319 | |
| 320 | <div class="source"> |
| 321 | <div class="source"> |
| 322 | <pre>var expression1 = new FLWOGRExpression() |
| 323 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 324 | .WhereClause().and( |
| 325 | new AExpression("$user.user-since >= datetime('2010-07-22T00:00:00')"), |
| 326 | new AExpression("$user.user-since <= datetime('2012-07-29T23:59:59')") |
| 327 | ).ReturnClause("$user"); |
| 328 | </pre></div></div></div> |
| 329 | <div class="section"> |
| 330 | <h6><a name="Results"></a>Results</h6> |
| 331 | |
| 332 | <div class="source"> |
| 333 | <div class="source"> |
| 334 | <pre>{ "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} } |
| 335 | { "id": { int32: 10 } , "alias": "Bram", "name": "BramHatch", "user-since": { datetime: 1287223800000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "physcane", "start-date": { date: 1181001600000}, "end-date": { date: 1320451200000} } ]} } |
| 336 | { "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} } |
| 337 | { "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} } |
| 338 | </pre></div></div></div></div></div></div> |
| 339 | <div class="section"> |
| 340 | <h3><a name="Query_2-A_-_Equijoin"></a>Query 2-A - Equijoin</h3> |
| 341 | <div class="section"> |
| 342 | <div class="section"> |
| 343 | <div class="section"> |
| 344 | <h6><a name="AQL"></a>AQL</h6> |
| 345 | |
| 346 | <div class="source"> |
| 347 | <div class="source"> |
| 348 | <pre>use dataverse TinySocial; |
| 349 | |
| 350 | for $user in dataset FacebookUsers |
| 351 | for $message in dataset FacebookMessages |
| 352 | where $message.author-id = $user.id |
| 353 | return { |
| 354 | "uname": $user.name, |
| 355 | "message": $message.message |
| 356 | }; |
| 357 | </pre></div></div></div> |
| 358 | <div class="section"> |
| 359 | <h6><a name="JS"></a>JS</h6> |
| 360 | |
| 361 | <div class="source"> |
| 362 | <div class="source"> |
| 363 | <pre>var expression2a = new FLWOGRExpression() |
| 364 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 365 | .ForClause ("$message", new AExpression("dataset FacebookMessages")) |
| 366 | .WhereClause(new AExpression("$message.author-id = $user.id")) |
| 367 | .ReturnClause({ |
| 368 | "uname" : "$user.name", |
| 369 | "message" : "$message.message" |
| 370 | }); |
| 371 | </pre></div></div></div> |
| 372 | <div class="section"> |
| 373 | <h6><a name="Results"></a>Results</h6> |
| 374 | |
| 375 | <div class="source"> |
| 376 | <div class="source"> |
| 377 | <pre>{ "uname": "MargaritaStoddard", "message": " dislike iphone its touch-screen is horrible" } |
| 378 | { "uname": "MargaritaStoddard", "message": " like verizon the 3G is awesome:)" } |
| 379 | { "uname": "MargaritaStoddard", "message": " can't stand motorola the touch-screen is terrible" } |
| 380 | { "uname": "MargaritaStoddard", "message": " can't stand at&t the network is horrible:(" } |
| 381 | { "uname": "MargaritaStoddard", "message": " can't stand at&t its plan is terrible" } |
| 382 | { "uname": "IsbelDull", "message": " like samsung the plan is amazing" } |
| 383 | { "uname": "IsbelDull", "message": " like t-mobile its platform is mind-blowing" } |
| 384 | { "uname": "WoodrowNehling", "message": " love at&t its 3G is good:)" } |
| 385 | { "uname": "BramHatch", "message": " dislike iphone the voice-command is bad:(" } |
| 386 | { "uname": "BramHatch", "message": " can't stand t-mobile its voicemail-service is OMG:(" } |
| 387 | { "uname": "EmoryUnk", "message": " love sprint its shortcut-menu is awesome:)" } |
| 388 | { "uname": "EmoryUnk", "message": " love verizon its wireless is good" } |
| 389 | { "uname": "WillisWynne", "message": " love sprint the customization is mind-blowing" } |
| 390 | { "uname": "SuzannaTillson", "message": " like iphone the voicemail-service is awesome" } |
| 391 | { "uname": "VonKemble", "message": " dislike sprint the speed is horrible" } |
| 392 | </pre></div></div></div></div></div></div> |
| 393 | <div class="section"> |
| 394 | <h3><a name="Query_2-B_-_Index_join"></a>Query 2-B - Index join</h3> |
| 395 | <div class="section"> |
| 396 | <div class="section"> |
| 397 | <div class="section"> |
| 398 | <h6><a name="AQL"></a>AQL</h6> |
| 399 | |
| 400 | <div class="source"> |
| 401 | <div class="source"> |
| 402 | <pre>use dataverse TinySocial; |
| 403 | |
| 404 | for $user in dataset FacebookUsers |
| 405 | for $message in dataset FacebookMessages |
| 406 | where $message.author-id /*+ indexnl */ = $user.id |
| 407 | return { |
| 408 | "uname": $user.name, |
| 409 | "message": $message.message |
| 410 | }; |
| 411 | </pre></div></div></div> |
| 412 | <div class="section"> |
| 413 | <h6><a name="JS"></a>JS</h6> |
| 414 | |
| 415 | <div class="source"> |
| 416 | <div class="source"> |
| 417 | <pre>var expression2b = new FLWOGRExpression() |
| 418 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 419 | .ForClause ("$message", new AExpression("dataset FacebookMessages")) |
| 420 | .WhereClause(new AExpression("$message.author-id /*+ indexnl */ = $user.id")) |
| 421 | .ReturnClause({ |
| 422 | "uname" : "$user.name", |
| 423 | "message" : "$message.message" |
| 424 | }); |
| 425 | </pre></div></div></div> |
| 426 | <div class="section"> |
| 427 | <h6><a name="Results"></a>Results</h6> |
| 428 | |
| 429 | <div class="source"> |
| 430 | <div class="source"> |
| 431 | <pre>{ "uname": "MargaritaStoddard", "message": " dislike iphone its touch-screen is horrible" } |
| 432 | { "uname": "MargaritaStoddard", "message": " like verizon the 3G is awesome:)" } |
| 433 | { "uname": "MargaritaStoddard", "message": " can't stand motorola the touch-screen is terrible" } |
| 434 | { "uname": "MargaritaStoddard", "message": " can't stand at&t the network is horrible:(" } |
| 435 | { "uname": "MargaritaStoddard", "message": " can't stand at&t its plan is terrible" } |
| 436 | { "uname": "IsbelDull", "message": " like samsung the plan is amazing" } |
| 437 | { "uname": "IsbelDull", "message": " like t-mobile its platform is mind-blowing" } |
| 438 | { "uname": "WoodrowNehling", "message": " love at&t its 3G is good:)" } |
| 439 | { "uname": "BramHatch", "message": " dislike iphone the voice-command is bad:(" } |
| 440 | { "uname": "BramHatch", "message": " can't stand t-mobile its voicemail-service is OMG:(" } |
| 441 | { "uname": "EmoryUnk", "message": " love sprint its shortcut-menu is awesome:)" } |
| 442 | { "uname": "EmoryUnk", "message": " love verizon its wireless is good" } |
| 443 | { "uname": "WillisWynne", "message": " love sprint the customization is mind-blowing" } |
| 444 | { "uname": "SuzannaTillson", "message": " like iphone the voicemail-service is awesome" } |
| 445 | { "uname": "VonKemble", "message": " dislike sprint the speed is horrible" } |
| 446 | </pre></div></div></div></div></div></div> |
| 447 | <div class="section"> |
| 448 | <h3><a name="Query_3_-_Nested_Outer_Join"></a>Query 3 - Nested Outer Join</h3> |
| 449 | <div class="section"> |
| 450 | <div class="section"> |
| 451 | <div class="section"> |
| 452 | <h6><a name="AQL"></a>AQL</h6> |
| 453 | |
| 454 | <div class="source"> |
| 455 | <div class="source"> |
| 456 | <pre>use dataverse TinySocial; |
| 457 | |
| 458 | for $user in dataset FacebookUsers |
| 459 | return { |
| 460 | "uname": $user.name, |
| 461 | "messages": for $message in dataset FacebookMessages |
| 462 | where $message.author-id = $user.id |
| 463 | return $message.message |
| 464 | }; |
| 465 | </pre></div></div></div> |
| 466 | <div class="section"> |
| 467 | <h6><a name="JS"></a>JS</h6> |
| 468 | |
| 469 | <div class="source"> |
| 470 | <div class="source"> |
| 471 | <pre>var expression3messages = new FLWOGRExpression() |
| 472 | .ForClause("$message", new AExpression("dataset FacebookMessages")) |
| 473 | .WhereClause(new AExpression("$message.author-id = $user.id")) |
| 474 | .ReturnClause("$message.message"); |
| 475 | |
| 476 | var expression3 = new FLWOGRExpression() |
| 477 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 478 | .ReturnClause({ |
| 479 | "uname": "$user.name", |
| 480 | "messages" : expression3messages |
| 481 | }); |
| 482 | </pre></div></div></div> |
| 483 | <div class="section"> |
| 484 | <h6><a name="Results"></a>Results</h6> |
| 485 | |
| 486 | <div class="source"> |
| 487 | <div class="source"> |
| 488 | <pre>{ "uname": "MargaritaStoddard", "messages": { orderedlist: [" dislike iphone its touch-screen is horrible", " like verizon the 3G is awesome:)", " can't stand motorola the touch-screen is terrible", " can't stand at&t the network is horrible:(", " can't stand at&t its plan is terrible" ]} } |
| 489 | { "uname": "IsbelDull", "messages": { orderedlist: [" like samsung the plan is amazing", " like t-mobile its platform is mind-blowing" ]} } |
| 490 | { "uname": "NilaMilliron", "messages": { orderedlist: [ ]} } |
| 491 | { "uname": "WoodrowNehling", "messages": { orderedlist: [" love at&t its 3G is good:)" ]} } |
| 492 | { "uname": "BramHatch", "messages": { orderedlist: [" dislike iphone the voice-command is bad:(", " can't stand t-mobile its voicemail-service is OMG:(" ]} } |
| 493 | { "uname": "EmoryUnk", "messages": { orderedlist: [" love sprint its shortcut-menu is awesome:)", " love verizon its wireless is good" ]} } |
| 494 | { "uname": "WillisWynne", "messages": { orderedlist: [" love sprint the customization is mind-blowing" ]} } |
| 495 | { "uname": "SuzannaTillson", "messages": { orderedlist: [" like iphone the voicemail-service is awesome" ]} } |
| 496 | { "uname": "NicholasStroh", "messages": { orderedlist: [ ]} } |
| 497 | { "uname": "VonKemble", "messages": { orderedlist: [" dislike sprint the speed is horrible" ]} } |
| 498 | </pre></div></div></div></div></div></div> |
| 499 | <div class="section"> |
| 500 | <h3><a name="Query_4_-_Theta_Join"></a>Query 4 - Theta Join</h3> |
| 501 | <div class="section"> |
| 502 | <div class="section"> |
| 503 | <div class="section"> |
| 504 | <h6><a name="AQL"></a>AQL</h6> |
| 505 | |
| 506 | <div class="source"> |
| 507 | <div class="source"> |
| 508 | <pre>use dataverse TinySocial; |
| 509 | |
| 510 | for $t in dataset TweetMessages |
| 511 | return { |
| 512 | "message": $t.message-text, |
| 513 | "nearby-messages": for $t2 in dataset TweetMessages |
| 514 | where spatial-distance($t.sender-location, $t2.sender-location) <= 1 |
| 515 | return { "msgtxt":$t2.message-text} |
| 516 | }; |
| 517 | </pre></div></div></div> |
| 518 | <div class="section"> |
| 519 | <h6><a name="JS"></a>JS</h6> |
| 520 | |
| 521 | <div class="source"> |
| 522 | <div class="source"> |
| 523 | <pre>var expression4messages = new FLWOGRExpression() |
| 524 | .ForClause( "$t2", new AExpression("dataset TweetMessages")) |
| 525 | .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1")) |
| 526 | .ReturnClause({ "msgtxt" : "$t2.message-text" }); |
| 527 | |
| 528 | var expression4 = new FLWOGRExpression() |
| 529 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
| 530 | .ReturnClause({ |
| 531 | "message" : "$t.message-text", |
| 532 | "nearby-messages" : expression4messages |
| 533 | }); |
| 534 | </pre></div></div></div> |
| 535 | <div class="section"> |
| 536 | <h6><a name="Results"></a>Results</h6> |
| 537 | |
| 538 | <div class="source"> |
| 539 | <div class="source"> |
| 540 | <pre>{ "message": " hate verizon its voice-clarity is OMG:(", "nearby-messages": { orderedlist: [{ "msgtxt": " hate verizon its voice-clarity is OMG:(" }, { "msgtxt": " like motorola the speed is good:)" } ]} } |
| 541 | { "message": " like iphone the voice-clarity is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like iphone the voice-clarity is good:)" } ]} } |
| 542 | { "message": " like samsung the platform is good", "nearby-messages": { orderedlist: [{ "msgtxt": " like samsung the platform is good" } ]} } |
| 543 | { "message": " love t-mobile its customization is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " love t-mobile its customization is good:)" } ]} } |
| 544 | { "message": " like samsung the voice-command is amazing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like samsung the voice-command is amazing:)" } ]} } |
| 545 | { "message": " like motorola the speed is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " hate verizon its voice-clarity is OMG:(" }, { "msgtxt": " like motorola the speed is good:)" } ]} } |
| 546 | { "message": " love verizon its voicemail-service is awesome", "nearby-messages": { orderedlist: [{ "msgtxt": " love verizon its voicemail-service is awesome" } ]} } |
| 547 | { "message": " can't stand motorola its speed is terrible:(", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand motorola its speed is terrible:(" } ]} } |
| 548 | { "message": " like t-mobile the shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like t-mobile the shortcut-menu is awesome:)" } ]} } |
| 549 | { "message": " can't stand iphone its platform is terrible", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand iphone its platform is terrible" } ]} } |
| 550 | { "message": " like verizon its shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like verizon its shortcut-menu is awesome:)" } ]} } |
| 551 | { "message": " like sprint the voice-command is mind-blowing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like sprint the voice-command is mind-blowing:)" } ]} } |
| 552 | </pre></div></div></div></div></div></div> |
| 553 | <div class="section"> |
| 554 | <h3><a name="Query_5_-_Fuzzy_Join"></a>Query 5 - Fuzzy Join</h3> |
| 555 | <div class="section"> |
| 556 | <div class="section"> |
| 557 | <div class="section"> |
| 558 | <h6><a name="AQL"></a>AQL</h6> |
| 559 | <p>use dataverse TinySocial;</p> |
| 560 | |
| 561 | <div class="source"> |
| 562 | <div class="source"> |
| 563 | <pre>set simfunction "edit-distance"; |
| 564 | set simthreshold "3"; |
| 565 | |
| 566 | for $fbu in dataset FacebookUsers |
| 567 | return { |
| 568 | "id": $fbu.id, |
| 569 | "name": $fbu.name, |
| 570 | "similar-users": for $t in dataset TweetMessages |
| 571 | let $tu := $t.user |
| 572 | where $tu.name ~= $fbu.name |
| 573 | return { |
| 574 | "twitter-screenname": $tu.screen-name, |
| 575 | "twitter-name": $tu.name |
| 576 | } |
| 577 | }; |
| 578 | </pre></div></div></div> |
| 579 | <div class="section"> |
| 580 | <h6><a name="JS"></a>JS</h6> |
| 581 | |
| 582 | <div class="source"> |
| 583 | <div class="source"> |
| 584 | <pre>var similarUsersExpression = new FLWOGRExpression() |
| 585 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 586 | .LetClause ("$tu", new AExpression("$t.user")) |
| 587 | .WhereClause(new AExpression("$tu.name ~= $fbu.name")) |
| 588 | .ReturnClause({ |
| 589 | "twitter-screenname": "$tu.screen-name", |
| 590 | "twitter-name": "$tu.name" |
| 591 | }); |
| 592 | |
| 593 | var expression5 = new FLWOGRExpression() |
| 594 | .ForClause ("$fbu", new AExpression("dataset FacebookUsers")) |
| 595 | .ReturnClause( |
| 596 | { |
| 597 | "id" : "$fbu.id", |
| 598 | "name" : "$fbu.name", |
| 599 | "similar-users" : similarUsersExpression |
| 600 | } |
| 601 | ); |
| 602 | </pre></div></div></div> |
| 603 | <div class="section"> |
| 604 | <h6><a name="Results"></a>Results</h6> |
| 605 | |
| 606 | <div class="source"> |
| 607 | <div class="source"> |
| 608 | <pre>{ "id": { int32: 1 } , "name": "MargaritaStoddard", "similar-users": { orderedlist: [ ]} } |
| 609 | { "id": { int32: 2 } , "name": "IsbelDull", "similar-users": { orderedlist: [ ]} } |
| 610 | { "id": { int32: 8 } , "name": "NilaMilliron", "similar-users": { orderedlist: [{ "twitter-screenname": "NilaMilliron_tw", "twitter-name": "Nila Milliron" } ]} } |
| 611 | { "id": { int32: 9 } , "name": "WoodrowNehling", "similar-users": { orderedlist: [ ]} } |
| 612 | { "id": { int32: 10 } , "name": "BramHatch", "similar-users": { orderedlist: [ ]} } |
| 613 | { "id": { int32: 3 } , "name": "EmoryUnk", "similar-users": { orderedlist: [ ]} } |
| 614 | { "id": { int32: 6 } , "name": "WillisWynne", "similar-users": { orderedlist: [ ]} } |
| 615 | { "id": { int32: 7 } , "name": "SuzannaTillson", "similar-users": { orderedlist: [ ]} } |
| 616 | { "id": { int32: 4 } , "name": "NicholasStroh", "similar-users": { orderedlist: [ ]} } |
| 617 | { "id": { int32: 5 } , "name": "VonKemble", "similar-users": { orderedlist: [ ]} } |
| 618 | </pre></div></div></div></div></div></div> |
| 619 | <div class="section"> |
| 620 | <h3><a name="Query_6_-_Existential_Quantification"></a>Query 6 - Existential Quantification</h3> |
| 621 | <div class="section"> |
| 622 | <div class="section"> |
| 623 | <div class="section"> |
| 624 | <h6><a name="AQL"></a>AQL</h6> |
| 625 | |
| 626 | <div class="source"> |
| 627 | <div class="source"> |
| 628 | <pre>use dataverse TinySocial; |
| 629 | |
| 630 | for $fbu in dataset FacebookUsers |
| 631 | where (some $e in $fbu.employment satisfies is-null($e.end-date)) |
| 632 | return $fbu; |
| 633 | </pre></div></div></div> |
| 634 | <div class="section"> |
| 635 | <h6><a name="JS"></a>JS</h6> |
| 636 | |
| 637 | <div class="source"> |
| 638 | <div class="source"> |
| 639 | <pre>var expression6 = new FLWOGRExpression() |
| 640 | .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers")) |
| 641 | .WhereClause( |
| 642 | new QuantifiedExpression ( |
| 643 | "some" , |
| 644 | {"$e" : new AExpression("$fbu.employment") }, |
| 645 | new FunctionExpression("is-null", new AExpression("$e.end-date")) |
| 646 | ) |
| 647 | ) |
| 648 | .ReturnClause("$fbu"); |
| 649 | </pre></div></div></div> |
| 650 | <div class="section"> |
| 651 | <h6><a name="Results"></a>Results</h6> |
| 652 | |
| 653 | <div class="source"> |
| 654 | <div class="source"> |
| 655 | <pre>{ "id": { int32: 1 } , "alias": "Margarita", "name": "MargaritaStoddard", "user-since": { datetime: 1345457400000}, "friend-ids": { unorderedlist: [{ int32: 2 } , { int32: 3 } , { int32: 6 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Codetechno", "start-date": { date: 1154822400000}, "end-date": null } ]} } |
| 656 | { "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} } |
| 657 | { "id": { int32: 8 } , "alias": "Nila", "name": "NilaMilliron", "user-since": { datetime: 1199182200000}, "friend-ids": { unorderedlist: [{ int32: 3 } ]}, "employment": { orderedlist: [{ "organization-name": "Plexlane", "start-date": { date: 1267315200000}, "end-date": null } ]} } |
| 658 | { "id": { int32: 6 } , "alias": "Willis", "name": "WillisWynne", "user-since": { datetime: 1105956600000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 3 } , { int32: 7 } ]}, "employment": { orderedlist: [{ "organization-name": "jaydax", "start-date": { date: 1242345600000}, "end-date": null } ]} } |
| 659 | { "id": { int32: 7 } , "alias": "Suzanna", "name": "SuzannaTillson", "user-since": { datetime: 1344334200000}, "friend-ids": { unorderedlist: [{ int32: 6 } ]}, "employment": { orderedlist: [{ "organization-name": "Labzatron", "start-date": { date: 1303171200000}, "end-date": null } ]} } |
| 660 | { "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} } |
| 661 | { "id": { int32: 5 } , "alias": "Von", "name": "VonKemble", "user-since": { datetime: 1262686200000}, "friend-ids": { unorderedlist: [{ int32: 3 } , { int32: 6 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Kongreen", "start-date": { date: 1290816000000}, "end-date": null } ]} } |
| 662 | </pre></div></div></div></div></div></div> |
| 663 | <div class="section"> |
| 664 | <h3><a name="Query_7_-_Universal_Quantification"></a>Query 7 - Universal Quantification</h3> |
| 665 | <div class="section"> |
| 666 | <div class="section"> |
| 667 | <div class="section"> |
| 668 | <h6><a name="AQL"></a>AQL</h6> |
| 669 | |
| 670 | <div class="source"> |
| 671 | <div class="source"> |
| 672 | <pre>use dataverse TinySocial; |
| 673 | |
| 674 | for $fbu in dataset FacebookUsers |
| 675 | where (every $e in $fbu.employment satisfies not(is-null($e.end-date))) |
| 676 | return $fbu; |
| 677 | </pre></div></div></div> |
| 678 | <div class="section"> |
| 679 | <h6><a name="JS"></a>JS</h6> |
| 680 | |
| 681 | <div class="source"> |
| 682 | <div class="source"> |
| 683 | <pre>var expression7 = new FLWOGRExpression() |
| 684 | .ForClause("$fbu", new AExpression("dataset FacebookUsers")) |
| 685 | .WhereClause( |
| 686 | new QuantifiedExpression ( |
| 687 | "every" , |
| 688 | {"$e" : new AExpression("$fbu.employment") }, |
| 689 | new FunctionExpression("not", new FunctionExpression("is-null", new AExpression("$e.end-date"))) |
| 690 | ) |
| 691 | ) |
| 692 | .ReturnClause("$fbu"); |
| 693 | </pre></div></div></div> |
| 694 | <div class="section"> |
| 695 | <h6><a name="Results"></a>Results</h6> |
| 696 | |
| 697 | <div class="source"> |
| 698 | <div class="source"> |
| 699 | <pre>{ "id": { int32: 9 } , "alias": "Woodrow", "name": "WoodrowNehling", "user-since": { datetime: 1127211000000}, "friend-ids": { unorderedlist: [{ int32: 3 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Zuncan", "start-date": { date: 1050969600000}, "end-date": { date: 1260662400000} } ]} } |
| 700 | { "id": { int32: 10 } , "alias": "Bram", "name": "BramHatch", "user-since": { datetime: 1287223800000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "physcane", "start-date": { date: 1181001600000}, "end-date": { date: 1320451200000} } ]} } |
| 701 | { "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} } |
| 702 | </pre></div></div></div></div></div></div> |
| 703 | <div class="section"> |
| 704 | <h3><a name="Query_8_-_Simple_Aggregation"></a>Query 8 - Simple Aggregation</h3> |
| 705 | <div class="section"> |
| 706 | <div class="section"> |
| 707 | <div class="section"> |
| 708 | <h6><a name="AQL"></a>AQL</h6> |
| 709 | |
| 710 | <div class="source"> |
| 711 | <div class="source"> |
| 712 | <pre>use dataverse TinySocial; |
| 713 | |
| 714 | count(for $fbu in dataset FacebookUsers return $fbu); |
| 715 | </pre></div></div></div> |
| 716 | <div class="section"> |
| 717 | <h6><a name="JS"></a>JS</h6> |
| 718 | |
| 719 | <div class="source"> |
| 720 | <div class="source"> |
| 721 | <pre>var expression8 = new FunctionExpression( |
| 722 | "count", |
| 723 | new FLWOGRExpression() |
| 724 | .ForClause("$fbu", new AExpression("dataset FacebookUsers")) |
| 725 | .ReturnClause("$fbu") |
| 726 | ); |
| 727 | </pre></div></div></div> |
| 728 | <div class="section"> |
| 729 | <h6><a name="Results"></a>Results</h6> |
| 730 | |
| 731 | <div class="source"> |
| 732 | <div class="source"> |
| 733 | <pre>{ int64: 10 } |
| 734 | </pre></div></div></div></div></div></div> |
| 735 | <div class="section"> |
| 736 | <h3><a name="Query_9-A_-_Grouping_and_Aggregation"></a>Query 9-A - Grouping and Aggregation</h3> |
| 737 | <div class="section"> |
| 738 | <div class="section"> |
| 739 | <div class="section"> |
| 740 | <h6><a name="AQL"></a>AQL</h6> |
| 741 | |
| 742 | <div class="source"> |
| 743 | <div class="source"> |
| 744 | <pre>use dataverse TinySocial; |
| 745 | |
| 746 | for $t in dataset TweetMessages |
| 747 | group by $uid := $t.user.screen-name with $t |
| 748 | return { |
| 749 | "user": $uid, |
| 750 | "count": count($t) |
| 751 | }; |
| 752 | </pre></div></div></div> |
| 753 | <div class="section"> |
| 754 | <h6><a name="JS"></a>JS</h6> |
| 755 | |
| 756 | <div class="source"> |
| 757 | <div class="source"> |
| 758 | <pre>var expression9a = new FLWOGRExpression() |
| 759 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 760 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 761 | .ReturnClause( |
| 762 | { |
| 763 | "user" : "$uid", |
| 764 | "count" : new FunctionExpression("count", new AExpression("$t")) |
| 765 | } |
| 766 | ); |
| 767 | </pre></div></div></div> |
| 768 | <div class="section"> |
| 769 | <h6><a name="Results"></a>Results</h6> |
| 770 | |
| 771 | <div class="source"> |
| 772 | <div class="source"> |
| 773 | <pre>{ "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 774 | { "user": "OliJackson_512", "count": { int64: 1 } } |
| 775 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 776 | { "user": "ChangEwing_573", "count": { int64: 1 } } |
| 777 | { "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 778 | </pre></div></div></div></div></div></div> |
| 779 | <div class="section"> |
| 780 | <h3><a name="Query_9-B_-_Hash-Based_Grouping_and_Aggregation"></a>Query 9-B - (Hash-Based) Grouping and Aggregation</h3> |
| 781 | <div class="section"> |
| 782 | <div class="section"> |
| 783 | <div class="section"> |
| 784 | <h6><a name="AQL"></a>AQL</h6> |
| 785 | |
| 786 | <div class="source"> |
| 787 | <div class="source"> |
| 788 | <pre>use dataverse TinySocial; |
| 789 | |
| 790 | for $t in dataset TweetMessages |
| 791 | /*+ hash*/ |
| 792 | group by $uid := $t.user.screen-name with $t |
| 793 | return { |
| 794 | "user": $uid, |
| 795 | "count": count($t) |
| 796 | }; |
| 797 | </pre></div></div></div> |
| 798 | <div class="section"> |
| 799 | <h6><a name="JS"></a>JS</h6> |
| 800 | |
| 801 | <div class="source"> |
| 802 | <div class="source"> |
| 803 | <pre>var expression9b = new FLWOGRExpression() |
| 804 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 805 | .AQLClause("/*+ hash*/") |
| 806 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 807 | .ReturnClause( |
| 808 | { |
| 809 | "user" : "$uid", |
| 810 | "count" : new FunctionExpression("count", new AExpression("$t")) |
| 811 | } |
| 812 | ); |
| 813 | </pre></div></div></div> |
| 814 | <div class="section"> |
| 815 | <h6><a name="Results"></a>Results</h6> |
| 816 | |
| 817 | <div class="source"> |
| 818 | <div class="source"> |
| 819 | <pre>{ "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 820 | { "user": "OliJackson_512", "count": { int64: 1 } } |
| 821 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 822 | { "user": "ChangEwing_573", "count": { int64: 1 } } |
| 823 | { "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 824 | </pre></div></div></div></div></div></div> |
| 825 | <div class="section"> |
| 826 | <h3><a name="Query_10_-_Grouping_and_Limits"></a>Query 10 - Grouping and Limits</h3> |
| 827 | <div class="section"> |
| 828 | <div class="section"> |
| 829 | <div class="section"> |
| 830 | <h6><a name="AQL"></a>AQL</h6> |
| 831 | |
| 832 | <div class="source"> |
| 833 | <div class="source"> |
| 834 | <pre>use dataverse TinySocial; |
| 835 | |
| 836 | for $t in dataset TweetMessages |
| 837 | group by $uid := $t.user.screen-name with $t |
| 838 | let $c := count($t) |
| 839 | order by $c desc |
| 840 | limit 3 |
| 841 | return { |
| 842 | "user": $uid, |
| 843 | "count": $c |
| 844 | }; |
| 845 | </pre></div></div></div> |
| 846 | <div class="section"> |
| 847 | <h6><a name="JS"></a>JS</h6> |
| 848 | |
| 849 | <div class="source"> |
| 850 | <div class="source"> |
| 851 | <pre>var expression10 = new FLWOGRExpression() |
| 852 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 853 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 854 | .LetClause("$c", new FunctionExpression("count", new AExpression("$t"))) |
| 855 | .OrderbyClause( new AExpression("$c"), "desc" ) |
| 856 | .LimitClause(new AExpression("3")) |
| 857 | .ReturnClause( |
| 858 | { |
| 859 | "user" : "$uid", |
| 860 | "count" : "$c" |
| 861 | } |
| 862 | ); |
| 863 | </pre></div></div></div> |
| 864 | <div class="section"> |
| 865 | <h6><a name="Results"></a>Results</h6> |
| 866 | |
| 867 | <div class="source"> |
| 868 | <div class="source"> |
| 869 | <pre>{ "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 870 | { "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 871 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 872 | </pre></div></div></div></div></div></div> |
| 873 | <div class="section"> |
| 874 | <h3><a name="Query_11_-_Left_Outer_Fuzzy_Join"></a>Query 11 - Left Outer Fuzzy Join</h3> |
| 875 | <div class="section"> |
| 876 | <div class="section"> |
| 877 | <div class="section"> |
| 878 | <h6><a name="AQL"></a>AQL</h6> |
| 879 | |
| 880 | <div class="source"> |
| 881 | <div class="source"> |
| 882 | <pre>use dataverse TinySocial; |
| 883 | |
| 884 | set simfunction "jaccard"; |
| 885 | set simthreshold "0.3"; |
| 886 | |
| 887 | for $t in dataset TweetMessages |
| 888 | return { |
| 889 | "tweet": $t, |
| 890 | "similar-tweets": for $t2 in dataset TweetMessages |
| 891 | where $t2.referred-topics ~= $t.referred-topics |
| 892 | and $t2.tweetid != $t.tweetid |
| 893 | return $t2.referred-topics |
| 894 | }; |
| 895 | </pre></div></div></div> |
| 896 | <div class="section"> |
| 897 | <h6><a name="JS"></a>JS</h6> |
| 898 | |
| 899 | <div class="source"> |
| 900 | <div class="source"> |
| 901 | <pre>var expression11 = new FLWOGRExpression() |
| 902 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
| 903 | .ReturnClause({ |
| 904 | "tweet" : new AExpression("$t"), |
| 905 | "similar-tweets": new FLWOGRExpression() |
| 906 | .ForClause( "$t2", new AExpression("dataset TweetMessages")) |
| 907 | .WhereClause().and( |
| 908 | new AExpression("$t2.referred-topics ~= $t.referred-topics"), |
| 909 | new AExpression("$t2.tweetid != $t.tweetid") |
| 910 | ) |
| 911 | .ReturnClause("$t2.referred-topics") |
| 912 | }); |
| 913 | </pre></div></div></div> |
| 914 | <div class="section"> |
| 915 | <h6><a name="Results"></a>Results</h6> |
| 916 | |
| 917 | <div class="source"> |
| 918 | <div class="source"> |
| 919 | <pre>{ "tweet": { "tweetid": "10", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [29.15, 76.53]}, "send-time": { datetime: 1201342200000}, "referred-topics": { unorderedlist: ["verizon", "voice-clarity" ]}, "message-text": " hate verizon its voice-clarity is OMG:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "voice-clarity" ]}, { unorderedlist: ["verizon", "shortcut-menu" ]}, { unorderedlist: ["verizon", "voicemail-service" ]} ]} } |
| 920 | { "tweet": { "tweetid": "6", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [47.51, 83.99]}, "send-time": { datetime: 1273227000000}, "referred-topics": { unorderedlist: ["iphone", "voice-clarity" ]}, "message-text": " like iphone the voice-clarity is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["iphone", "platform" ]} ]} } |
| 921 | { "tweet": { "tweetid": "7", "user": { "screen-name": "ChangEwing_573", "lang": "en", "friends_count": { int32: 182 } , "statuses_count": { int32: 394 } , "name": "Chang Ewing", "followers_count": { int32: 32136 } }, "sender-location": { point: [36.21, 72.6]}, "send-time": { datetime: 1314267000000}, "referred-topics": { unorderedlist: ["samsung", "platform" ]}, "message-text": " like samsung the platform is good" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "platform" ]}, { unorderedlist: ["samsung", "voice-command" ]} ]} } |
| 922 | { "tweet": { "tweetid": "1", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [47.44, 80.65]}, "send-time": { datetime: 1209204600000}, "referred-topics": { unorderedlist: ["t-mobile", "customization" ]}, "message-text": " love t-mobile its customization is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["t-mobile", "shortcut-menu" ]} ]} } |
| 923 | { "tweet": { "tweetid": "12", "user": { "screen-name": "OliJackson_512", "lang": "en", "friends_count": { int32: 445 } , "statuses_count": { int32: 164 } , "name": "Oli Jackson", "followers_count": { int32: 22649 } }, "sender-location": { point: [24.82, 94.63]}, "send-time": { datetime: 1266055800000}, "referred-topics": { unorderedlist: ["samsung", "voice-command" ]}, "message-text": " like samsung the voice-command is amazing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["samsung", "platform" ]}, { unorderedlist: ["sprint", "voice-command" ]} ]} } |
| 924 | { "tweet": { "tweetid": "3", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [29.72, 75.8]}, "send-time": { datetime: 1162635000000}, "referred-topics": { unorderedlist: ["motorola", "speed" ]}, "message-text": " like motorola the speed is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["motorola", "speed" ]} ]} } |
| 925 | { "tweet": { "tweetid": "9", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [36.86, 74.62]}, "send-time": { datetime: 1342865400000}, "referred-topics": { unorderedlist: ["verizon", "voicemail-service" ]}, "message-text": " love verizon its voicemail-service is awesome" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["verizon", "shortcut-menu" ]} ]} } |
| 926 | { "tweet": { "tweetid": "5", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [40.09, 92.69]}, "send-time": { datetime: 1154686200000}, "referred-topics": { unorderedlist: ["motorola", "speed" ]}, "message-text": " can't stand motorola its speed is terrible:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["motorola", "speed" ]} ]} } |
| 927 | { "tweet": { "tweetid": "8", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [46.05, 93.34]}, "send-time": { datetime: 1129284600000}, "referred-topics": { unorderedlist: ["t-mobile", "shortcut-menu" ]}, "message-text": " like t-mobile the shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "shortcut-menu" ]}, { unorderedlist: ["t-mobile", "customization" ]} ]} } |
| 928 | { "tweet": { "tweetid": "11", "user": { "screen-name": "NilaMilliron_tw", "lang": "en", "friends_count": { int32: 445 } , "statuses_count": { int32: 164 } , "name": "Nila Milliron", "followers_count": { int32: 22649 } }, "sender-location": { point: [37.59, 68.42]}, "send-time": { datetime: 1205057400000}, "referred-topics": { unorderedlist: ["iphone", "platform" ]}, "message-text": " can't stand iphone its platform is terrible" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "voice-clarity" ]}, { unorderedlist: ["samsung", "platform" ]} ]} } |
| 929 | { "tweet": { "tweetid": "2", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [32.84, 67.14]}, "send-time": { datetime: 1273745400000}, "referred-topics": { unorderedlist: ["verizon", "shortcut-menu" ]}, "message-text": " like verizon its shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["t-mobile", "shortcut-menu" ]}, { unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["verizon", "voicemail-service" ]} ]} } |
| 930 | { "tweet": { "tweetid": "4", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [39.28, 70.48]}, "send-time": { datetime: 1324894200000}, "referred-topics": { unorderedlist: ["sprint", "voice-command" ]}, "message-text": " like sprint the voice-command is mind-blowing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["samsung", "voice-command" ]} ]} } |
| 931 | </pre></div></div></div></div></div></div></div> |
| 932 | </div> |
| 933 | </div> |
| 934 | </div> |
| 935 | |
| 936 | <hr/> |
| 937 | |
| 938 | <footer> |
| 939 | <div class="container-fluid"> |
| 940 | <div class="row span12">Copyright © 2015 |
| 941 | <a href="http://www.apache.org/">The Apache Software Foundation</a>. |
| 942 | All Rights Reserved. |
| 943 | |
| 944 | </div> |
| 945 | |
| 946 | <?xml version="1.0" encoding="UTF-8"?> |
| 947 | <div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache |
| 948 | feather logo, and the Apache AsterixDB project logo are either |
| 949 | registered trademarks or trademarks of The Apache Software |
| 950 | Foundation in the United States and other countries. |
| 951 | All other marks mentioned may be trademarks or registered |
| 952 | trademarks of their respective owners.</div> |
| 953 | |
| 954 | |
| 955 | </div> |
| 956 | </footer> |
| 957 | </body> |
| 958 | </html> |