line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::Plan::Load |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Plan::Load - Executable query plan for LOAD operations. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Plan::Load 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::Load; |
22
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
203
|
use strict; |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
1011
|
|
24
|
35
|
|
|
35
|
|
183
|
use warnings; |
|
35
|
|
|
|
|
76
|
|
|
35
|
|
|
|
|
937
|
|
25
|
35
|
|
|
35
|
|
181
|
use base qw(RDF::Query::Plan); |
|
35
|
|
|
|
|
82
|
|
|
35
|
|
|
|
|
2435
|
|
26
|
|
|
|
|
|
|
|
27
|
35
|
|
|
35
|
|
219
|
use Log::Log4perl; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
315
|
|
28
|
35
|
|
|
35
|
|
1880
|
use Scalar::Util qw(blessed); |
|
35
|
|
|
|
|
99
|
|
|
35
|
|
|
|
|
1902
|
|
29
|
35
|
|
|
35
|
|
206
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
35
|
|
|
|
|
70
|
|
|
35
|
|
|
|
|
275
|
|
30
|
|
|
|
|
|
|
|
31
|
35
|
|
|
35
|
|
4043
|
use RDF::Query::Error qw(:try); |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
254
|
|
32
|
35
|
|
|
35
|
|
4443
|
use RDF::Query::ExecutionContext; |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
793
|
|
33
|
35
|
|
|
35
|
|
187
|
use RDF::Query::VariableBindings; |
|
35
|
|
|
|
|
80
|
|
|
35
|
|
|
|
|
1470
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###################################################################### |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our ($VERSION); |
38
|
|
|
|
|
|
|
BEGIN { |
39
|
35
|
|
|
35
|
|
26248
|
$VERSION = '2.916'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
###################################################################### |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item C<< new ( $url, $graph ) >> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
50
|
0
|
|
|
|
|
|
my $url = shift; |
51
|
0
|
|
|
|
|
|
my $graph = shift; |
52
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( $url, $graph ); |
53
|
0
|
|
|
|
|
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub execute ($) { |
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
my $context = shift; |
63
|
0
|
|
|
|
|
|
$self->[0]{delegate} = $context->delegate; |
64
|
0
|
0
|
|
|
|
|
if ($self->state == $self->OPEN) { |
65
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "LOAD plan can't be executed while already open"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); |
69
|
0
|
|
|
|
|
|
$l->trace( "executing RDF::Query::Plan::Load" ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
my %args = ($self->namedgraph) ? (context => $self->namedgraph) : (); |
72
|
0
|
|
|
|
|
|
my $ok = 0; |
73
|
|
|
|
|
|
|
try { |
74
|
0
|
|
|
0
|
|
|
RDF::Trine::Parser->parse_url_into_model( $self->url->uri_value, $context->model, %args ); |
75
|
0
|
|
|
|
|
|
$ok = 1; |
76
|
0
|
|
|
0
|
|
|
} catch RDF::Trine::Error with {}; |
77
|
0
|
|
|
|
|
|
$self->[0]{ok} = $ok; |
78
|
0
|
|
|
|
|
|
$self->state( $self->OPEN ); |
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 LOAD"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); |
93
|
0
|
|
|
|
|
|
$self->close(); |
94
|
0
|
0
|
|
|
|
|
if (my $d = $self->delegate) { |
95
|
0
|
|
|
|
|
|
$d->log_result( $self, $self->[0]{ok} ); |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
return $self->[0]{ok}; |
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 LOAD"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
delete $self->[0]{ok}; |
111
|
0
|
|
|
|
|
|
$self->SUPER::close(); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item C<< url >> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the URL to load data from. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub url { |
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
|
return $self->[1]; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item C<< namedgraph >> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns the optional graph name to load the data with. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub namedgraph { |
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
return $self->[2]; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<< distinct >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return distinct results. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub distinct { |
143
|
0
|
|
|
0
|
1
|
|
return 1; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item C<< ordered >> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return ordered results. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub ordered { |
153
|
0
|
|
|
0
|
1
|
|
return []; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item C<< plan_node_name >> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns the string name of this plan node, suitable for use in serialization. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub plan_node_name { |
163
|
0
|
|
|
0
|
1
|
|
return 'load'; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item C<< plan_prototype >> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns a list of scalar identifiers for the type of the content (children) |
169
|
|
|
|
|
|
|
nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable |
170
|
|
|
|
|
|
|
identifiers. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub plan_prototype { |
175
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
176
|
0
|
|
|
|
|
|
return qw(N N); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item C<< plan_node_data >> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Returns the data for this plan node that corresponds to the values described by |
182
|
|
|
|
|
|
|
the signature returned by C<< plan_prototype >>. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub plan_node_data { |
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
188
|
0
|
|
|
|
|
|
return ($self->url, $self->namedgraph); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item C<< graph ( $g ) >> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub graph { |
196
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
197
|
0
|
|
|
|
|
|
my $g = shift; |
198
|
0
|
|
|
|
|
|
my $label = $self->graph_labels; |
199
|
0
|
|
|
|
|
|
my $url = $self->url->uri_value; |
200
|
0
|
|
|
|
|
|
$g->add_node( "$self", label => "Load" . $self->graph_labels ); |
201
|
0
|
|
|
|
|
|
$g->add_node( "${self}$url", label => $url ); |
202
|
0
|
|
|
|
|
|
$g->add_edge( "$self" => "${self}$url", label => 'url' ); |
203
|
0
|
|
|
|
|
|
return "$self"; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item C<< is_update >> |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Returns true if the plan represents an update operation. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub is_update { |
213
|
0
|
|
|
0
|
1
|
|
return 1; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
__END__ |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 AUTHOR |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |