Implements setstatements and Query 11 - Left Outer Fuzzy Join
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 25aedf9..7298024 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
@@ -154,17 +154,15 @@
$('#result8').html('');
var expression8 = new FunctionExpression({
"function" : "count",
- "expression" : new ForClause(
- "fbu", null, new AsterixExpression().set(["dataset FacebookUsers"])
- ).bind(
- {"return" : new AsterixExpression().set(["$fbu"])}
- ),
+ "expression" : new ForClause("fbu", null, new AExpression().set("dataset FacebookUsers"))
+ .bind( new ReturnClause( new AExpression().set("$fbu") )),
"dataverse" : "TinySocial",
"success" : function(res) {
$('#result8').html(res["results"]);
}
});
- expression8.run();
+ alert(expression8.val());
+ // expression8.run();
});
// 9a - Grouping & Aggregation
@@ -262,14 +260,36 @@
var expression11 = new FLWOGRExpression({
"dataverse" : "TinySocial",
"success" : function(res) {
- alert(JSON.stringify(res));
$('#result11').html(res["results"]);
}
- });
- alert("EXPRESSION 11 " + expression11.val());
+ })
+ .bind( new SetStatement( "simfunction", "jaccard" ))
+ .bind( new SetStatement( "simthreshold", "0.3"))
+ .bind( new ForClause( "t", null, new AsterixExpression().set(["dataset TweetMessages"]) ))
+ .bind( new ReturnClause({
+ "tweet" : new AExpression().set("$t"),
+ "similar-tweets": new FLWOGRExpression()
+ .bind( new ForClause( "t2", null, new AExpression().set("dataset TweetMessages") ))
+ .bind( new AQLClause().set("where $t2.referred-topics ~= $t.referred-topics and $t2.tweetid != $t.tweetid") )
+ .bind( new ReturnClause(new AQLClause().set("$t2.referred-topics")))
+ }));
+
+ expression11.run();
});
+ //$('#run0a').trigger('click');
+ //$('#run0b').trigger('click');
+ //$('#run1').trigger('click');
+ //$('#run2a').trigger('click');
+ //$('#run2b').trigger('click');
+ //$('#run3').trigger('click');
+ //$('#run4').trigger('click');
+ //$('#run5').trigger('click');
+ //$('#run6').trigger('click');
+ //$('#run7').trigger('click');
+ //$('#run8').trigger('click');
$('#run9a').trigger('click');
$('#run9b').trigger('click');
$('#run10').trigger('click');
+ $('#run11').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 870f93b..5854521 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
@@ -301,6 +301,7 @@
AExpression.call(this);
this._properties["clauses"] = [];
+ this._properties["minSize"] = 0;
// Bind options and return
this.bind(options);
@@ -317,7 +318,12 @@
var options = options || {};
- if (this._properties["clauses"].length == 0) {
+ if (options instanceof SetStatement) {
+ this._properties["clauses"].push(options);
+ this._properties["minSize"] += 1;
+ }
+
+ if (this._properties["clauses"].length <= this._properties["minSize"]) {
// Needs to start with for or let clause
if (options instanceof ForClause || options instanceof LetClause) {
this._properties["clauses"].push(options);
@@ -340,7 +346,7 @@
clauseValues.push(this._properties["clauses"][c].val());
}
- return value + clauseValues.join("\n") + ";";
+ return value + clauseValues.join("\n");// + ";";
};
@@ -437,7 +443,7 @@
AQLClause.call(this);
this._properties["clause"] = "return ";
- if (expression instanceof AExpression) {
+ if (expression instanceof AExpression || expression instanceof AQLClause) {
this._properties["clause"] += expression.val();
} else if ( Object.getPrototypeOf( expression ) === Object.prototype ) {
@@ -661,3 +667,21 @@
BooleanExpression.prototype.val = function() {
return this.value;
}
+
+
+// SetStatement
+//
+// Grammar
+// "set" Identifier StringLiteral
+function SetStatement (identifier, stringLiteral) {
+ AExpression.call(this);
+
+ var statement = "set " + identifier + ' "' + stringLiteral + '";';
+
+ AExpression.prototype.set.call(this, statement);
+
+ return this;
+}
+
+SetStatement.prototype = Object.create(AExpression.prototype);
+SetStatement.prototype.constructor = SetStatement;