line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pipeline::Action::Count; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2012
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'Data::Pipeline::Action'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has name => ( |
7
|
|
|
|
|
|
|
isa => 'Str', |
8
|
|
|
|
|
|
|
is => 'rw', |
9
|
|
|
|
|
|
|
lazy => 1, |
10
|
|
|
|
|
|
|
default => 'count' |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub reduce_iterator { |
14
|
|
|
|
|
|
|
my($self, $iterator) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# print STDERR "iterator: $iterator\n"; |
17
|
|
|
|
|
|
|
my $count = 0; |
18
|
|
|
|
|
|
|
until( $iterator -> finished ) { $iterator -> next; $count++; } #print STDERR "count: ", $iterator -> next, "\n"; $count++; } |
19
|
|
|
|
|
|
|
return { |
20
|
|
|
|
|
|
|
$self -> name => $count |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub meta_reduce { |
25
|
|
|
|
|
|
|
my($self, $iterator) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $count = 0; |
28
|
|
|
|
|
|
|
$count += $iterator -> next -> {$self -> name} until $iterator -> finished; |
29
|
|
|
|
|
|
|
return { |
30
|
|
|
|
|
|
|
$self -> name => $count |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |