blob: f2f330e2748e9ba418fd927b29d3bfaed171883d [file] [log] [blame]
alexander.behm417fb9b2012-11-15 19:36:44 +00001/*
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
9drop dataverse test if exists;
10create dataverse test;
11use dataverse test;
12
13create type DBLPType as closed {
14 id: int32,
15 dblpid: string,
16 title: string,
17 authors: string,
18 misc: string
19}
20
21create type CSXType as closed {
22 id: int32,
23 csxid: string,
24 title: string,
25 authors: string,
26 misc: string
27}
28
ramangrover29669d8f62013-02-11 06:03:32 +000029create dataset DBLP(DBLPType) primary key id;
alexander.behm417fb9b2012-11-15 19:36:44 +000030
ramangrover29669d8f62013-02-11 06:03:32 +000031create dataset CSX(CSXType) primary key id;
alexander.behm417fb9b2012-11-15 19:36:44 +000032
33load dataset DBLP
34using "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
37load dataset CSX
38using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
39(("path"="nc1://data/pub-small/csx-small-id.txt"),("format"="delimited-text"),("delimiter"=":"));
40
41create index ngram_index on DBLP(title) type ngram(3);
42
43write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard-inline.adm";
44
45for $a in dataset('DBLP')
46for $b in dataset('CSX')
47let $jacc := similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false))
48where $jacc >= 0.5f and $a.id < $b.id
49order by $jacc, $a.id, $b.id
50return { "a": $a.title, "b": $b.title, "jacc": $jacc }