vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse rares03 if exists; |
| 2 | |
| 3 | create dataverse rares03; |
| 4 | |
| 5 | use dataverse rares03; |
| 6 | |
| 7 | create type UserType as open { |
| 8 | uid: int32, |
| 9 | name: string, |
| 10 | lottery_numbers: {{int32}} |
| 11 | } |
| 12 | |
| 13 | create type VisitorType as open { |
| 14 | vid: int32, |
| 15 | name: string, |
| 16 | lottery_numbers: {{int32}} |
| 17 | } |
| 18 | |
| 19 | create nodegroup group1 if not exists on nc1, nc2; |
| 20 | |
| 21 | create dataset Users(UserType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 22 | primary key uid on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 23 | |
| 24 | create dataset Visitors(VisitorType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 25 | primary key vid on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | // set simfunction "jaccard"; |
| 29 | // set simthreshold ".8"; |
| 30 | |
| 31 | write output to nc1:"/tmp/rares03.adm"; |
| 32 | |
| 33 | for $user in dataset('Users') |
| 34 | let $tokens := |
| 35 | for $lottery_number in $user.lottery_numbers |
| 36 | for $token at $i in |
| 37 | for $user in dataset('Users') |
| 38 | for $lottery_number in $user.lottery_numbers |
| 39 | group by $item := $lottery_number with $user |
| 40 | let $count := count($user) |
| 41 | order by $count desc |
| 42 | return $item |
| 43 | where $lottery_number = $token |
| 44 | order by $token |
| 45 | return $i |
| 46 | return {"uid": $user.uid, "tokens": $tokens} |