line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pipeline::Aggregator::Pipeline; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2080
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
extends 'Data::Pipeline::Aggregator'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use MooseX::Types::Moose qw(ArrayRef CodeRef); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Data::Pipeline::Types qw(Iterator Adapter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Data::Pipeline::Machine (); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has actions => ( |
13
|
|
|
|
|
|
|
isa => 'ArrayRef', |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
predicate => 'has_actions', |
16
|
|
|
|
|
|
|
default => sub { [ ] }, |
17
|
|
|
|
|
|
|
lazy => 1 |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub from { |
21
|
|
|
|
|
|
|
my($self, %options) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if( !$self -> has_actions ) { |
24
|
|
|
|
|
|
|
Carp::croak "Pipeline doesn't have an adapter from which to get data"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my($source, @rest) = @{$self -> actions}; |
28
|
|
|
|
|
|
|
$source = $source -> () if is_CodeRef( $source ); |
29
|
|
|
|
|
|
|
$source = $source -> duplicate( %options ) if is_Adapter( $source ); |
30
|
|
|
|
|
|
|
$source = to_Iterator( $source ); |
31
|
|
|
|
|
|
|
if( !is_Iterator( $source ) ) { |
32
|
|
|
|
|
|
|
Carp::croak "Pipeline doesn't have a source from which to get data"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $cascade = $source; |
36
|
|
|
|
|
|
|
for my $action ( @rest ) { |
37
|
|
|
|
|
|
|
$cascade = $action -> transform( $cascade ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $cascade; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub transform { |
44
|
|
|
|
|
|
|
my($self, $iterator) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#Data::Pipeline::Machine::with_options($options, sub { |
47
|
|
|
|
|
|
|
$iterator = to_Iterator( $iterator ); |
48
|
|
|
|
|
|
|
#$iterator -> options( $options ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $iterator unless $self -> has_actions; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $cascade = $iterator; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#my $first = 1; |
55
|
|
|
|
|
|
|
for my $action (@{$self -> actions}) { |
56
|
|
|
|
|
|
|
#next if $first && $action -> isa('Data::Pipeline::Adapter'); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#$first = 0; |
59
|
|
|
|
|
|
|
#$action -> options( $options ); |
60
|
|
|
|
|
|
|
$cascade = $action -> transform( $cascade ); |
61
|
|
|
|
|
|
|
# $cascade -> options( $options ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $cascade; |
65
|
|
|
|
|
|
|
#}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Data::Pipeline::Aggregator::Pipeline - serial aggregation of actions |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 Creation |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$pipeline = Data::Pipeline::Aggregator::Pipeline -> new( |
81
|
|
|
|
|
|
|
actions => \@actions |
82
|
|
|
|
|
|
|
) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
or |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use Data::Pipeline qw( Pipeline ); |
87
|
|
|
|
|
|
|
$pipeline = Pipeline( @actions ); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 Use |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$out_iterator = $pipeline -> from( %options ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$out_iterator = $pipeline -> transform( $in_iterator ) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|