|
Revision 19262, 0.6 kB
(checked in by lopnor, 5 years ago)
|
|
lang/perl/App-Hachero: hadoop streaming support, but not tested yet.
|
| Line | |
|---|
| 1 | package App::Hachero::Plugin::Output::HadoopReduce; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use base 'App::Hachero::Plugin::Base'; |
|---|
| 5 | |
|---|
| 6 | sub 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 | |
|---|
| 20 | sub _writeline { |
|---|
| 21 | my ($self, $key, @value) = @_; |
|---|
| 22 | my $fh = \*STDOUT; |
|---|
| 23 | printf $fh "%s\t%s\n", $key, join ("\t", @value); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | 1; |
|---|