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 | |
| 21 | create nodegroup group1 if not exists on nc1, nc2; |
| 22 | |
| 23 | create dataset MyData(MyRecord) |
| 24 | partitioned by key id on group1; |
| 25 | |
| 26 | load dataset MyData |
| 27 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 28 | (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted; |
| 29 | |
| 30 | |
| 31 | create dataset MyMiniData(MyMiniRecord) |
| 32 | partitioned by key id on group1; |
| 33 | |
| 34 | load dataset MyMiniData |
| 35 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 36 | (("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted; |
| 37 | |
| 38 | create index rtree_index_point_0 on MyData(point) type rtree; |
| 39 | create index rtree_index_point on MyMiniData(point) type rtree; |
| 40 | |
| 41 | insert into dataset MyMiniData |
| 42 | ( |
| 43 | for $m in dataset('MyData') |
| 44 | return { |
| 45 | "id": $m.id, |
| 46 | "point": $m.point |
| 47 | } |
| 48 | ); |
| 49 | |
| 50 | write output to nc1:"rttest/dml_scan-insert-rtree-secondary-index.adm"; |
| 51 | |
| 52 | for $o in dataset('MyMiniData') |
| 53 | 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))) |
| 54 | order by $o.id |
| 55 | return {"id":$o.id} |