blob: 9c871b2500d978683bee301831247b1d0b6ea187 [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
26
27create nodegroup group1 if not exists on nc1, nc2;
28
29create dataset User(UserType)
30 partitioned by key name on group1;
31
32load dataset User
33using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
34(("path"="nc1://data/events/tiny/user.adm"),("format"="json")) pre-sorted;
35
36
37write output to nc1:'rttest/dapd_q3.adm';
38
39set simthreshold '.5f';
40
41for $user in dataset('User')
42let $similar_users :=
43 for $similar_user in dataset('User')
44 where $user.name != $similar_user.name
45 and $user.interests ~= $similar_user.interests
46 let $sim := similarity-jaccard($user.interests, $similar_user.interests)
47 order by $sim desc
48 limit 10
49 return { "user_name": $similar_user.name }
50order by $user.name
51return { "user_name" : $user.name, "similar_users" : $similar_users }