jarodwen | cbbab14 | 2013-02-01 07:56:46 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Description : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens. |
| 3 | * DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join. |
| 4 | * We test the inlining of variables that enable the select to be pushed into the join for subsequent optimization with an index. |
| 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 | |
| 28 | create dataset DBLP(DBLPType) partitioned by key id; |
| 29 | |
| 30 | create dataset CSX(CSXType) partitioned by key id; |
| 31 | |
| 32 | load dataset DBLP |
| 33 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 34 | (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted; |
| 35 | |
| 36 | load dataset CSX |
| 37 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 38 | (("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); |
| 39 | |
| 40 | create index ngram_index on DBLP(title) type ngram(3); |
| 41 | |
| 42 | write output to nc1:"rttest/inverted-index-join_ngram-jaccard-inline.adm"; |
| 43 | |
| 44 | for $a in dataset('DBLP') |
| 45 | for $b in dataset('CSX') |
| 46 | let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) |
| 47 | where $jacc >= 0.5f and $a.id < $b.id |
| 48 | order by $jacc, $a.id, $b.id |
| 49 | return { "arec": $a, "brec": $b, "jacc": $jacc } |