alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Fuzzy joins two datasets, Customers and Customers2, based on the edit-distance function of their names. |
| 3 | * Customers has a 3-gram index on name, and we expect the join to be transformed into an indexed nested-loop join. |
| 4 | * Success : Yes |
| 5 | */ |
| 6 | |
| 7 | drop dataverse test if exists; |
| 8 | create dataverse test; |
| 9 | use dataverse test; |
| 10 | |
| 11 | create type AddressType as open { |
| 12 | number: int32, |
| 13 | street: string, |
| 14 | city: string |
| 15 | } |
| 16 | |
| 17 | create type CustomerType as open { |
| 18 | cid: int32, |
| 19 | name: string, |
| 20 | age: int32?, |
| 21 | address: AddressType?, |
| 22 | interests: [string], |
| 23 | children: [ { name: string, age: int32? } ] |
| 24 | } |
| 25 | |
| 26 | create dataset Customers(CustomerType) partitioned by key cid; |
| 27 | |
| 28 | create dataset Customers2(CustomerType) partitioned by key cid; |
| 29 | |
| 30 | load dataset Customers |
| 31 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 32 | (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm")); |
| 33 | |
| 34 | load dataset Customers2 |
| 35 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 36 | (("path"="nc1://data/semistructured/co1k_olist/customer.adm"),("format"="adm")); |
| 37 | |
| 38 | create index ngram_index on Customers(name) type ngram(3); |
| 39 | |
| 40 | write output to nc1:"rttest/index-join_inverted-index-ngram-edit-distance.adm"; |
| 41 | |
| 42 | for $a in dataset('Customers') |
| 43 | for $b in dataset('Customers2') |
| 44 | where edit-distance($a.name, $b.name) <= 4 and $a.cid < $b.cid |
| 45 | order by $a.cid, $b.cid |
| 46 | return { "arec": $a, "brec": $b } |