blob: 23e4557e8c7c440c8041712e5ae2b68d86d0853a [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001drop dataverse test if exists;
2create dataverse test;
3use dataverse test;
4
5
6create type AddressType as closed {
7 street: string,
8 city: string,
9 zip: string,
10 latlong: point2d
11}
12
13create type UserType as open{
14 name: string,
15 interests: {{string}},
16 address: AddressType,
17 member_of: {{
18 {
19 sig_id: int32,
20 chapter_name: string,
21 member_since: date
22 }
23}}
24}
25
vinayakb38b7ca42012-03-05 05:44:15 +000026create dataset User(UserType)
khfaraaz82@gmail.com502731f2012-05-02 20:38:16 +000027 partitioned by key name;
vinayakb38b7ca42012-03-05 05:44:15 +000028
29load dataset User
30using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
31(("path"="nc1://data/events/tiny/user.adm"),("format"="json")) pre-sorted;
32
vinayakb38b7ca42012-03-05 05:44:15 +000033write output to nc1:'rttest/dapd_q3.adm';
34
35set simthreshold '.5f';
36
37for $user in dataset('User')
38let $similar_users :=
39 for $similar_user in dataset('User')
40 where $user.name != $similar_user.name
41 and $user.interests ~= $similar_user.interests
42 let $sim := similarity-jaccard($user.interests, $similar_user.interests)
43 order by $sim desc
44 limit 10
45 return { "user_name": $similar_user.name }
46order by $user.name
47return { "user_name" : $user.name, "similar_users" : $similar_users }