vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse test if exists; |
| 2 | create dataverse test; |
| 3 | use dataverse test; |
| 4 | |
| 5 | |
| 6 | create type AddressType as closed { |
| 7 | street: string, |
| 8 | city: string, |
| 9 | zip: string, |
| 10 | latlong: point2d |
| 11 | } |
| 12 | |
| 13 | create 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 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 26 | create dataset User(UserType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 27 | primary key name; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 28 | |
| 29 | load dataset User |
| 30 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 31 | (("path"="nc1://data/events/tiny/user.adm"),("format"="json")) pre-sorted; |
| 32 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 33 | write output to nc1:'rttest/dapd_q3.adm'; |
| 34 | |
| 35 | set simthreshold '.5f'; |
| 36 | |
| 37 | for $user in dataset('User') |
| 38 | let $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 } |
| 46 | order by $user.name |
| 47 | return { "user_name" : $user.name, "similar_users" : $similar_users } |