vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | use dataverse events; |
| 2 | |
| 3 | declare type EventType as closed { |
| 4 | event_id: int64, |
| 5 | name: string, |
| 6 | location: AddressType ?, |
| 7 | organizers: {{ |
| 8 | { |
| 9 | name: string |
| 10 | } |
| 11 | }}, |
| 12 | sponsoring_sigs: [ |
| 13 | { |
| 14 | sig_id: int32, |
| 15 | chapter_name: string |
| 16 | } |
| 17 | ], |
| 18 | interest_keywords: {{string}}, |
| 19 | price: double?, |
| 20 | start_time: datetime, |
| 21 | end_time: datetime |
| 22 | } |
| 23 | |
| 24 | declare type AddressType as closed { |
| 25 | street: string, |
| 26 | city: string, |
| 27 | zip: string, |
| 28 | latlong: point |
| 29 | } |
| 30 | |
| 31 | declare nodegroup group1 on nc1; |
| 32 | |
| 33 | /* |
| 34 | declare dataset Event(EventType) |
| 35 | splits nc1:"/home/nicnic/Work/Asterix/adg/event.adm"; |
| 36 | */ |
| 37 | |
| 38 | drop dataset Event; |
| 39 | declare dataset Event(EventType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame^] | 40 | primary key event_id on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 41 | |
| 42 | load dataset Event |
| 43 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 44 | (("path"="nc1:///home/nicnic/Work/Asterix/adg/event.adm"),("format"="adm")); |
| 45 | |
| 46 | write output to nc1:"/tmp/dapd_q2.adm"; |
| 47 | |
| 48 | for $event in dataset('Event') |
| 49 | for $sponsor in $event.sponsoring_sigs |
| 50 | let $es := { "event": $event, "sponsor": $sponsor } |
| 51 | group by $sig_id := $sponsor.sig_id with $es |
| 52 | let $sig_sponsorship_count := count($es) |
| 53 | let $by_chapter := |
| 54 | for $e in $es |
| 55 | group by $chapter_name := $e.sponsor.chapter_name with $e |
| 56 | return { "chapter_name": $chapter_name, "escount" : count($e) } |
| 57 | order by $sig_sponsorship_count desc |
| 58 | limit 5 |
| 59 | return { "sig_id": $sig_id, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter } |
| 60 | |