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