Ian Maxon | 444ca1b | 2017-08-25 11:41:41 -0700 | [diff] [blame^] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | | Generated by Apache Maven Doxia at 2017-07-27 |
| 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="20170727" /> |
| 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=".././" 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: 2017-07-27</li> |
| 52 | |
| 53 | |
| 54 | |
| 55 | <li id="projectVersion" class="pull-right">Version: 0.9.2-SNAPSHOT</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">Get Started - Installation</li> |
| 74 | |
| 75 | <li> |
| 76 | |
| 77 | <a href="../ncservice.html" title="Option 1: using NCService"> |
| 78 | <i class="none"></i> |
| 79 | Option 1: using NCService</a> |
| 80 | </li> |
| 81 | |
| 82 | <li> |
| 83 | |
| 84 | <a href="../ansible.html" title="Option 2: using Ansible"> |
| 85 | <i class="none"></i> |
| 86 | Option 2: using Ansible</a> |
| 87 | </li> |
| 88 | |
| 89 | <li> |
| 90 | |
| 91 | <a href="../aws.html" title="Option 3: using Amazon Web Services"> |
| 92 | <i class="none"></i> |
| 93 | Option 3: using Amazon Web Services</a> |
| 94 | </li> |
| 95 | |
| 96 | <li> |
| 97 | |
| 98 | <a href="../yarn.html" title="Option 4: using YARN"> |
| 99 | <i class="none"></i> |
| 100 | Option 4: using YARN</a> |
| 101 | </li> |
| 102 | |
| 103 | <li> |
| 104 | |
| 105 | <a href="../install.html" title="Option 5: using Managix (deprecated)"> |
| 106 | <i class="none"></i> |
| 107 | Option 5: using Managix (deprecated)</a> |
| 108 | </li> |
| 109 | <li class="nav-header">AsterixDB Primer</li> |
| 110 | |
| 111 | <li> |
| 112 | |
| 113 | <a href="../sqlpp/primer-sqlpp.html" title="Option 1: using SQL++"> |
| 114 | <i class="none"></i> |
| 115 | Option 1: using SQL++</a> |
| 116 | </li> |
| 117 | |
| 118 | <li> |
| 119 | |
| 120 | <a href="../aql/primer.html" title="Option 2: using AQL"> |
| 121 | <i class="none"></i> |
| 122 | Option 2: using AQL</a> |
| 123 | </li> |
| 124 | <li class="nav-header">Data Model</li> |
| 125 | |
| 126 | <li> |
| 127 | |
| 128 | <a href="../datamodel.html" title="The Asterix Data Model"> |
| 129 | <i class="none"></i> |
| 130 | The Asterix Data Model</a> |
| 131 | </li> |
| 132 | <li class="nav-header">Queries - SQL++</li> |
| 133 | |
| 134 | <li> |
| 135 | |
| 136 | <a href="../sqlpp/manual.html" title="The SQL++ Query Language"> |
| 137 | <i class="none"></i> |
| 138 | The SQL++ Query Language</a> |
| 139 | </li> |
| 140 | |
| 141 | <li> |
| 142 | |
| 143 | <a href="../sqlpp/builtins.html" title="Builtin Functions"> |
| 144 | <i class="none"></i> |
| 145 | Builtin Functions</a> |
| 146 | </li> |
| 147 | <li class="nav-header">Queries - AQL</li> |
| 148 | |
| 149 | <li> |
| 150 | |
| 151 | <a href="../aql/manual.html" title="The Asterix Query Language (AQL)"> |
| 152 | <i class="none"></i> |
| 153 | The Asterix Query Language (AQL)</a> |
| 154 | </li> |
| 155 | |
| 156 | <li> |
| 157 | |
| 158 | <a href="../aql/builtins.html" title="Builtin Functions"> |
| 159 | <i class="none"></i> |
| 160 | Builtin Functions</a> |
| 161 | </li> |
| 162 | <li class="nav-header">API/SDK</li> |
| 163 | |
| 164 | <li> |
| 165 | |
| 166 | <a href="../api.html" title="HTTP API"> |
| 167 | <i class="none"></i> |
| 168 | HTTP API</a> |
| 169 | </li> |
| 170 | |
| 171 | <li> |
| 172 | |
| 173 | <a href="../csv.html" title="CSV Output"> |
| 174 | <i class="none"></i> |
| 175 | CSV Output</a> |
| 176 | </li> |
| 177 | <li class="nav-header">Advanced Features</li> |
| 178 | |
| 179 | <li> |
| 180 | |
| 181 | <a href="../aql/fulltext.html" title="Support of Full-text Queries"> |
| 182 | <i class="none"></i> |
| 183 | Support of Full-text Queries</a> |
| 184 | </li> |
| 185 | |
| 186 | <li> |
| 187 | |
| 188 | <a href="../aql/externaldata.html" title="Accessing External Data"> |
| 189 | <i class="none"></i> |
| 190 | Accessing External Data</a> |
| 191 | </li> |
| 192 | |
| 193 | <li> |
| 194 | |
| 195 | <a href="../feeds/tutorial.html" title="Support for Data Ingestion"> |
| 196 | <i class="none"></i> |
| 197 | Support for Data Ingestion</a> |
| 198 | </li> |
| 199 | |
| 200 | <li> |
| 201 | |
| 202 | <a href="../udf.html" title="User Defined Functions"> |
| 203 | <i class="none"></i> |
| 204 | User Defined Functions</a> |
| 205 | </li> |
| 206 | |
| 207 | <li> |
| 208 | |
| 209 | <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration"> |
| 210 | <i class="none"></i> |
| 211 | Filter-Based LSM Index Acceleration</a> |
| 212 | </li> |
| 213 | |
| 214 | <li> |
| 215 | |
| 216 | <a href="../aql/similarity.html" title="Support of Similarity Queries"> |
| 217 | <i class="none"></i> |
| 218 | Support of Similarity Queries</a> |
| 219 | </li> |
| 220 | </ul> |
| 221 | |
| 222 | |
| 223 | |
| 224 | <hr class="divider" /> |
| 225 | |
| 226 | <div id="poweredBy"> |
| 227 | <div class="clear"></div> |
| 228 | <div class="clear"></div> |
| 229 | <div class="clear"></div> |
| 230 | <a href=".././" title="AsterixDB" class="builtBy"> |
| 231 | <img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /> |
| 232 | </a> |
| 233 | </div> |
| 234 | </div> |
| 235 | </div> |
| 236 | |
| 237 | |
| 238 | <div id="bodyColumn" class="span9" > |
| 239 | |
| 240 | <!-- ! Licensed to the Apache Software Foundation (ASF) under one |
| 241 | ! or more contributor license agreements. See the NOTICE file |
| 242 | ! distributed with this work for additional information |
| 243 | ! regarding copyright ownership. The ASF licenses this file |
| 244 | ! to you under the Apache License, Version 2.0 (the |
| 245 | ! "License"); you may not use this file except in compliance |
| 246 | ! with the License. You may obtain a copy of the License at |
| 247 | ! |
| 248 | ! http://www.apache.org/licenses/LICENSE-2.0 |
| 249 | ! |
| 250 | ! Unless required by applicable law or agreed to in writing, |
| 251 | ! software distributed under the License is distributed on an |
| 252 | ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 253 | ! KIND, either express or implied. See the License for the |
| 254 | ! specific language governing permissions and limitations |
| 255 | ! under the License. |
| 256 | ! --><h1>AsterixDB Javascript SDK</h1> |
| 257 | <div class="section"> |
| 258 | <h2><a name="Obtaining_and_Including"></a>Obtaining and Including</h2> |
| 259 | <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> |
| 260 | |
| 261 | <div class="source"> |
| 262 | <div class="source"> |
| 263 | <pre><script src="path/to/asterix-sdk-stable.js"></script> |
| 264 | </pre></div></div></div> |
| 265 | <div class="section"> |
| 266 | <h2><a name="Interactive_Demos"></a>Interactive Demos</h2> |
| 267 | <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> |
| 268 | |
| 269 | <ul> |
| 270 | |
| 271 | <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> |
| 272 | |
| 273 | <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> |
| 274 | </ul></div> |
| 275 | <div class="section"> |
| 276 | <h2><a name="The_javascript_SDK:_by_example"></a>The javascript SDK: by example</h2> |
| 277 | <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> |
| 278 | <div class="section"> |
| 279 | <h3><a name="Query_0-A_-_Exact-Match_Lookup"></a>Query 0-A - Exact-Match Lookup</h3> |
| 280 | <div class="section"> |
| 281 | <div class="section"> |
| 282 | <div class="section"> |
| 283 | <h6><a name="AQL"></a>AQL</h6> |
| 284 | |
| 285 | <div class="source"> |
| 286 | <div class="source"> |
| 287 | <pre>use dataverse TinySocial; |
| 288 | |
| 289 | for $user in dataset FacebookUsers |
| 290 | where $user.id = 8 |
| 291 | return $user; |
| 292 | </pre></div></div></div> |
| 293 | <div class="section"> |
| 294 | <h6><a name="JS"></a>JS</h6> |
| 295 | |
| 296 | <div class="source"> |
| 297 | <div class="source"> |
| 298 | <pre>var expression0a = new FLWOGRExpression() |
| 299 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 300 | .WhereClause(new AExpression("$user.id = 8")) |
| 301 | .ReturnClause("$user"); |
| 302 | </pre></div></div></div> |
| 303 | <div class="section"> |
| 304 | <h6><a name="Results"></a>Results</h6> |
| 305 | |
| 306 | <div class="source"> |
| 307 | <div class="source"> |
| 308 | <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 } ]} } |
| 309 | </pre></div></div></div></div></div></div> |
| 310 | <div class="section"> |
| 311 | <h3><a name="Query_0-B_-_Range_Scan"></a>Query 0-B - Range Scan</h3> |
| 312 | <div class="section"> |
| 313 | <div class="section"> |
| 314 | <div class="section"> |
| 315 | <h6><a name="AQL"></a>AQL</h6> |
| 316 | |
| 317 | <div class="source"> |
| 318 | <div class="source"> |
| 319 | <pre>use dataverse TinySocial; |
| 320 | |
| 321 | for $user in dataset FacebookUsers |
| 322 | where $user.id >= 2 and $user.id <= 4 |
| 323 | return $user; |
| 324 | </pre></div></div></div> |
| 325 | <div class="section"> |
| 326 | <h6><a name="JS"></a>JS</h6> |
| 327 | |
| 328 | <div class="source"> |
| 329 | <div class="source"> |
| 330 | <pre>var expression0b = new FLWOGRExpression() |
| 331 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 332 | .WhereClause().and(new AExpression("$user.id >= 2"), new AExpression("$user.id <= 4")) |
| 333 | .ReturnClause("$user"); |
| 334 | </pre></div></div></div> |
| 335 | <div class="section"> |
| 336 | <h6><a name="Results"></a>Results</h6> |
| 337 | |
| 338 | <div class="source"> |
| 339 | <div class="source"> |
| 340 | <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 } ]} } |
| 341 | { "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} } ]} } |
| 342 | { "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 } ]} } |
| 343 | </pre></div></div></div></div></div></div> |
| 344 | <div class="section"> |
| 345 | <h3><a name="Query_1_-_Other_Query_Filters"></a>Query 1 - Other Query Filters</h3> |
| 346 | <div class="section"> |
| 347 | <div class="section"> |
| 348 | <div class="section"> |
| 349 | <h6><a name="AQL"></a>AQL</h6> |
| 350 | |
| 351 | <div class="source"> |
| 352 | <div class="source"> |
| 353 | <pre>use dataverse TinySocial; |
| 354 | |
| 355 | for $user in dataset FacebookUsers |
| 356 | where $user.user-since >= datetime('2010-07-22T00:00:00') |
| 357 | and $user.user-since <= datetime('2012-07-29T23:59:59') |
| 358 | return $user; |
| 359 | </pre></div></div></div> |
| 360 | <div class="section"> |
| 361 | <h6><a name="JS"></a>JS</h6> |
| 362 | |
| 363 | <div class="source"> |
| 364 | <div class="source"> |
| 365 | <pre>var expression1 = new FLWOGRExpression() |
| 366 | .ForClause("$user", new AExpression("dataset FacebookUsers")) |
| 367 | .WhereClause().and( |
| 368 | new AExpression("$user.user-since >= datetime('2010-07-22T00:00:00')"), |
| 369 | new AExpression("$user.user-since <= datetime('2012-07-29T23:59:59')") |
| 370 | ).ReturnClause("$user"); |
| 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>{ "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 } ]} } |
| 378 | { "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} } ]} } |
| 379 | { "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} } ]} } |
| 380 | { "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 } ]} } |
| 381 | </pre></div></div></div></div></div></div> |
| 382 | <div class="section"> |
| 383 | <h3><a name="Query_2-A_-_Equijoin"></a>Query 2-A - Equijoin</h3> |
| 384 | <div class="section"> |
| 385 | <div class="section"> |
| 386 | <div class="section"> |
| 387 | <h6><a name="AQL"></a>AQL</h6> |
| 388 | |
| 389 | <div class="source"> |
| 390 | <div class="source"> |
| 391 | <pre>use dataverse TinySocial; |
| 392 | |
| 393 | for $user in dataset FacebookUsers |
| 394 | for $message in dataset FacebookMessages |
| 395 | where $message.author-id = $user.id |
| 396 | return { |
| 397 | "uname": $user.name, |
| 398 | "message": $message.message |
| 399 | }; |
| 400 | </pre></div></div></div> |
| 401 | <div class="section"> |
| 402 | <h6><a name="JS"></a>JS</h6> |
| 403 | |
| 404 | <div class="source"> |
| 405 | <div class="source"> |
| 406 | <pre>var expression2a = new FLWOGRExpression() |
| 407 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 408 | .ForClause ("$message", new AExpression("dataset FacebookMessages")) |
| 409 | .WhereClause(new AExpression("$message.author-id = $user.id")) |
| 410 | .ReturnClause({ |
| 411 | "uname" : "$user.name", |
| 412 | "message" : "$message.message" |
| 413 | }); |
| 414 | </pre></div></div></div> |
| 415 | <div class="section"> |
| 416 | <h6><a name="Results"></a>Results</h6> |
| 417 | |
| 418 | <div class="source"> |
| 419 | <div class="source"> |
| 420 | <pre>{ "uname": "MargaritaStoddard", "message": " dislike x-phone its touch-screen is horrible" } |
| 421 | { "uname": "MargaritaStoddard", "message": " like ccast the 3G is awesome:)" } |
| 422 | { "uname": "MargaritaStoddard", "message": " can't stand product-w the touch-screen is terrible" } |
| 423 | { "uname": "MargaritaStoddard", "message": " can't stand acast the network is horrible:(" } |
| 424 | { "uname": "MargaritaStoddard", "message": " can't stand acast its plan is terrible" } |
| 425 | { "uname": "IsbelDull", "message": " like product-y the plan is amazing" } |
| 426 | { "uname": "IsbelDull", "message": " like product-z its platform is mind-blowing" } |
| 427 | { "uname": "WoodrowNehling", "message": " love acast its 3G is good:)" } |
| 428 | { "uname": "BramHatch", "message": " dislike x-phone the voice-command is bad:(" } |
| 429 | { "uname": "BramHatch", "message": " can't stand product-z its voicemail-service is OMG:(" } |
| 430 | { "uname": "EmoryUnk", "message": " love product-b its shortcut-menu is awesome:)" } |
| 431 | { "uname": "EmoryUnk", "message": " love ccast its wireless is good" } |
| 432 | { "uname": "WillisWynne", "message": " love product-b the customization is mind-blowing" } |
| 433 | { "uname": "SuzannaTillson", "message": " like x-phone the voicemail-service is awesome" } |
| 434 | { "uname": "VonKemble", "message": " dislike product-b the speed is horrible" } |
| 435 | </pre></div></div></div></div></div></div> |
| 436 | <div class="section"> |
| 437 | <h3><a name="Query_2-B_-_Index_join"></a>Query 2-B - Index join</h3> |
| 438 | <div class="section"> |
| 439 | <div class="section"> |
| 440 | <div class="section"> |
| 441 | <h6><a name="AQL"></a>AQL</h6> |
| 442 | |
| 443 | <div class="source"> |
| 444 | <div class="source"> |
| 445 | <pre>use dataverse TinySocial; |
| 446 | |
| 447 | for $user in dataset FacebookUsers |
| 448 | for $message in dataset FacebookMessages |
| 449 | where $message.author-id /*+ indexnl */ = $user.id |
| 450 | return { |
| 451 | "uname": $user.name, |
| 452 | "message": $message.message |
| 453 | }; |
| 454 | </pre></div></div></div> |
| 455 | <div class="section"> |
| 456 | <h6><a name="JS"></a>JS</h6> |
| 457 | |
| 458 | <div class="source"> |
| 459 | <div class="source"> |
| 460 | <pre>var expression2b = new FLWOGRExpression() |
| 461 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 462 | .ForClause ("$message", new AExpression("dataset FacebookMessages")) |
| 463 | .WhereClause(new AExpression("$message.author-id /*+ indexnl */ = $user.id")) |
| 464 | .ReturnClause({ |
| 465 | "uname" : "$user.name", |
| 466 | "message" : "$message.message" |
| 467 | }); |
| 468 | </pre></div></div></div> |
| 469 | <div class="section"> |
| 470 | <h6><a name="Results"></a>Results</h6> |
| 471 | |
| 472 | <div class="source"> |
| 473 | <div class="source"> |
| 474 | <pre>{ "uname": "MargaritaStoddard", "message": " dislike x-phone its touch-screen is horrible" } |
| 475 | { "uname": "MargaritaStoddard", "message": " like ccast the 3G is awesome:)" } |
| 476 | { "uname": "MargaritaStoddard", "message": " can't stand product-w the touch-screen is terrible" } |
| 477 | { "uname": "MargaritaStoddard", "message": " can't stand acast the network is horrible:(" } |
| 478 | { "uname": "MargaritaStoddard", "message": " can't stand acast its plan is terrible" } |
| 479 | { "uname": "IsbelDull", "message": " like product-y the plan is amazing" } |
| 480 | { "uname": "IsbelDull", "message": " like product-z its platform is mind-blowing" } |
| 481 | { "uname": "WoodrowNehling", "message": " love acast its 3G is good:)" } |
| 482 | { "uname": "BramHatch", "message": " dislike x-phone the voice-command is bad:(" } |
| 483 | { "uname": "BramHatch", "message": " can't stand product-z its voicemail-service is OMG:(" } |
| 484 | { "uname": "EmoryUnk", "message": " love product-b its shortcut-menu is awesome:)" } |
| 485 | { "uname": "EmoryUnk", "message": " love ccast its wireless is good" } |
| 486 | { "uname": "WillisWynne", "message": " love product-b the customization is mind-blowing" } |
| 487 | { "uname": "SuzannaTillson", "message": " like x-phone the voicemail-service is awesome" } |
| 488 | { "uname": "VonKemble", "message": " dislike product-b the speed is horrible" } |
| 489 | </pre></div></div></div></div></div></div> |
| 490 | <div class="section"> |
| 491 | <h3><a name="Query_3_-_Nested_Outer_Join"></a>Query 3 - Nested Outer Join</h3> |
| 492 | <div class="section"> |
| 493 | <div class="section"> |
| 494 | <div class="section"> |
| 495 | <h6><a name="AQL"></a>AQL</h6> |
| 496 | |
| 497 | <div class="source"> |
| 498 | <div class="source"> |
| 499 | <pre>use dataverse TinySocial; |
| 500 | |
| 501 | for $user in dataset FacebookUsers |
| 502 | return { |
| 503 | "uname": $user.name, |
| 504 | "messages": for $message in dataset FacebookMessages |
| 505 | where $message.author-id = $user.id |
| 506 | return $message.message |
| 507 | }; |
| 508 | </pre></div></div></div> |
| 509 | <div class="section"> |
| 510 | <h6><a name="JS"></a>JS</h6> |
| 511 | |
| 512 | <div class="source"> |
| 513 | <div class="source"> |
| 514 | <pre>var expression3messages = new FLWOGRExpression() |
| 515 | .ForClause("$message", new AExpression("dataset FacebookMessages")) |
| 516 | .WhereClause(new AExpression("$message.author-id = $user.id")) |
| 517 | .ReturnClause("$message.message"); |
| 518 | |
| 519 | var expression3 = new FLWOGRExpression() |
| 520 | .ForClause ("$user", new AExpression("dataset FacebookUsers")) |
| 521 | .ReturnClause({ |
| 522 | "uname": "$user.name", |
| 523 | "messages" : expression3messages |
| 524 | }); |
| 525 | </pre></div></div></div> |
| 526 | <div class="section"> |
| 527 | <h6><a name="Results"></a>Results</h6> |
| 528 | |
| 529 | <div class="source"> |
| 530 | <div class="source"> |
| 531 | <pre>{ "uname": "MargaritaStoddard", "messages": { orderedlist: [" dislike x-phone its touch-screen is horrible", " like ccast the 3G is awesome:)", " can't stand product-w the touch-screen is terrible", " can't stand acast the network is horrible:(", " can't stand acast its plan is terrible" ]} } |
| 532 | { "uname": "IsbelDull", "messages": { orderedlist: [" like product-y the plan is amazing", " like product-z its platform is mind-blowing" ]} } |
| 533 | { "uname": "NilaMilliron", "messages": { orderedlist: [ ]} } |
| 534 | { "uname": "WoodrowNehling", "messages": { orderedlist: [" love acast its 3G is good:)" ]} } |
| 535 | { "uname": "BramHatch", "messages": { orderedlist: [" dislike x-phone the voice-command is bad:(", " can't stand product-z its voicemail-service is OMG:(" ]} } |
| 536 | { "uname": "EmoryUnk", "messages": { orderedlist: [" love product-b its shortcut-menu is awesome:)", " love ccast its wireless is good" ]} } |
| 537 | { "uname": "WillisWynne", "messages": { orderedlist: [" love product-b the customization is mind-blowing" ]} } |
| 538 | { "uname": "SuzannaTillson", "messages": { orderedlist: [" like x-phone the voicemail-service is awesome" ]} } |
| 539 | { "uname": "NicholasStroh", "messages": { orderedlist: [ ]} } |
| 540 | { "uname": "VonKemble", "messages": { orderedlist: [" dislike product-b the speed is horrible" ]} } |
| 541 | </pre></div></div></div></div></div></div> |
| 542 | <div class="section"> |
| 543 | <h3><a name="Query_4_-_Theta_Join"></a>Query 4 - Theta Join</h3> |
| 544 | <div class="section"> |
| 545 | <div class="section"> |
| 546 | <div class="section"> |
| 547 | <h6><a name="AQL"></a>AQL</h6> |
| 548 | |
| 549 | <div class="source"> |
| 550 | <div class="source"> |
| 551 | <pre>use dataverse TinySocial; |
| 552 | |
| 553 | for $t in dataset TweetMessages |
| 554 | return { |
| 555 | "message": $t.message-text, |
| 556 | "nearby-messages": for $t2 in dataset TweetMessages |
| 557 | where spatial-distance($t.sender-location, $t2.sender-location) <= 1 |
| 558 | return { "msgtxt":$t2.message-text} |
| 559 | }; |
| 560 | </pre></div></div></div> |
| 561 | <div class="section"> |
| 562 | <h6><a name="JS"></a>JS</h6> |
| 563 | |
| 564 | <div class="source"> |
| 565 | <div class="source"> |
| 566 | <pre>var expression4messages = new FLWOGRExpression() |
| 567 | .ForClause( "$t2", new AExpression("dataset TweetMessages")) |
| 568 | .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1")) |
| 569 | .ReturnClause({ "msgtxt" : "$t2.message-text" }); |
| 570 | |
| 571 | var expression4 = new FLWOGRExpression() |
| 572 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
| 573 | .ReturnClause({ |
| 574 | "message" : "$t.message-text", |
| 575 | "nearby-messages" : expression4messages |
| 576 | }); |
| 577 | </pre></div></div></div> |
| 578 | <div class="section"> |
| 579 | <h6><a name="Results"></a>Results</h6> |
| 580 | |
| 581 | <div class="source"> |
| 582 | <div class="source"> |
| 583 | <pre>{ "message": " hate ccast its voice-clarity is OMG:(", "nearby-messages": { orderedlist: [{ "msgtxt": " hate ccast its voice-clarity is OMG:(" }, { "msgtxt": " like product-w the speed is good:)" } ]} } |
| 584 | { "message": " like x-phone the voice-clarity is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like x-phone the voice-clarity is good:)" } ]} } |
| 585 | { "message": " like product-y the platform is good", "nearby-messages": { orderedlist: [{ "msgtxt": " like product-y the platform is good" } ]} } |
| 586 | { "message": " love product-z its customization is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " love product-z its customization is good:)" } ]} } |
| 587 | { "message": " like product-y the voice-command is amazing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like product-y the voice-command is amazing:)" } ]} } |
| 588 | { "message": " like product-w the speed is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " hate ccast its voice-clarity is OMG:(" }, { "msgtxt": " like product-w the speed is good:)" } ]} } |
| 589 | { "message": " love ccast its voicemail-service is awesome", "nearby-messages": { orderedlist: [{ "msgtxt": " love ccast its voicemail-service is awesome" } ]} } |
| 590 | { "message": " can't stand product-w its speed is terrible:(", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand product-w its speed is terrible:(" } ]} } |
| 591 | { "message": " like product-z the shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like product-z the shortcut-menu is awesome:)" } ]} } |
| 592 | { "message": " can't stand x-phone its platform is terrible", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand x-phone its platform is terrible" } ]} } |
| 593 | { "message": " like ccast its shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like ccast its shortcut-menu is awesome:)" } ]} } |
| 594 | { "message": " like product-b the voice-command is mind-blowing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like product-b the voice-command is mind-blowing:)" } ]} } |
| 595 | </pre></div></div></div></div></div></div> |
| 596 | <div class="section"> |
| 597 | <h3><a name="Query_5_-_Fuzzy_Join"></a>Query 5 - Fuzzy Join</h3> |
| 598 | <div class="section"> |
| 599 | <div class="section"> |
| 600 | <div class="section"> |
| 601 | <h6><a name="AQL"></a>AQL</h6> |
| 602 | <p>use dataverse TinySocial;</p> |
| 603 | |
| 604 | <div class="source"> |
| 605 | <div class="source"> |
| 606 | <pre>set simfunction "edit-distance"; |
| 607 | set simthreshold "3"; |
| 608 | |
| 609 | for $fbu in dataset FacebookUsers |
| 610 | return { |
| 611 | "id": $fbu.id, |
| 612 | "name": $fbu.name, |
| 613 | "similar-users": for $t in dataset TweetMessages |
| 614 | let $tu := $t.user |
| 615 | where $tu.name ~= $fbu.name |
| 616 | return { |
| 617 | "twitter-screenname": $tu.screen-name, |
| 618 | "twitter-name": $tu.name |
| 619 | } |
| 620 | }; |
| 621 | </pre></div></div></div> |
| 622 | <div class="section"> |
| 623 | <h6><a name="JS"></a>JS</h6> |
| 624 | |
| 625 | <div class="source"> |
| 626 | <div class="source"> |
| 627 | <pre>var similarUsersExpression = new FLWOGRExpression() |
| 628 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 629 | .LetClause ("$tu", new AExpression("$t.user")) |
| 630 | .WhereClause(new AExpression("$tu.name ~= $fbu.name")) |
| 631 | .ReturnClause({ |
| 632 | "twitter-screenname": "$tu.screen-name", |
| 633 | "twitter-name": "$tu.name" |
| 634 | }); |
| 635 | |
| 636 | var expression5 = new FLWOGRExpression() |
| 637 | .ForClause ("$fbu", new AExpression("dataset FacebookUsers")) |
| 638 | .ReturnClause( |
| 639 | { |
| 640 | "id" : "$fbu.id", |
| 641 | "name" : "$fbu.name", |
| 642 | "similar-users" : similarUsersExpression |
| 643 | } |
| 644 | ); |
| 645 | </pre></div></div></div> |
| 646 | <div class="section"> |
| 647 | <h6><a name="Results"></a>Results</h6> |
| 648 | |
| 649 | <div class="source"> |
| 650 | <div class="source"> |
| 651 | <pre>{ "id": { int32: 1 } , "name": "MargaritaStoddard", "similar-users": { orderedlist: [ ]} } |
| 652 | { "id": { int32: 2 } , "name": "IsbelDull", "similar-users": { orderedlist: [ ]} } |
| 653 | { "id": { int32: 8 } , "name": "NilaMilliron", "similar-users": { orderedlist: [{ "twitter-screenname": "NilaMilliron_tw", "twitter-name": "Nila Milliron" } ]} } |
| 654 | { "id": { int32: 9 } , "name": "WoodrowNehling", "similar-users": { orderedlist: [ ]} } |
| 655 | { "id": { int32: 10 } , "name": "BramHatch", "similar-users": { orderedlist: [ ]} } |
| 656 | { "id": { int32: 3 } , "name": "EmoryUnk", "similar-users": { orderedlist: [ ]} } |
| 657 | { "id": { int32: 6 } , "name": "WillisWynne", "similar-users": { orderedlist: [ ]} } |
| 658 | { "id": { int32: 7 } , "name": "SuzannaTillson", "similar-users": { orderedlist: [ ]} } |
| 659 | { "id": { int32: 4 } , "name": "NicholasStroh", "similar-users": { orderedlist: [ ]} } |
| 660 | { "id": { int32: 5 } , "name": "VonKemble", "similar-users": { orderedlist: [ ]} } |
| 661 | </pre></div></div></div></div></div></div> |
| 662 | <div class="section"> |
| 663 | <h3><a name="Query_6_-_Existential_Quantification"></a>Query 6 - Existential Quantification</h3> |
| 664 | <div class="section"> |
| 665 | <div class="section"> |
| 666 | <div class="section"> |
| 667 | <h6><a name="AQL"></a>AQL</h6> |
| 668 | |
| 669 | <div class="source"> |
| 670 | <div class="source"> |
| 671 | <pre>use dataverse TinySocial; |
| 672 | |
| 673 | for $fbu in dataset FacebookUsers |
| 674 | where (some $e in $fbu.employment satisfies is-null($e.end-date)) |
| 675 | return $fbu; |
| 676 | </pre></div></div></div> |
| 677 | <div class="section"> |
| 678 | <h6><a name="JS"></a>JS</h6> |
| 679 | |
| 680 | <div class="source"> |
| 681 | <div class="source"> |
| 682 | <pre>var expression6 = new FLWOGRExpression() |
| 683 | .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers")) |
| 684 | .WhereClause( |
| 685 | new QuantifiedExpression ( |
| 686 | "some" , |
| 687 | {"$e" : new AExpression("$fbu.employment") }, |
| 688 | new FunctionExpression("is-null", new AExpression("$e.end-date")) |
| 689 | ) |
| 690 | ) |
| 691 | .ReturnClause("$fbu"); |
| 692 | </pre></div></div></div> |
| 693 | <div class="section"> |
| 694 | <h6><a name="Results"></a>Results</h6> |
| 695 | |
| 696 | <div class="source"> |
| 697 | <div class="source"> |
| 698 | <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 } ]} } |
| 699 | { "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 } ]} } |
| 700 | { "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 } ]} } |
| 701 | { "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 } ]} } |
| 702 | { "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 } ]} } |
| 703 | { "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 } ]} } |
| 704 | { "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 } ]} } |
| 705 | </pre></div></div></div></div></div></div> |
| 706 | <div class="section"> |
| 707 | <h3><a name="Query_7_-_Universal_Quantification"></a>Query 7 - Universal Quantification</h3> |
| 708 | <div class="section"> |
| 709 | <div class="section"> |
| 710 | <div class="section"> |
| 711 | <h6><a name="AQL"></a>AQL</h6> |
| 712 | |
| 713 | <div class="source"> |
| 714 | <div class="source"> |
| 715 | <pre>use dataverse TinySocial; |
| 716 | |
| 717 | for $fbu in dataset FacebookUsers |
| 718 | where (every $e in $fbu.employment satisfies not(is-null($e.end-date))) |
| 719 | return $fbu; |
| 720 | </pre></div></div></div> |
| 721 | <div class="section"> |
| 722 | <h6><a name="JS"></a>JS</h6> |
| 723 | |
| 724 | <div class="source"> |
| 725 | <div class="source"> |
| 726 | <pre>var expression7 = new FLWOGRExpression() |
| 727 | .ForClause("$fbu", new AExpression("dataset FacebookUsers")) |
| 728 | .WhereClause( |
| 729 | new QuantifiedExpression ( |
| 730 | "every" , |
| 731 | {"$e" : new AExpression("$fbu.employment") }, |
| 732 | new FunctionExpression("not", new FunctionExpression("is-null", new AExpression("$e.end-date"))) |
| 733 | ) |
| 734 | ) |
| 735 | .ReturnClause("$fbu"); |
| 736 | </pre></div></div></div> |
| 737 | <div class="section"> |
| 738 | <h6><a name="Results"></a>Results</h6> |
| 739 | |
| 740 | <div class="source"> |
| 741 | <div class="source"> |
| 742 | <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} } ]} } |
| 743 | { "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} } ]} } |
| 744 | { "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} } ]} } |
| 745 | </pre></div></div></div></div></div></div> |
| 746 | <div class="section"> |
| 747 | <h3><a name="Query_8_-_Simple_Aggregation"></a>Query 8 - Simple Aggregation</h3> |
| 748 | <div class="section"> |
| 749 | <div class="section"> |
| 750 | <div class="section"> |
| 751 | <h6><a name="AQL"></a>AQL</h6> |
| 752 | |
| 753 | <div class="source"> |
| 754 | <div class="source"> |
| 755 | <pre>use dataverse TinySocial; |
| 756 | |
| 757 | count(for $fbu in dataset FacebookUsers return $fbu); |
| 758 | </pre></div></div></div> |
| 759 | <div class="section"> |
| 760 | <h6><a name="JS"></a>JS</h6> |
| 761 | |
| 762 | <div class="source"> |
| 763 | <div class="source"> |
| 764 | <pre>var expression8 = new FunctionExpression( |
| 765 | "count", |
| 766 | new FLWOGRExpression() |
| 767 | .ForClause("$fbu", new AExpression("dataset FacebookUsers")) |
| 768 | .ReturnClause("$fbu") |
| 769 | ); |
| 770 | </pre></div></div></div> |
| 771 | <div class="section"> |
| 772 | <h6><a name="Results"></a>Results</h6> |
| 773 | |
| 774 | <div class="source"> |
| 775 | <div class="source"> |
| 776 | <pre>{ int64: 10 } |
| 777 | </pre></div></div></div></div></div></div> |
| 778 | <div class="section"> |
| 779 | <h3><a name="Query_9-A_-_Grouping_and_Aggregation"></a>Query 9-A - Grouping and Aggregation</h3> |
| 780 | <div class="section"> |
| 781 | <div class="section"> |
| 782 | <div class="section"> |
| 783 | <h6><a name="AQL"></a>AQL</h6> |
| 784 | |
| 785 | <div class="source"> |
| 786 | <div class="source"> |
| 787 | <pre>use dataverse TinySocial; |
| 788 | |
| 789 | for $t in dataset TweetMessages |
| 790 | group by $uid := $t.user.screen-name with $t |
| 791 | return { |
| 792 | "user": $uid, |
| 793 | "count": count($t) |
| 794 | }; |
| 795 | </pre></div></div></div> |
| 796 | <div class="section"> |
| 797 | <h6><a name="JS"></a>JS</h6> |
| 798 | |
| 799 | <div class="source"> |
| 800 | <div class="source"> |
| 801 | <pre>var expression9a = new FLWOGRExpression() |
| 802 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 803 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 804 | .ReturnClause( |
| 805 | { |
| 806 | "user" : "$uid", |
| 807 | "count" : new FunctionExpression("count", new AExpression("$t")) |
| 808 | } |
| 809 | ); |
| 810 | </pre></div></div></div> |
| 811 | <div class="section"> |
| 812 | <h6><a name="Results"></a>Results</h6> |
| 813 | |
| 814 | <div class="source"> |
| 815 | <div class="source"> |
| 816 | <pre>{ "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 817 | { "user": "OliJackson_512", "count": { int64: 1 } } |
| 818 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 819 | { "user": "ChangEwing_573", "count": { int64: 1 } } |
| 820 | { "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 821 | </pre></div></div></div></div></div></div> |
| 822 | <div class="section"> |
| 823 | <h3><a name="Query_9-B_-_Hash-Based_Grouping_and_Aggregation"></a>Query 9-B - (Hash-Based) Grouping and Aggregation</h3> |
| 824 | <div class="section"> |
| 825 | <div class="section"> |
| 826 | <div class="section"> |
| 827 | <h6><a name="AQL"></a>AQL</h6> |
| 828 | |
| 829 | <div class="source"> |
| 830 | <div class="source"> |
| 831 | <pre>use dataverse TinySocial; |
| 832 | |
| 833 | for $t in dataset TweetMessages |
| 834 | /*+ hash*/ |
| 835 | group by $uid := $t.user.screen-name with $t |
| 836 | return { |
| 837 | "user": $uid, |
| 838 | "count": count($t) |
| 839 | }; |
| 840 | </pre></div></div></div> |
| 841 | <div class="section"> |
| 842 | <h6><a name="JS"></a>JS</h6> |
| 843 | |
| 844 | <div class="source"> |
| 845 | <div class="source"> |
| 846 | <pre>var expression9b = new FLWOGRExpression() |
| 847 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 848 | .AQLClause("/*+ hash*/") |
| 849 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 850 | .ReturnClause( |
| 851 | { |
| 852 | "user" : "$uid", |
| 853 | "count" : new FunctionExpression("count", new AExpression("$t")) |
| 854 | } |
| 855 | ); |
| 856 | </pre></div></div></div> |
| 857 | <div class="section"> |
| 858 | <h6><a name="Results"></a>Results</h6> |
| 859 | |
| 860 | <div class="source"> |
| 861 | <div class="source"> |
| 862 | <pre>{ "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 863 | { "user": "OliJackson_512", "count": { int64: 1 } } |
| 864 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 865 | { "user": "ChangEwing_573", "count": { int64: 1 } } |
| 866 | { "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 867 | </pre></div></div></div></div></div></div> |
| 868 | <div class="section"> |
| 869 | <h3><a name="Query_10_-_Grouping_and_Limits"></a>Query 10 - Grouping and Limits</h3> |
| 870 | <div class="section"> |
| 871 | <div class="section"> |
| 872 | <div class="section"> |
| 873 | <h6><a name="AQL"></a>AQL</h6> |
| 874 | |
| 875 | <div class="source"> |
| 876 | <div class="source"> |
| 877 | <pre>use dataverse TinySocial; |
| 878 | |
| 879 | for $t in dataset TweetMessages |
| 880 | group by $uid := $t.user.screen-name with $t |
| 881 | let $c := count($t) |
| 882 | order by $c desc |
| 883 | limit 3 |
| 884 | return { |
| 885 | "user": $uid, |
| 886 | "count": $c |
| 887 | }; |
| 888 | </pre></div></div></div> |
| 889 | <div class="section"> |
| 890 | <h6><a name="JS"></a>JS</h6> |
| 891 | |
| 892 | <div class="source"> |
| 893 | <div class="source"> |
| 894 | <pre>var expression10 = new FLWOGRExpression() |
| 895 | .ForClause("$t", new AExpression("dataset TweetMessages")) |
| 896 | .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t") |
| 897 | .LetClause("$c", new FunctionExpression("count", new AExpression("$t"))) |
| 898 | .OrderbyClause( new AExpression("$c"), "desc" ) |
| 899 | .LimitClause(new AExpression("3")) |
| 900 | .ReturnClause( |
| 901 | { |
| 902 | "user" : "$uid", |
| 903 | "count" : "$c" |
| 904 | } |
| 905 | ); |
| 906 | </pre></div></div></div> |
| 907 | <div class="section"> |
| 908 | <h6><a name="Results"></a>Results</h6> |
| 909 | |
| 910 | <div class="source"> |
| 911 | <div class="source"> |
| 912 | <pre>{ "user": "NathanGiesen@211", "count": { int64: 6 } } |
| 913 | { "user": "ColineGeyer@63", "count": { int64: 3 } } |
| 914 | { "user": "NilaMilliron_tw", "count": { int64: 1 } } |
| 915 | </pre></div></div></div></div></div></div> |
| 916 | <div class="section"> |
| 917 | <h3><a name="Query_11_-_Left_Outer_Fuzzy_Join"></a>Query 11 - Left Outer Fuzzy Join</h3> |
| 918 | <div class="section"> |
| 919 | <div class="section"> |
| 920 | <div class="section"> |
| 921 | <h6><a name="AQL"></a>AQL</h6> |
| 922 | |
| 923 | <div class="source"> |
| 924 | <div class="source"> |
| 925 | <pre>use dataverse TinySocial; |
| 926 | |
| 927 | set simfunction "jaccard"; |
| 928 | set simthreshold "0.3"; |
| 929 | |
| 930 | for $t in dataset TweetMessages |
| 931 | return { |
| 932 | "tweet": $t, |
| 933 | "similar-tweets": for $t2 in dataset TweetMessages |
| 934 | where $t2.referred-topics ~= $t.referred-topics |
| 935 | and $t2.tweetid != $t.tweetid |
| 936 | return $t2.referred-topics |
| 937 | }; |
| 938 | </pre></div></div></div> |
| 939 | <div class="section"> |
| 940 | <h6><a name="JS"></a>JS</h6> |
| 941 | |
| 942 | <div class="source"> |
| 943 | <div class="source"> |
| 944 | <pre>var expression11 = new FLWOGRExpression() |
| 945 | .ForClause( "$t", new AExpression("dataset TweetMessages")) |
| 946 | .ReturnClause({ |
| 947 | "tweet" : new AExpression("$t"), |
| 948 | "similar-tweets": new FLWOGRExpression() |
| 949 | .ForClause( "$t2", new AExpression("dataset TweetMessages")) |
| 950 | .WhereClause().and( |
| 951 | new AExpression("$t2.referred-topics ~= $t.referred-topics"), |
| 952 | new AExpression("$t2.tweetid != $t.tweetid") |
| 953 | ) |
| 954 | .ReturnClause("$t2.referred-topics") |
| 955 | }); |
| 956 | </pre></div></div></div> |
| 957 | <div class="section"> |
| 958 | <h6><a name="Results"></a>Results</h6> |
| 959 | |
| 960 | <div class="source"> |
| 961 | <div class="source"> |
| 962 | <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: ["ccast", "voice-clarity" ]}, "message-text": " hate ccast its voice-clarity is OMG:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["x-phone", "voice-clarity" ]}, { unorderedlist: ["ccast", "shortcut-menu" ]}, { unorderedlist: ["ccast", "voicemail-service" ]} ]} } |
| 963 | { "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: ["x-phone", "voice-clarity" ]}, "message-text": " like x-phone the voice-clarity is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["ccast", "voice-clarity" ]}, { unorderedlist: ["x-phone", "platform" ]} ]} } |
| 964 | { "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: ["product-y", "platform" ]}, "message-text": " like product-y the platform is good" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["x-phone", "platform" ]}, { unorderedlist: ["product-y", "voice-command" ]} ]} } |
| 965 | { "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: ["product-z", "customization" ]}, "message-text": " love product-z its customization is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-z", "shortcut-menu" ]} ]} } |
| 966 | { "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: ["product-y", "voice-command" ]}, "message-text": " like product-y the voice-command is amazing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-y", "platform" ]}, { unorderedlist: ["product-b", "voice-command" ]} ]} } |
| 967 | { "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: ["product-w", "speed" ]}, "message-text": " like product-w the speed is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-w", "speed" ]} ]} } |
| 968 | { "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: ["ccast", "voicemail-service" ]}, "message-text": " love ccast its voicemail-service is awesome" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["ccast", "voice-clarity" ]}, { unorderedlist: ["ccast", "shortcut-menu" ]} ]} } |
| 969 | { "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: ["product-w", "speed" ]}, "message-text": " can't stand product-w its speed is terrible:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-w", "speed" ]} ]} } |
| 970 | { "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: ["product-z", "shortcut-menu" ]}, "message-text": " like product-z the shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["ccast", "shortcut-menu" ]}, { unorderedlist: ["product-z", "customization" ]} ]} } |
| 971 | { "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: ["x-phone", "platform" ]}, "message-text": " can't stand x-phone its platform is terrible" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["x-phone", "voice-clarity" ]}, { unorderedlist: ["product-y", "platform" ]} ]} } |
| 972 | { "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: ["ccast", "shortcut-menu" ]}, "message-text": " like ccast its shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-z", "shortcut-menu" ]}, { unorderedlist: ["ccast", "voice-clarity" ]}, { unorderedlist: ["ccast", "voicemail-service" ]} ]} } |
| 973 | { "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: ["product-b", "voice-command" ]}, "message-text": " like product-b the voice-command is mind-blowing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["product-y", "voice-command" ]} ]} } |
| 974 | </pre></div></div></div></div></div></div></div> |
| 975 | </div> |
| 976 | </div> |
| 977 | </div> |
| 978 | |
| 979 | <hr/> |
| 980 | |
| 981 | <footer> |
| 982 | <div class="container-fluid"> |
| 983 | <div class="row span12">Copyright © 2017 |
| 984 | <a href="https://www.apache.org/">The Apache Software Foundation</a>. |
| 985 | All Rights Reserved. |
| 986 | |
| 987 | </div> |
| 988 | |
| 989 | <?xml version="1.0" encoding="UTF-8"?> |
| 990 | <div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache |
| 991 | feather logo, and the Apache AsterixDB project logo are either |
| 992 | registered trademarks or trademarks of The Apache Software |
| 993 | Foundation in the United States and other countries. |
| 994 | All other marks mentioned may be trademarks or registered |
| 995 | trademarks of their respective owners.</div> |
| 996 | |
| 997 | |
| 998 | </div> |
| 999 | </footer> |
| 1000 | </body> |
| 1001 | </html> |