root/lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/OutputLine/HadoopMap.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::OutputLine::HadoopMap;
2use strict;
3use warnings;
4use base qw(App::Hachero::Plugin::Base);
5use JSON;
6
7sub output_line : Hook {
8    my ($self, $context) = @_;
9    for my $prime_key (keys %{$context->result}) {
10        my $result = $context->result->{$prime_key};
11        for my $second_key (keys %{$result}) {
12            my $value = JSON->new->allow_blessed->encode($result->{$second_key});
13            $self->_writeline("$prime_key-$second_key", $value);
14        }
15    }
16    $context->result( {} );
17}
18
19sub _writeline {
20    my ($self, $key, $value) = @_;
21    my $fh = \*STDOUT;
22    printf $fh "%s\t%s\n", $key, $value;
23}
24
251;
Note: See TracBrowser for help on using the browser.