blob: fdb046986c7728414a25e242b70526810c05ccfb [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001use dataverse events;
2
3declare 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
24declare type AddressType as closed {
25 street: string,
26 city: string,
27 zip: string,
28 latlong: point
29}
30
31declare nodegroup group1 on nc1;
32
33/*
34declare dataset Event(EventType)
35 splits nc1:"/home/nicnic/Work/Asterix/adg/event.adm";
36*/
37
38drop dataset Event;
39declare dataset Event(EventType)
ramangrover29669d8f62013-02-11 06:03:32 +000040 primary key event_id on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000041
42load dataset Event
43using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
44(("path"="nc1:///home/nicnic/Work/Asterix/adg/event.adm"),("format"="adm"));
45
46write output to nc1:"/tmp/dapd_q2.adm";
47
48for $event in dataset('Event')
49for $sponsor in $event.sponsoring_sigs
50let $es := { "event": $event, "sponsor": $sponsor }
51group by $sig_id := $sponsor.sig_id with $es
52let $sig_sponsorship_count := count($es)
53let $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) }
57order by $sig_sponsorship_count desc
58limit 5
59return { "sig_id": $sig_id, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
60