vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse test if exists; |
| 2 | create dataverse test; |
| 3 | use dataverse test; |
| 4 | |
| 5 | create type MyRecord as closed { |
| 6 | id: int32, |
| 7 | point: point, |
| 8 | kwds: string, |
| 9 | line1: line, |
| 10 | line2: line, |
| 11 | poly1: polygon, |
| 12 | poly2: polygon, |
salsubaiee@gmail.com | 2a0d817 | 2012-11-11 22:31:52 +0000 | [diff] [blame] | 13 | rec: rectangle, |
| 14 | circle: circle |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | create type MyMiniRecord as closed { |
| 18 | id: int32, |
| 19 | point: point |
| 20 | } |
| 21 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 22 | create dataset MyData(MyRecord) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 23 | primary key id; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 24 | |
| 25 | load dataset MyData |
| 26 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 27 | (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted; |
| 28 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 29 | create dataset MyMiniData(MyMiniRecord) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 30 | primary key id; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 31 | |
| 32 | load dataset MyMiniData |
| 33 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 34 | (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted; |
| 35 | |
| 36 | create index rtree_index_point_0 on MyData(point) type rtree; |
| 37 | create index rtree_index_point on MyMiniData(point) type rtree; |
| 38 | |
| 39 | insert into dataset MyMiniData |
| 40 | ( |
| 41 | for $m in dataset('MyData') |
| 42 | return { |
| 43 | "id": $m.id, |
| 44 | "point": $m.point |
| 45 | } |
| 46 | ); |
| 47 | |
| 48 | write output to nc1:"rttest/dml_scan-insert-rtree-secondary-index.adm"; |
| 49 | |
| 50 | for $o in dataset('MyMiniData') |
| 51 | where spatial-intersect($o.point, create-polygon(create-point(0.0,1.0), create-point(0.0,4.0), create-point(12.0,4.0), create-point(12.0,1.0))) |
| 52 | order by $o.id |
| 53 | return {"id":$o.id} |