Added asterix project

git-svn-id: https://asterixdb.googlecode.com/svn/trunk/asterix@12 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql
new file mode 100644
index 0000000..0face3b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation-with-filtering.aql
@@ -0,0 +1,41 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Tweet as closed {
+	id: int32,
+	tweetid: int64,
+	loc: point,
+	time: datetime,
+	text: string
+}
+
+create nodegroup group1 if not exists on nc1, nc2;
+
+create dataset TwitterData(Tweet)
+  partitioned by key id on group1;
+
+
+load dataset TwitterData 
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm")) pre-sorted;
+
+create index rtree_index_point on TwitterData(loc) type rtree;
+
+write output to nc1:"rttest/spatial_cell-aggregation-with-filtering.adm";
+
+for $t in dataset('TwitterData')
+let $keyword := "Allergies"
+let $region := polygon("
+	33.80503407287759,-126.41235263538363 
+	44.9090773200516,-126.41235263538363 
+	44.9090773200516,-87.65258701038363 
+	33.80503407287759,-87.65258701038363")
+
+where spatial-intersect($t.loc, $region)  and
+$t.time > datetime("2011-05-15T00:00:00Z") and $t.time < datetime("2011-05-16T23:59:59Z") and
+contains($t.text, $keyword)
+group by $c := spatial-cell($t.loc, create-point(24.5,-125.5), 3.0, 3.0) with $t
+let $num :=  count($t)
+order by $num
+return { "cell": $c, "count": $num }
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation.aql
new file mode 100644
index 0000000..44ad6ea
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/cell-aggregation.aql
@@ -0,0 +1,23 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  loc: point
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialDataAggregation.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_cell-aggregation.adm";
+
+let $grid :=
+for $o in dataset('MyData')
+group by $c := spatial-cell($o.loc, create-point(0.0,0.0), 5.0, 5.0) with $o
+let $num :=  count($o)
+order by $num
+return { "cell": $c, "count": $num}
+for $g in $grid
+return $g
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql
new file mode 100644
index 0000000..6018671
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/circle-intersect-circle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_circle-intersect-circle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect(create-circle(create-point(0.0,0.0), 5.0), create-circle(create-point(9.9,0.0), 5.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/distance-between-points.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/distance-between-points.aql
new file mode 100644
index 0000000..c02eba2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/distance-between-points.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_distance-between-points.adm";
+
+for $o in dataset('MyData')
+let $distance := spatial-distance($o.point, create-point(0.0, 0.0))
+order by $o.id
+return {"id":$o.id, "distance":$distance}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-circle.aql
new file mode 100644
index 0000000..035ec63
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-circle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_line-intersect-circle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.line1, create-circle(create-point(0.0,0.0), 5.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-line.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-line.aql
new file mode 100644
index 0000000..e844030
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-line.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_line-intersect-line.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.line1, $o.line2)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-polygon.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-polygon.aql
new file mode 100644
index 0000000..7ed8e25
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-polygon.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_line-intersect-polygon.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.line1, $o.poly1)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-rectangle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-rectangle.aql
new file mode 100644
index 0000000..940f5c4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/line-intersect-rectangle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+  using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+  (("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_line-intersect-rectangle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.line1, $o.rec)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point-equals-point.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point-equals-point.aql
new file mode 100644
index 0000000..90d488f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point-equals-point.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_point-equals-point.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, create-point(5.0,1.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-circle.aql
new file mode 100644
index 0000000..9f9e451
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-circle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_point-in-circle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, create-circle(create-point(0.0,0.0), 5.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-polygon.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-polygon.aql
new file mode 100644
index 0000000..c239185
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-polygon.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_point-in-polygon.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, $o.poly1)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-rectangle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-rectangle.aql
new file mode 100644
index 0000000..86d3dd9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point-in-rectangle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_point-in-rectangle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, $o.rec)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/point-on-line.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/point-on-line.aql
new file mode 100644
index 0000000..66908b8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/point-on-line.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_point-on-line.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.point, $o.line1)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-circle.aql
new file mode 100644
index 0000000..acd29a8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-circle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_polygon-intersect-circle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.poly1, create-circle(create-point(6.0,3.0), 1.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-polygon.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-polygon.aql
new file mode 100644
index 0000000..2a14dbd
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-polygon.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_polygon-intersect-polygon.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.poly1, $o.poly2)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-rectangle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-rectangle.aql
new file mode 100644
index 0000000..16bb5a1
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/polygon-intersect-rectangle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_polygon-intersect-rectangle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.poly1, $o.rec)
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-circle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-circle.aql
new file mode 100644
index 0000000..4f7c004
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-circle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_rectangle-intersect-circle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.rec, create-circle(create-point(4.1,4.1), 1.0))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql
new file mode 100644
index 0000000..90c9f77
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/rectangle-intersect-rectangle.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_rectangle-intersect-rectangle.adm";
+
+for $o in dataset('MyData')
+where spatial-intersect($o.rec, create-rectangle(create-point(-1.0,5.0), create-point(4.5,9.0)))
+order by $o.id
+return {"id":$o.id}
+ 
diff --git a/asterix-app/src/test/resources/runtimets/queries/spatial/spatial-area.aql b/asterix-app/src/test/resources/runtimets/queries/spatial/spatial-area.aql
new file mode 100644
index 0000000..7f6c0b7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/spatial/spatial-area.aql
@@ -0,0 +1,21 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type MyRecord as open {
+  id: int32,
+  point: point,
+  kwds: string
+}
+
+create external dataset MyData(MyRecord)
+using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
+(("path"="nc1://data/spatial/spatialData.json"),("format"="adm"));
+
+write output to nc1:"rttest/spatial_spatial-area.adm";
+
+let $polygonArea := spatial-area(create-polygon(create-point(1.0,1.0),create-point(1.0,4.0),create-point(3.0,4.0),create-point(3.0,1.0)))
+let $circleArea := spatial-area(create-circle(create-point(0.0,0.0), 1.0))
+let $rectangleArea := spatial-area(create-rectangle(create-point(0.0,5.0), create-point(8.0,8.0)))
+return {"polygonArea":$polygonArea, "circleArea":$circleArea, "rectangleArea":$rectangleArea}
+