alexander.behm | 954083a | 2012-11-15 04:01:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Fuzzy self joins a dataset, DBLP, based on the similarity-jaccard function of its 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; |
ramangrover29 | a321120 | 2013-05-19 11:56:49 -0700 | [diff] [blame] | 12 | set import-private-functions 'true'; |
alexander.behm | 954083a | 2012-11-15 04:01:23 +0000 | [diff] [blame] | 13 | |
| 14 | create type DBLPType as closed { |
| 15 | id: int32, |
| 16 | dblpid: string, |
| 17 | title: string, |
| 18 | authors: string, |
| 19 | misc: string |
| 20 | } |
| 21 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 22 | create dataset DBLP(DBLPType) primary key id; |
alexander.behm | 954083a | 2012-11-15 04:01:23 +0000 | [diff] [blame] | 23 | |
| 24 | create index ngram_index on DBLP(title) type ngram(3); |
| 25 | |
| 26 | write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm"; |
| 27 | |
| 28 | for $a in dataset('DBLP') |
| 29 | for $b in dataset('DBLP') |
| 30 | let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) |
| 31 | where $jacc >= 0.5f and $a.id < $b.id |
ramangrover29 | a321120 | 2013-05-19 11:56:49 -0700 | [diff] [blame] | 32 | return {"atitle": $a.title, "btitle": $b.title, "jacc": $jacc} |