alexander.behm | 417fb9b | 2012-11-15 19:36:44 +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 | * We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary. |
| 6 | * Success : Yes |
| 7 | */ |
| 8 | |
| 9 | drop dataverse test if exists; |
| 10 | create dataverse test; |
| 11 | use dataverse test; |
| 12 | |
| 13 | create type DBLPType as closed { |
| 14 | id: int32, |
| 15 | dblpid: string, |
| 16 | title: string, |
| 17 | authors: string, |
| 18 | misc: string |
| 19 | } |
| 20 | |
| 21 | create type CSXType as closed { |
| 22 | id: int32, |
| 23 | csxid: string, |
| 24 | title: string, |
| 25 | authors: string, |
| 26 | misc: string |
| 27 | } |
| 28 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 29 | create dataset DBLP(DBLPType) primary key id; |
alexander.behm | 417fb9b | 2012-11-15 19:36:44 +0000 | [diff] [blame] | 30 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 31 | create dataset CSX(CSXType) primary key id; |
alexander.behm | 417fb9b | 2012-11-15 19:36:44 +0000 | [diff] [blame] | 32 | |
| 33 | load dataset DBLP |
| 34 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 35 | (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted; |
| 36 | |
| 37 | load dataset CSX |
| 38 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 39 | (("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":")); |
| 40 | |
| 41 | create index ngram_index on DBLP(title) type ngram(3); |
| 42 | |
| 43 | write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm"; |
| 44 | |
| 45 | for $a in dataset('DBLP') |
| 46 | for $b in dataset('CSX') |
| 47 | let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) |
| 48 | where $jacc >= 0.5f and $a.id < $b.id |
| 49 | order by $jacc, $a.id, $b.id |
| 50 | return { "a": $a.title, "b": $b.title, "jacc": $jacc } |