alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Equi joins two datasets, DBLP and CSX, based on their title. |
| 3 | * DBLP has a secondary btree index on title, and given the 'indexnl' hint |
| 4 | * we expect the 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 DBLPType as closed { |
| 13 | id: int32, |
| 14 | dblpid: string, |
| 15 | title: string, |
| 16 | authors: string, |
| 17 | misc: string |
| 18 | } |
| 19 | |
| 20 | create type CSXType as closed { |
| 21 | id: int32, |
| 22 | csxid: string, |
| 23 | title: string, |
| 24 | authors: string, |
| 25 | misc: string |
| 26 | } |
| 27 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 28 | create dataset DBLP(DBLPType) primary key id; |
| 29 | create dataset CSX(CSXType) primary key id; |
alexander.behm | 3caae9e | 2012-11-08 04:50:20 +0000 | [diff] [blame] | 30 | |
| 31 | load dataset DBLP |
| 32 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 33 | (("path"="nc1://data/pub-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); |
| 34 | |
| 35 | load dataset CSX |
| 36 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 37 | (("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); |
| 38 | |
| 39 | create index title_index on DBLP(authors); |
| 40 | |
| 41 | write output to nc1:"rttest/index-join_btree-secondary-equi-join.adm"; |
| 42 | |
| 43 | for $a in dataset('DBLP') |
| 44 | for $b in dataset('CSX') |
| 45 | where $a.authors /*+ indexnl */ = $b.authors |
| 46 | order by $a.id, $b.id |
| 47 | return {"aid": $a.id, "bid": $b.id, "authors": $a.authors} |