AsterixSDK Stable Beta Demo - TinySocial - Simple Aggregate Correct
diff --git a/asterix-app/src/main/resources/sdk/static/example/demo.html b/asterix-app/src/main/resources/sdk/static/example/demo.html
new file mode 100644
index 0000000..3a8d353
--- /dev/null
+++ b/asterix-app/src/main/resources/sdk/static/example/demo.html
@@ -0,0 +1,391 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <title>AsterixDB TinySocial Demo</title>
+
+ <style>
+ .pretty-printed {
+ background-color: #eeeeee;
+ margin-bottom: 1em;
+ }
+
+ .how-to-run {
+ background-color: #c8c8c8;
+ margin-bottom: 1em;
+ }
+
+ .result-output {
+ background-color: #BED8E5;
+ margin-bottom: 1em;
+ }
+
+ body {
+ font-family : "Helvetica";
+ margin-bottom: 1em;
+ }
+ </style>
+
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
+ <script src="../js/asterix-sdk-stable.js"></script>
+ <script src="js/demo.js"></script>
+</head>
+<body>
+ <h1>AQL: Querying TinySocial AsterixDB</h1>
+
+ <h2>Query 0-A - Exact-Match Lookup</h2>
+ <div class="sample-query">
+
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ where $user.id = 8<br/>
+ return $user;<br/>
+ </div>
+
+ <div class="how-to-run">
+ javascript here
+ </div>
+
+ <div class="result-output" id="result0A">
+ </div>
+
+ <button id="run0a">Run #0-A</button>
+ </div>
+ <hr/>
+ <h2>Query 0-B - Range Scan</h2>
+ <div class="sample-query">
+
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ where $user.id >= 2 and $user.id <= 4<br/>
+ return $user;<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result0B">
+ </div>
+
+ <button id="run0b">Run #0-B</button>
+ </div>
+ <hr/>
+
+ <h2>Query 1 - Other Query Filters</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ where $user.user-since >= datetime('2010-07-22T00:00:00')<br/>
+ and $user.user-since <= datetime('2012-07-29T23:59:59')<br/>
+ return $user;<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result1">
+ </div>
+
+ <button id="run1">Run #1</button>
+ </div>
+ <hr/>
+
+ <h2>Query 2-A - Equijoin</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ for $message in dataset FacebookMessages<br/>
+ where $message.author-id = $user.id<br/>
+ return {<br/>
+ "uname": $user.name,<br/>
+ "message": $message.message<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result2a">
+ </div>
+
+ <button id="run2a">Run #2-A</button>
+ </div>
+ <hr/>
+
+ <h2>Query 2-B - Index join</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ for $message in dataset FacebookMessages<br/>
+ where $message.author-id /*+ indexnl */ = $user.id<br/>
+ return {<br/>
+ "uname": $user.name,<br/>
+ "message": $message.message<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result2b">
+ </div>
+
+ <button id="run2b">Run #2-B</button>
+ </div>
+ <hr/>
+
+ <h2>Query 3 - Nested Outer Join</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $user in dataset FacebookUsers<br/>
+ return {<br/>
+ "uname": $user.name,<br/>
+ "messages": for $message in dataset FacebookMessages<br/>
+ where $message.author-id = $user.id<br/>
+ return $message.message<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result3">
+ </div>
+
+ <button id="run3">Run #3</button>
+ </div>
+ <hr/>
+
+ <h2>Query 4 - Theta Join</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $t in dataset TweetMessages<br/>
+ return {<br/>
+ "message": $t.message-text,<br/>
+ "nearby-messages": for $t2 in dataset TweetMessages<br/>
+ where spatial-distance($t.sender-location, $t2.sender-location) <= 1<br/>
+ return { "msgtxt":$t2.message-text}<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result4">
+ </div>
+
+ <button id="run4">Run #4</button>
+ </div>
+ <hr/>
+
+ <h2>Query 5 - Fuzzy Join</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ set simfunction "edit-distance";<br/>
+ set simthreshold "3";<br/><br/>
+
+ for $fbu in dataset FacebookUsers<br/>
+ return {<br/>
+ "id": $fbu.id,<br/>
+ "name": $fbu.name,<br/>
+ "similar-users": for $t in dataset TweetMessages<br/>
+ let $tu := $t.user<br/>
+ where $tu.name ~= $fbu.name<br/>
+ return {<br/>
+ "twitter-screenname": $tu.screen-name,<br/>
+ "twitter-name": $tu.name<br/>
+ }<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result5">
+ </div>
+
+ <button id="run5">Run #5</button>
+ </div>
+ <hr/>
+
+ <h2>Query 6 - Existential Quantification</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $fbu in dataset FacebookUsers<br/>
+ where (some $e in $fbu.employment satisfies is-null($e.end-date))<br/>
+ return $fbu;<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result6">
+ </div>
+
+ <button id="run6">Run #6</button>
+ </div>
+ <hr/>
+
+ <h2>Query 7 - Universal Quantification</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $fbu in dataset FacebookUsers<br/>
+ where (every $e in $fbu.employment satisfies not(is-null($e.end-date))) <br/>
+ return $fbu;<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result7">
+ </div>
+
+ <button id="run7">Run #7</button>
+ </div>
+ <hr/>
+
+ <h2>Query 8 - Simple Aggregation</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ count(for $fbu in dataset FacebookUsers return $fbu);<br/>
+ </div>
+
+ <div class="how-to-run">
+ var expression8 = new FunctionExpression({<br/>
+ "function" : "count",<br/>
+ "expression" : new ForClause("fbu", null, new AsterixExpression().set(["dataset FacebookUsers"])).bind({"return" : "$fbu"}),<br/>
+ "dataverse" : "TinySocial"<br/>
+ }).run();
+ </div>
+
+ <div class="result-output" id="result8">
+ </div>
+
+ <button id="run8">Run #8</button>
+ </div>
+ <hr/>
+
+ <h2>Query 9-A - Grouping and Aggregation</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $t in dataset TweetMessages<br/>
+ group by $uid := $t.user.screen-name with $t<br/>
+ return {<br/>
+ "user": $uid,<br/>
+ "count": count($t)<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result9">
+ </div>
+
+ <button id="run9a">Run #9-A</button>
+ </div>
+ <hr/>
+
+ <h2>Query 9-B - (Hash-Based) Grouping and Aggregation</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $t in dataset TweetMessages<br/>
+ /*+ hash*/<br/>
+ group by $uid := $t.user.screen-name with $t<br/>
+ return {<br/>
+ "user": $uid,<br/>
+ "count": count($t)<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result10">
+ </div>
+
+ <button id="run9b">Run #9-B</button>
+ </div>
+ <hr/>
+
+ <h2>Query 10 - Grouping and Limits</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ for $t in dataset TweetMessages<br/>
+ group by $uid := $t.user.screen-name with $t<br/>
+ let $c := count($t)<br/>
+ order by $c desc<br/>
+ limit 3<br/>
+ return {<br/>
+ "user": $uid,<br/>
+ "count": $c<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result11">
+ </div>
+
+ <button id="run10">Run #10</button>
+ </div>
+ <hr/>
+
+ <h2>Query 11 - Left Outer Fuzzy Join</h2>
+ <div class="sample-query">
+ <div class="pretty-printed">
+ use dataverse TinySocial;<br/><br/>
+
+ set simfunction "jaccard";<br/>
+ set simthreshold "0.3";<br/><br/>
+
+ for $t in dataset TweetMessages<br/>
+ return {<br/>
+ "tweet": $t,<br/>
+ "similar-tweets": for $t2 in dataset TweetMessages<br/>
+ where $t2.referred-topics ~= $t.referred-topics<br/>
+ and $t2.tweetid != $t.tweetid<br/>
+ return $t2.referred-topics<br/>
+ };<br/>
+ </div>
+
+ <div class="how-to-run">
+ </div>
+
+ <div class="result-output" id="result11">
+ </div>
+
+ <button id="run11">Run #11</button>
+ </div>
+
+</body>
+</html>