alexander.behm | 1e74ad5 | 2012-11-06 09:23:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Joins two datasets on the intersection of their point attributes. |
| 3 | * The dataset 'MyData1' has an RTree index, and we expect the |
| 4 | * join to be transformed into an indexed nested-loop join. |
| 5 | * Success : Yes |
| 6 | */ |
| 7 | |
| 8 | drop dataverse test if exists; |
| 9 | create dataverse test; |
| 10 | use dataverse test; |
| 11 | |
| 12 | create type MyRecord as closed { |
| 13 | id: int32, |
| 14 | point: point, |
| 15 | kwds: string, |
| 16 | line1: line, |
| 17 | line2: line, |
| 18 | poly1: polygon, |
| 19 | poly2: polygon, |
salsubaiee@gmail.com | 2a0d817 | 2012-11-11 22:31:52 +0000 | [diff] [blame^] | 20 | rec: rectangle, |
| 21 | circle: circle |
alexander.behm | 1e74ad5 | 2012-11-06 09:23:58 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | create dataset MyData1(MyRecord) partitioned by key id; |
| 25 | create dataset MyData2(MyRecord) partitioned by key id; |
| 26 | |
| 27 | load dataset MyData1 |
| 28 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 29 | (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted; |
| 30 | |
| 31 | load dataset MyData2 |
| 32 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 33 | (("path"="nc1://data/spatial/spatialData.json"),("format"="adm")) pre-sorted; |
| 34 | |
| 35 | create index rtree_index on MyData1(point) type rtree; |
| 36 | |
| 37 | write output to nc1:"rttest/index-join_rtree-spatial-intersect-point.adm"; |
| 38 | |
| 39 | for $a in dataset('MyData1') |
| 40 | for $b in dataset('MyData2') |
| 41 | where spatial-intersect($a.point, $b.point) and $a.id != $b.id |
| 42 | order by $a.id, $b.id |
| 43 | return {"aid": $a.id, "bid": $b.id, "apt": $a.point, "bp": $b.point} |