| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# RDF::Query::Plan::NamedGraph |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Plan::NamedGraph - Executable query plan for named graphs. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Plan::NamedGraph version 2.918. |
|
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::NamedGraph; |
|
22
|
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
143
|
use strict; |
|
|
35
|
|
|
|
|
50
|
|
|
|
35
|
|
|
|
|
865
|
|
|
24
|
35
|
|
|
35
|
|
116
|
use warnings; |
|
|
35
|
|
|
|
|
49
|
|
|
|
35
|
|
|
|
|
796
|
|
|
25
|
35
|
|
|
35
|
|
116
|
use Scalar::Util qw(blessed); |
|
|
35
|
|
|
|
|
46
|
|
|
|
35
|
|
|
|
|
1344
|
|
|
26
|
35
|
|
|
35
|
|
127
|
use base qw(RDF::Query::Plan); |
|
|
35
|
|
|
|
|
44
|
|
|
|
35
|
|
|
|
|
2473
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
###################################################################### |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our ($VERSION); |
|
31
|
|
|
|
|
|
|
BEGIN { |
|
32
|
35
|
|
|
35
|
|
22418
|
$VERSION = '2.918'; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###################################################################### |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item C<< new ( $graph, $plan ) >> |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
|
43
|
10
|
|
|
10
|
1
|
16
|
my $class = shift; |
|
44
|
10
|
|
|
|
|
29
|
my $graph = shift; |
|
45
|
10
|
|
|
|
|
13
|
my $plan = shift; |
|
46
|
10
|
|
|
|
|
45
|
my $self = $class->SUPER::new( $graph, $plan ); |
|
47
|
10
|
|
|
|
|
59
|
$self->[0]{referenced_variables} = [ $plan->referenced_variables ]; |
|
48
|
|
|
|
|
|
|
|
|
49
|
10
|
|
|
|
|
47
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.namedgraph"); |
|
50
|
10
|
|
|
|
|
1015
|
$l->trace('constructing named graph plan...'); |
|
51
|
10
|
|
|
|
|
86
|
return $self; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub execute ($) { |
|
59
|
11
|
|
|
11
|
1
|
16
|
my $self = shift; |
|
60
|
11
|
|
|
|
|
13
|
my $context = shift; |
|
61
|
11
|
|
|
|
|
25
|
$self->[0]{delegate} = $context->delegate; |
|
62
|
11
|
50
|
|
|
|
36
|
if ($self->state == $self->OPEN) { |
|
63
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "NamedGraph plan can't be executed while already open"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
11
|
|
|
|
|
37
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.namedgraph"); |
|
67
|
11
|
|
|
|
|
179
|
$l->trace('executing named graph plan'); |
|
68
|
11
|
|
|
|
|
58
|
my $model = $context->model; |
|
69
|
11
|
|
|
|
|
50
|
my $graphs = $model->get_graphs; |
|
70
|
11
|
|
|
|
|
992
|
$self->[0]{graphs} = $graphs; |
|
71
|
11
|
|
50
|
|
|
42
|
$self->[0]{bound} = $context->bound || {}; |
|
72
|
11
|
|
|
|
|
20
|
$self->[0]{context} = $context; |
|
73
|
|
|
|
|
|
|
|
|
74
|
11
|
50
|
|
|
|
58
|
if (my $g = $self->[0]{graphs}->next) { |
|
75
|
11
|
|
|
|
|
55
|
my %bound = %{ $self->[0]{bound} }; |
|
|
11
|
|
|
|
|
30
|
|
|
76
|
11
|
|
|
|
|
37
|
$bound{ $self->graph->name } = $g; |
|
77
|
11
|
|
|
|
|
67
|
my $ctx = $context->copy( bound => \%bound ); |
|
78
|
11
|
|
|
|
|
33
|
my $plan = $self->pattern; |
|
79
|
11
|
|
|
|
|
41
|
$l->trace("Executing named graph pattern with graph " . $g->as_string . ": " . $plan->sse); |
|
80
|
11
|
|
|
|
|
92
|
$plan->execute( $ctx ); |
|
81
|
11
|
|
|
|
|
64
|
$self->[0]{current_graph} = $g; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
11
|
|
|
|
|
44
|
$self->state( $self->OPEN ); |
|
85
|
11
|
|
|
|
|
23
|
$self; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item C<< next >> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub next { |
|
93
|
30
|
|
|
30
|
1
|
33
|
my $self = shift; |
|
94
|
30
|
50
|
|
|
|
58
|
unless ($self->state == $self->OPEN) { |
|
95
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open NAMED GRAPH"; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
30
|
|
|
|
|
37
|
my $context = $self->[0]{context}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
30
|
|
|
|
|
60
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.namedgraph"); |
|
100
|
30
|
|
|
|
|
337
|
while (1) { |
|
101
|
37
|
50
|
|
|
|
126
|
unless ($self->[0]{current_graph}) { |
|
102
|
0
|
|
|
|
|
0
|
return; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
37
|
|
|
|
|
207
|
my $row = $self->pattern->next; |
|
105
|
37
|
100
|
|
|
|
87
|
if ($row) { |
|
106
|
20
|
|
|
|
|
28
|
my $g = $self->[0]{current_graph}; |
|
107
|
20
|
100
|
|
|
|
43
|
if (my $rg = $row->{ $self->graph->name }) { |
|
108
|
18
|
50
|
|
|
|
130
|
unless ($rg->equal( $g )) { |
|
109
|
0
|
|
|
|
|
0
|
next; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
20
|
|
|
|
|
148
|
$row->{ $self->graph->name } = $g; |
|
113
|
20
|
50
|
|
|
|
78
|
if (my $d = $self->delegate) { |
|
114
|
0
|
|
|
|
|
0
|
$d->log_result( $self, $row ); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
20
|
|
|
|
|
60
|
return $row; |
|
117
|
|
|
|
|
|
|
} else { |
|
118
|
17
|
|
|
|
|
53
|
my $g = $self->[0]{graphs}->next; |
|
119
|
17
|
100
|
|
|
|
189
|
unless (blessed($g)) { |
|
120
|
10
|
|
|
|
|
29
|
return; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
7
|
|
|
|
|
13
|
my %bound = %{ $self->[0]{bound} }; |
|
|
7
|
|
|
|
|
22
|
|
|
123
|
7
|
|
|
|
|
30
|
$bound{ $self->graph->name } = $g; |
|
124
|
7
|
|
|
|
|
45
|
my $ctx = $self->[0]{context}->copy( bound => \%bound ); |
|
125
|
7
|
|
|
|
|
20
|
my $plan = $self->pattern; |
|
126
|
7
|
50
|
|
|
|
22
|
if ($plan->state == $plan->OPEN) { |
|
127
|
7
|
|
|
|
|
25
|
$plan->close(); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
7
|
|
|
|
|
27
|
$l->trace("Executing named graph pattern with graph " . $g->as_string); |
|
130
|
7
|
|
|
|
|
95
|
$plan->execute( $ctx ); |
|
131
|
7
|
|
|
|
|
31
|
$self->[0]{current_graph} = $g; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<< close >> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub close { |
|
141
|
11
|
|
|
11
|
1
|
18
|
my $self = shift; |
|
142
|
11
|
50
|
|
|
|
23
|
unless ($self->state == $self->OPEN) { |
|
143
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open NAMED GRAPH"; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
11
|
|
|
|
|
18
|
delete $self->[0]{current_graph}; |
|
146
|
11
|
|
|
|
|
18
|
my $plan = $self->pattern; |
|
147
|
11
|
50
|
|
|
|
24
|
if ($plan->state == $plan->OPEN) { |
|
148
|
11
|
|
|
|
|
35
|
$plan->close(); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
11
|
|
|
|
|
37
|
$self->SUPER::close(); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item C<< graph >> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns the graph variable. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub graph { |
|
160
|
62
|
|
|
62
|
1
|
54
|
my $self = shift; |
|
161
|
62
|
|
|
|
|
154
|
return $self->[1]; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item C<< pattern >> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Returns the query plan that will be used with each named graph in the model. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub pattern { |
|
171
|
77
|
|
|
77
|
1
|
70
|
my $self = shift; |
|
172
|
77
|
|
|
|
|
171
|
return $self->[2]; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item C<< distinct >> |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return distinct results. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub distinct { |
|
182
|
7
|
|
|
7
|
1
|
12
|
my $self = shift; |
|
183
|
7
|
|
|
|
|
17
|
return $self->pattern->distinct; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item C<< ordered >> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return ordered results. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub ordered { |
|
193
|
8
|
|
|
8
|
1
|
10
|
my $self = shift; |
|
194
|
8
|
|
|
|
|
68
|
return []; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item C<< plan_node_name >> |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Returns the string name of this plan node, suitable for use in serialization. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub plan_node_name { |
|
204
|
2
|
|
|
2
|
1
|
5
|
return 'named-graph'; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item C<< plan_prototype >> |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Returns a list of scalar identifiers for the type of the content (children) |
|
210
|
|
|
|
|
|
|
nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable |
|
211
|
|
|
|
|
|
|
identifiers. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub plan_prototype { |
|
216
|
2
|
|
|
2
|
1
|
2
|
my $self = shift; |
|
217
|
2
|
|
|
|
|
9
|
return qw(N P); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item C<< plan_node_data >> |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Returns the data for this plan node that corresponds to the values described by |
|
223
|
|
|
|
|
|
|
the signature returned by C<< plan_prototype >>. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub plan_node_data { |
|
228
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
|
229
|
4
|
|
|
|
|
9
|
return ($self->graph, $self->pattern); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
1; |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
__END__ |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 AUTHOR |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=cut |