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, |
| 13 | rec: rectangle |
| 14 | } |
| 15 | |
| 16 | create type MyMiniRecord as closed { |
| 17 | id: int32, |
| 18 | point: point |
| 19 | } |
| 20 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 21 | create dataset MyData(MyRecord) |
khfaraaz82@gmail.com | 502731f | 2012-05-02 20:38:16 +0000 | [diff] [blame] | 22 | partitioned by key id; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 23 | |
| 24 | load dataset MyData |
| 25 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 26 | (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted; |
| 27 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 28 | create dataset MyMiniData(MyMiniRecord) |
khfaraaz82@gmail.com | 502731f | 2012-05-02 20:38:16 +0000 | [diff] [blame] | 29 | partitioned by key id; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 30 | |
| 31 | load dataset MyMiniData |
| 32 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 33 | (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted; |
| 34 | |
| 35 | create index rtree_index_point_0 on MyData(point) type rtree; |
| 36 | create index rtree_index_point on MyMiniData(point) type rtree; |
| 37 | |
| 38 | insert into dataset MyMiniData |
| 39 | ( |
| 40 | for $m in dataset('MyData') |
| 41 | return { |
| 42 | "id": $m.id, |
| 43 | "point": $m.point |
| 44 | } |
| 45 | ); |
| 46 | |
| 47 | write output to nc1:"rttest/dml_scan-insert-rtree-secondary-index.adm"; |
| 48 | |
| 49 | for $o in dataset('MyMiniData') |
| 50 | 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))) |
| 51 | order by $o.id |
| 52 | return {"id":$o.id} |