Implements 9A & 9B TinySocial (Grouping & Aggreggation)
diff --git a/asterix-app/src/main/resources/sdk/static/example/js/demo.js b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
index b5c5ae8..25aedf9 100644
--- a/asterix-app/src/main/resources/sdk/static/example/js/demo.js
+++ b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
@@ -174,25 +174,52 @@
var expression9a = new FLWOGRExpression({
"dataverse" : "TinySocial",
"success" : function(res) {
- alert(JSON.stringify(res));
$('#result9a').html(res["results"]);
}
- });
- alert("EXPRESSION 9a " + expression9a.val());
+ })
+ .bind( new ForClause("t", null, new AsterixExpression().set(["dataset TweetMessages"])))
+ .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
+ .bind( new ReturnClause(
+ {
+ "user" : "$uid",
+ "count" : new FunctionExpression(
+ {
+ "function" : "count",
+ "expression" : new AsterixExpression().set(["$t"])
+ }
+ )
+ }
+ ));
+
+ expression9a.run();
});
- // 9b - Hash-bAsed Grouping & Aggregation
+ // 9b - Hash-based Grouping & Aggregation
$("#run9b").click(function() {
$('#result9b').html('');
var expression9b = new FLWOGRExpression({
"dataverse" : "TinySocial",
"success" : function(res) {
- alert(JSON.stringify(res));
$('#result9b').html(res["results"]);
}
- });
- alert("EXPRESSION 9b " + expression9b.val());
+ })
+ .bind( new ForClause("t", null, new AsterixExpression().set(["dataset TweetMessages"])))
+ .bind( new AQLClause().set("/*+ hash*/"))
+ .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
+ .bind( new ReturnClause(
+ {
+ "user" : "$uid",
+ "count" : new FunctionExpression(
+ {
+ "function" : "count",
+ "expression" : new AsterixExpression().set(["$t"])
+ }
+ )
+ }
+ ));
+
+ expression9b.run();
});
// 10 - Grouping and Limits
@@ -242,4 +269,7 @@
alert("EXPRESSION 11 " + expression11.val());
});
+ $('#run9a').trigger('click');
+ $('#run9b').trigger('click');
+ $('#run10').trigger('click');
});
diff --git a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
index ad8421d..870f93b 100644
--- a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
+++ b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
@@ -372,6 +372,11 @@
return this;
};
+AQLClause.prototype.set = function(value) {
+ this._properties["clause"] = value;
+ return this;
+};
+
// ForClause
//