| /* |
| * Description : Fuzzy joins two datasets, Customer and Customer2, based on ~= using Jaccard of their interest sets. |
| * Customers2 has a keyword index on interests, and we expect the join to be transformed into an indexed nested-loop join. |
| * Success : Yes |
| */ |
| |
| drop dataverse test if exists; |
| create dataverse test; |
| use dataverse test; |
| |
| create type AddressType as closed { |
| number: int32, |
| street: string, |
| city: string |
| } |
| |
| create type CustomerType as closed { |
| cid: int32, |
| name: string, |
| age: int32?, |
| address: AddressType?, |
| interests: {{string}}, |
| children: [ { name: string, age: int32? } ] |
| } |
| |
| create dataset Customers(CustomerType) partitioned by key cid; |
| |
| create dataset Customers2(CustomerType) partitioned by key cid; |
| |
| load dataset Customers |
| using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm")); |
| |
| load dataset Customers2 |
| using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| (("path"="nc1://data/semistructured/co1k/customer.adm"),("format"="adm")); |
| |
| create index interests_index on Customers2(interests) type keyword; |
| |
| write output to nc1:"rttest/inverted-index-join_ulist-fuzzyeq-jaccard_02.adm"; |
| |
| set simfunction 'jaccard'; |
| set simthreshold '0.7f'; |
| |
| for $a in dataset('Customers') |
| for $b in dataset('Customers2') |
| where $a.interests /*+ indexnl */ ~= $b.interests and $a.cid < $b.cid |
| return {"arec": $a, "brec": $b } |