2つのレベルのグループ化のように見えるものを実行するときにPigについて質問があります。例として、次のような入力データの例があるとします。
email_id:chararray from:chararray to:bag{recipients:tuple(recipient:chararray)}
e1 user1@example.com {(friend1@example.com),(friend2@example.com),(friend3@myusers.com)}
e2 user1@example.com {(friend1@example.com),(friend4@example.com)}
e3 user1@example.com {(friend5@example.com)}
e4 user2@example.com {(friend2@example.com),(friend4@example.com)}
したがって、各行は、ユーザー「from」からユーザー「to」への電子メールです。
そして、最終的には、すべての送信者と送信先のすべての人のリストが必要です。これには、各人に送信された電子メールの数が含まれ、たとえば次のように並べ替えられます。
user1@example.com {(friend1@example.com, 2), (friend2@example.com, 1), (friend3@example.com, 1), (friend4@example.com, 1), (friend5@example.com, 1)}
user2@example.com {(friend2@example.com, 1), (friend4@example.com, 1)}
Pigでこれに取り組むための最良の方法に関するアイデアをいただければ幸いです。