Show
Ignore:
Timestamp:
09/24/08 00:37:05 (6 years ago)
Author:
lopnor
Message:

lang/perl/App-Hachero: hadoop support for A::H::Result

Location:
lang/perl/App-Hachero/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Parse/HadoopReduce.pm

    r19363 r19783  
    33use warnings; 
    44use base 'App::Hachero::Plugin::Base'; 
     5use App::Hachero::Result; 
    56 
    67sub parse : Hook { 
     
    1213    my $record = $context->result->{$prime}->{$second}; 
    1314    if ($record) { 
    14         $record->{count} += $VAR1->{count}; 
     15        $record->count_up($VAR1->{count}); 
    1516    } else { 
    1617        $context->result->{$prime}->{$second} = $VAR1; 
  • lang/perl/App-Hachero/trunk/lib/App/Hachero/Result.pm

    r19782 r19783  
    6969 
    7070sub count_up { 
    71     shift->{count}++; 
     71    my ($self, $n) = @_; 
     72    $n ||= 1; 
     73    shift->{count} += $n; 
    7274} 
    7375 
  • lang/perl/App-Hachero/trunk/t/plugin/output_line/01_hadoop_map.t

    r19768 r19783  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 3; 
     3use Test::More tests => 4; 
    44use App::Hachero; 
    55use App::Hachero::Result; 
     
    4444my $VAR1; 
    4545eval $value; 
     46isa_ok $VAR1, 'App::Hachero::Result::Data'; 
    4647is_deeply $VAR1, {a => 1, count => 1}; 
  • lang/perl/App-Hachero/trunk/t/plugin/parse/03_hadoop_reduce.t

    r19363 r19783  
    1616my $app = App::Hachero->new({config => $config}); 
    1717 
    18 $app->currentline(qq(hoo-bar\t\$VAR1={"a" => 1,"count" => 3}\n)); 
     18$app->currentline(qq(hoo-bar\t\$VAR1=bless( {"a" => 1,"count" => 3}, 'App::Hachero::Result::Data' )\n)); 
    1919$app->run_hook('parse'); 
    2020is_deeply $app->result->{hoo}->{bar}, {a => 1, count => 3}; 
    21 $app->currentline(qq(hoo-bar\t\$VAR1={"a" => 1,"count" => 7}\n)); 
     21$app->currentline(qq(hoo-bar\t\$VAR1=bless( {"a" => 1,"count" => 7}, 'App::Hachero::Result::Data' )\n)); 
    2222$app->run_hook('parse'); 
    2323is_deeply $app->result->{hoo}->{bar}, {a => 1, count => 10};