improvements for demo
- add demo cluster
- add example mugshot.com data and queries
- automatic configuration of a cluster
- set MANAGIX_HOME implicitly
- better AQL lexer error reporting
- better eror reporting in ADM parser
- fix and optimize construction of asterix zip for deployment
Change-Id: I9d80402cef72a15271766031b6f06c7220e4ad5a
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/95
Reviewed-by: Ian Maxon <imaxon@uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Raman Grover <ramang@uci.edu>
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/create.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/create.aql
new file mode 100644
index 0000000..acade56
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/create.aql
@@ -0,0 +1,51 @@
+drop dataverse TinySocial if exists;
+create dataverse TinySocial;
+use dataverse TinySocial;
+
+create type EmploymentType as open {
+ organization-name: string,
+ start-date: date,
+ end-date: date?
+}
+
+create type MugshotUserType as {
+ id: int32,
+ alias: string,
+ name: string,
+ user-since: datetime,
+ address: {
+ street: string,
+ city: string,
+ state: string,
+ zip: string,
+ country: string
+ },
+ friend-ids: {{ int32 }},
+ employment: [EmploymentType]
+}
+
+create type MugshotMessageType as closed {
+ message-id: int32,
+ author-id: int32,
+ timestamp: datetime,
+ in-response-to: int32?,
+ sender-location: point?,
+ tags: {{ string }},
+ message: string
+}
+
+create dataset MugshotUsers(MugshotUserType)
+ primary key id;
+create dataset MugshotMessages(MugshotMessageType)
+ primary key message-id;
+
+create index msUserSinceIdx
+ on MugshotUsers(user-since);
+create index msTimestampIdx
+ on MugshotMessages(timestamp);
+create index msAuthorIdx
+ on MugshotMessages(author-id) type btree;
+create index msSenderLocIndex
+ on MugshotMessages(sender-location) type rtree;
+create index msMessageIdx
+ on MugshotMessages(message) type keyword;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/delete.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/delete.aql
new file mode 100644
index 0000000..504b0af
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/delete.aql
@@ -0,0 +1,4 @@
+use dataverse TinySocial;
+
+delete $user from dataset MugshotUsers
+where $user.id = 999;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/equi-join.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/equi-join.aql
new file mode 100644
index 0000000..740720c
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/equi-join.aql
@@ -0,0 +1,11 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+for $message in dataset MugshotMessages
+where $message.author-id = $user.id
+ and $user.user-since >= datetime('2010-07-22T00:00:00')
+ and $user.user-since <= datetime('2012-07-29T23:59:59')
+return {
+ "uname" : $user.name,
+ "message" : $message.message
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/function-definition.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/function-definition.aql
new file mode 100644
index 0000000..86e28ca
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/function-definition.aql
@@ -0,0 +1,13 @@
+use dataverse TinySocial;
+
+drop function unemployed@0 if exists;
+
+create function unemployed() {
+ for $msu in dataset MugshotUsers
+ where (every $e in $msu.employment
+ satisfies not(is-null($e.end-date)))
+ return {
+ "name" : $msu.name,
+ "address" : $msu.address
+ }
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/function-use.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/function-use.aql
new file mode 100644
index 0000000..80fe6d3
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/function-use.aql
@@ -0,0 +1,5 @@
+use dataverse TinySocial;
+
+for $un in unemployed()
+where $un.address.zip = "94065"
+return $un
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/group-sort-limit.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/group-sort-limit.aql
new file mode 100644
index 0000000..3bdef76
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/group-sort-limit.aql
@@ -0,0 +1,13 @@
+use dataverse TinySocial;
+
+for $msg in dataset MugshotMessages
+where $msg.timestamp >= datetime("2014-02-20T00:00:00")
+ and $msg.timestamp < datetime("2014-03-20T00:00:00")
+group by $aid := $msg.author-id with $msg
+let $cnt := count($msg)
+order by $cnt desc
+limit 3
+return {
+ "author" : $aid,
+ "no messages" : $cnt
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/insert.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/insert.aql
new file mode 100644
index 0000000..e7ab0e6
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/insert.aql
@@ -0,0 +1,23 @@
+use dataverse TinySocial;
+
+insert into dataset MugshotUsers
+(
+ {
+ "id":999,
+ "alias":"John",
+ "name":"JohnDoe",
+ "address":{
+ "street":"789 Jane St",
+ "city":"San Harry",
+ "zip":"98767",
+ "state":"CA",
+ "country":"USA"
+ },
+ "user-since":datetime("2010-08-15T08:10:00"),
+ "friend-ids":{{ 5, 9, 11 }},
+ "employment":[{
+ "organization-name":"Kongreen",
+ "start-date":date("2012-06-05")
+ }]
+ }
+);
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/join-group.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/join-group.aql
new file mode 100644
index 0000000..bead5ac
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/join-group.aql
@@ -0,0 +1,14 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+for $message in dataset MugshotMessages
+where $message.author-id = $user.id
+group by $name := $user.name with $message
+let $avglen := avg(for $m in $message
+ return string-length($m.message))
+order by $avglen desc
+limit 10
+return {
+ "uname" : $name,
+ "msg-length" : $avglen
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-fuzzy-join.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-fuzzy-join.aql
new file mode 100644
index 0000000..1108a6f
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-fuzzy-join.aql
@@ -0,0 +1,19 @@
+use dataverse TinySocial;
+
+set simfunction "jaccard";
+set simthreshold "0.3";
+
+for $msg in dataset MugshotMessages
+let $msgsSimilarTags := (
+ for $m2 in dataset MugshotMessages
+ where $m2.tags ~= $msg.tags
+ and $m2.message-id != $msg.message-id
+ return $m2.message
+ )
+where count($msgsSimilarTags) > 0
+order by count($msgsSimilarTags)
+limit 10
+return {
+ "message" : $msg.message,
+ "similarly tagged" : $msgsSimilarTags
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join-aggr.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join-aggr.aql
new file mode 100644
index 0000000..0f5a3b2
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join-aggr.aql
@@ -0,0 +1,14 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+let $result := {
+ "uname" : $user.name,
+ "msg-length" : avg(
+ for $message in dataset MugshotMessages
+ where $message.author-id = $user.id
+ return string-length($message.message)
+ )
+ }
+order by $result.msg-length desc
+limit 10
+return $result;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join.aql
new file mode 100644
index 0000000..98c634e
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/left-outer-join.aql
@@ -0,0 +1,12 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+where $user.user-since >= datetime('2010-07-22T00:00:00')
+ and $user.user-since <= datetime('2012-07-29T23:59:59')
+return {
+ "uname" : $user.name,
+ "messages" :
+ for $message in dataset MugshotMessages
+ where $message.author-id = $user.id
+ return $message.message
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/load.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/load.aql
new file mode 100644
index 0000000..f123228
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/load.aql
@@ -0,0 +1,7 @@
+use dataverse TinySocial;
+
+load dataset MugshotUsers using localfs
+(("path"="127.0.0.1://../../../examples/mugshot/data/mugshot_users.adm"),("format"="adm"));
+
+load dataset MugshotMessages using localfs
+(("path"="127.0.0.1://../../../examples/mugshot/data/mugshot_messages.adm"),("format"="adm"));
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/lookup.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/lookup.aql
new file mode 100644
index 0000000..d5016cb
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/lookup.aql
@@ -0,0 +1,5 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+where $user.id = 8
+return $user;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/range-scan.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/range-scan.aql
new file mode 100644
index 0000000..23b5698
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/range-scan.aql
@@ -0,0 +1,6 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+where $user.user-since >= datetime('2010-07-22T00:00:00')
+ and $user.user-since <= datetime('2012-07-29T23:59:59')
+return $user;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/simple-aggregation.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/simple-aggregation.aql
new file mode 100644
index 0000000..f27c648
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/simple-aggregation.aql
@@ -0,0 +1,8 @@
+use dataverse TinySocial;
+
+avg(
+ for $m in dataset MugshotMessages
+ where $m.timestamp >= datetime("2014-01-01T00:00:00")
+ and $m.timestamp < datetime("2014-04-01T00:00:00")
+ return string-length($m.message)
+)
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/spatial-join.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/spatial-join.aql
new file mode 100644
index 0000000..14b53de
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/spatial-join.aql
@@ -0,0 +1,11 @@
+use dataverse TinySocial;
+
+for $t in dataset MugshotMessages
+return {
+ "message" : $t.message,
+ "nearby-messages":
+ for $t2 in dataset MugshotMessages
+ where spatial-distance($t.sender-location,
+ $t2.sender-location) <= 1
+ return { "msgtxt" : $t2.message }
+};
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/ten-of-each.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/ten-of-each.aql
new file mode 100644
index 0000000..07371e3
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/ten-of-each.aql
@@ -0,0 +1,9 @@
+use dataverse TinySocial;
+
+for $user in dataset MugshotUsers
+limit 10
+return $user;
+
+for $message in dataset MugshotMessages
+limit 10
+return $message;
diff --git a/asterix-installer/src/main/resources/examples/mugshot/aql/universal.aql b/asterix-installer/src/main/resources/examples/mugshot/aql/universal.aql
new file mode 100644
index 0000000..1752caf
--- /dev/null
+++ b/asterix-installer/src/main/resources/examples/mugshot/aql/universal.aql
@@ -0,0 +1,10 @@
+use dataverse TinySocial;
+
+for $msu in dataset MugshotUsers
+where (every $e in $msu.employment
+ satisfies not(is-null($e.end-date)))
+limit 10
+return {
+ "name" : $msu.name,
+ "address" : $msu.address
+};