line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1239
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
|
|
|
|
|
|
package RDF::Flow::Cascade; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$RDF::Flow::Cascade::VERSION = '0.178'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
#ABSTRACT: Returns the first non-empty response of a sequence of sources |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use Log::Contextual::WarnLogger; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
10
|
1
|
|
|
|
|
14
|
use Log::Contextual qw(:log), -default_logger |
11
|
1
|
|
|
1
|
|
5
|
=> Log::Contextual::WarnLogger->new({ env_prefix => __PACKAGE__ }); |
|
1
|
|
|
|
|
2
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2238
|
use parent 'RDF::Flow::Source'; |
|
1
|
|
|
|
|
440
|
|
|
1
|
|
|
|
|
6
|
|
14
|
|
|
|
|
|
|
use RDF::Flow::Source qw(:util); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Carp 'croak'; |
17
|
|
|
|
|
|
|
use Scalar::Util 'blessed'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
|
|
|
|
|
|
my $class = shift; |
21
|
|
|
|
|
|
|
my ($inputs, $args) = sourcelist_args( @_ ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $self = bless { |
24
|
|
|
|
|
|
|
inputs => $inputs, |
25
|
|
|
|
|
|
|
name => ($args->{name} || 'anonymous cascade'), |
26
|
|
|
|
|
|
|
}, $class; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->match( $args->{match} ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub about { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
$self->name($self) . ' with ' . $self->size . ' inputs'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub retrieve { # TODO: try/catch errors? |
39
|
|
|
|
|
|
|
my ($self, $env) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
log_trace { 'retrieve from ' . $self->about; } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $i = 1; |
44
|
|
|
|
|
|
|
my $rdf; |
45
|
|
|
|
|
|
|
foreach my $src ( $self->inputs ) { |
46
|
|
|
|
|
|
|
$rdf = $src->retrieve( $env ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
next unless defined $rdf; |
49
|
|
|
|
|
|
|
if ( blessed $rdf and $rdf->isa('RDF::Trine::Model') ) { |
50
|
|
|
|
|
|
|
last if $rdf->size > 0; |
51
|
|
|
|
|
|
|
} elsif ( blessed $rdf and $rdf->isa('RDF::Trine::Iterator') ) { |
52
|
|
|
|
|
|
|
last if $rdf->peek; |
53
|
|
|
|
|
|
|
} else { |
54
|
|
|
|
|
|
|
croak 'unexpected response in ' . $self->name . ': ' . $rdf; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$i++; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->timestamp( $env ); |
61
|
|
|
|
|
|
|
$self->trigger_retrieved( $rdf, "%s returned $i. with %s" ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _graphviz_edgeattr { |
65
|
|
|
|
|
|
|
my ($self,$n) = @_; |
66
|
|
|
|
|
|
|
my %attr = (label => sprintf("%d.",$n)); |
67
|
|
|
|
|
|
|
$attr{style} = 'dotted' if $n > 1; |
68
|
|
|
|
|
|
|
return %attr; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
RDF::Flow::Cascade - Returns the first non-empty response of a sequence of sources |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
version 0.178 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
use RDF::Flow qw(cascade); |
88
|
|
|
|
|
|
|
$src = cascade( @sources ); # shortcut |
89
|
|
|
|
|
|
|
$src = cascade( @sources, name => 'foo' ); # with name |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use RDF::Flow::Cascade; |
92
|
|
|
|
|
|
|
$src = RDF::Flow::Cascade->new( @sources ); # explicit |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$rdf = $src->retrieve( $env ); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This L<RDF::Flow::Source> returns the first non-empty response of a given |
99
|
|
|
|
|
|
|
sequence of sources. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SEE ALSO |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<RDF::Flow::Union>, L<RDF::Flow::Pipeline> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Jakob Voà <voss@gbv.de> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Jakob VoÃ. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
114
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|