root/lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Output/HadoopReduce.pm @ 19262

Revision 19262, 0.6 kB (checked in by lopnor, 5 years ago)

lang/perl/App-Hachero: hadoop streaming support, but not tested yet.

Line 
1package App::Hachero::Plugin::Output::HadoopReduce;
2use strict;
3use warnings;
4use base 'App::Hachero::Plugin::Base';
5
6sub output : Hook {
7    my ( $self, $context ) = @_;
8    for my $prime_key (keys %{$context->result}) {
9        my $result = $context->result->{$prime_key};
10        for my $second_key (keys %{$result}) {
11            $self->_writeline(
12                $prime_key,
13                map {$result->{$second_key}->{$_}} sort keys %{$result->{$second_key}}
14            );
15
16        }
17    }
18}
19
20sub _writeline {
21    my ($self, $key, @value) = @_;
22    my $fh = \*STDOUT;
23    printf $fh "%s\t%s\n", $key, join ("\t", @value);
24}
25
261;
Note: See TracBrowser for help on using the browser.