line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::Plan::Sequence |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Plan::Sequence - Executable query plan for a sequence of operations. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Plan::Sequence version 2.916. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
15
|
|
|
|
|
|
|
L<RDF::Query::Plan> class. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=over 4 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package RDF::Query::Plan::Sequence; |
22
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
192
|
use strict; |
|
35
|
|
|
|
|
72
|
|
|
35
|
|
|
|
|
957
|
|
24
|
35
|
|
|
35
|
|
181
|
use warnings; |
|
35
|
|
|
|
|
144
|
|
|
35
|
|
|
|
|
984
|
|
25
|
35
|
|
|
35
|
|
187
|
use base qw(RDF::Query::Plan); |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
2565
|
|
26
|
|
|
|
|
|
|
|
27
|
35
|
|
|
35
|
|
278
|
use Scalar::Util qw(blessed); |
|
35
|
|
|
|
|
71
|
|
|
35
|
|
|
|
|
1659
|
|
28
|
35
|
|
|
35
|
|
239
|
use RDF::Trine::Statement; |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
1621
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
###################################################################### |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our ($VERSION); |
33
|
|
|
|
|
|
|
BEGIN { |
34
|
35
|
|
|
35
|
|
21303
|
$VERSION = '2.916'; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
###################################################################### |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item C<< new ( @plans ) >> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
45
|
0
|
|
|
|
|
|
my @plans = @_; |
46
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( \@plans ); |
47
|
0
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub execute ($) { |
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
my $context = shift; |
57
|
0
|
|
|
|
|
|
$self->[0]{delegate} = $context->delegate; |
58
|
0
|
0
|
|
|
|
|
if ($self->state == $self->OPEN) { |
59
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "SEQUENCE plan can't be executed twice"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.sequence"); |
63
|
0
|
|
|
|
|
|
$l->trace( "executing RDF::Query::Plan::Sequence" ); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @plans = @{ $self->[1] }; |
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
while (scalar(@plans) > 1) { |
67
|
0
|
|
|
|
|
|
my $p = shift(@plans); |
68
|
0
|
|
|
|
|
|
$p->execute( $context ); |
69
|
0
|
|
|
|
|
|
1 while ($p->next); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
my $iter = $plans[0]->execute( $context ); |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if (blessed($iter)) { |
74
|
0
|
|
|
|
|
|
$self->[0]{iter} = $iter; |
75
|
0
|
|
|
|
|
|
$self->state( $self->OPEN ); |
76
|
|
|
|
|
|
|
} else { |
77
|
0
|
|
|
|
|
|
warn "no iterator in execute()"; |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
$self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item C<< next >> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub next { |
87
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
88
|
0
|
0
|
|
|
|
|
unless ($self->state == $self->OPEN) { |
89
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open SEQUENCE"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $iter = $self->[0]{iter}; |
93
|
0
|
|
|
|
|
|
my $row = $iter->next; |
94
|
0
|
0
|
|
|
|
|
if (my $d = $self->delegate) { |
95
|
0
|
|
|
|
|
|
$d->log_result( $self, $row ); |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
return $row; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C<< close >> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub close { |
105
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
106
|
0
|
0
|
|
|
|
|
unless ($self->state == $self->OPEN) { |
107
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open SEQUENCE"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
delete $self->[0]{iter}; |
111
|
0
|
|
|
|
|
|
$self->SUPER::close(); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item C<< distinct >> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return distinct results. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub distinct { |
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
|
my @plans = @{ $self->[1] }; |
|
0
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $plans[ $#plans ]->distinct; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item C<< ordered >> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return ordered results. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub ordered { |
133
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
134
|
0
|
|
|
|
|
|
my @plans = @{ $self->[1] }; |
|
0
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return $plans[ $#plans ]->ordered; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item C<< plan_node_name >> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns the string name of this plan node, suitable for use in serialization. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub plan_node_name { |
145
|
0
|
|
|
0
|
1
|
|
return 'sequence'; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item C<< plan_prototype >> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Returns a list of scalar identifiers for the type of the content (children) |
151
|
|
|
|
|
|
|
nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable |
152
|
|
|
|
|
|
|
identifiers. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub plan_prototype { |
157
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
158
|
0
|
|
|
|
|
|
return qw(*P); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item C<< plan_node_data >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns the data for this plan node that corresponds to the values described by |
164
|
|
|
|
|
|
|
the signature returned by C<< plan_prototype >>. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub plan_node_data { |
169
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
170
|
0
|
|
|
|
|
|
my @triples = @{ $self->[1] }; |
|
0
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
return @triples; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
__END__ |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |