| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# RDF::Query::Plan::Copy |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Plan::Copy - Executable query plan for COPY operations. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Plan::Copy 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::Copy; |
|
22
|
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
250
|
use strict; |
|
|
35
|
|
|
|
|
83
|
|
|
|
35
|
|
|
|
|
988
|
|
|
24
|
35
|
|
|
35
|
|
184
|
use warnings; |
|
|
35
|
|
|
|
|
74
|
|
|
|
35
|
|
|
|
|
963
|
|
|
25
|
35
|
|
|
35
|
|
191
|
use base qw(RDF::Query::Plan); |
|
|
35
|
|
|
|
|
78
|
|
|
|
35
|
|
|
|
|
2549
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
35
|
|
|
35
|
|
203
|
use Log::Log4perl; |
|
|
35
|
|
|
|
|
85
|
|
|
|
35
|
|
|
|
|
283
|
|
|
28
|
35
|
|
|
35
|
|
1619
|
use Scalar::Util qw(blessed); |
|
|
35
|
|
|
|
|
76
|
|
|
|
35
|
|
|
|
|
1717
|
|
|
29
|
35
|
|
|
35
|
|
194
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
|
35
|
|
|
|
|
81
|
|
|
|
35
|
|
|
|
|
277
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
35
|
|
|
35
|
|
3913
|
use RDF::Query::Error qw(:try); |
|
|
35
|
|
|
|
|
85
|
|
|
|
35
|
|
|
|
|
349
|
|
|
32
|
35
|
|
|
35
|
|
5117
|
use RDF::Query::ExecutionContext; |
|
|
35
|
|
|
|
|
86
|
|
|
|
35
|
|
|
|
|
831
|
|
|
33
|
35
|
|
|
35
|
|
202
|
use RDF::Query::VariableBindings; |
|
|
35
|
|
|
|
|
80
|
|
|
|
35
|
|
|
|
|
1501
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###################################################################### |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our ($VERSION); |
|
38
|
|
|
|
|
|
|
BEGIN { |
|
39
|
35
|
|
|
35
|
|
31587
|
$VERSION = '2.916'; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
###################################################################### |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item C<< new ( $from, $to, $silent ) >> |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
|
49
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
50
|
0
|
|
|
|
|
|
my $from = shift; |
|
51
|
0
|
|
|
|
|
|
my $to = shift; |
|
52
|
0
|
|
|
|
|
|
my $silent = shift; |
|
53
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( $from, $to, $silent ); |
|
54
|
0
|
|
|
|
|
|
return $self; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub execute ($) { |
|
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
|
my $context = shift; |
|
64
|
0
|
|
|
|
|
|
$self->[0]{delegate} = $context->delegate; |
|
65
|
0
|
0
|
|
|
|
|
if ($self->state == $self->OPEN) { |
|
66
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "COPY plan can't be executed while already open"; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.copy"); |
|
70
|
0
|
|
|
|
|
|
$l->trace( "executing RDF::Query::Plan::Copy" ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $from = $self->from; |
|
73
|
0
|
|
|
|
|
|
my $to = $self->to; |
|
74
|
|
|
|
|
|
|
# warn "Copying graph " . $from->as_string; |
|
75
|
0
|
|
|
|
|
|
my $ok = 0; |
|
76
|
|
|
|
|
|
|
try { |
|
77
|
0
|
0
|
|
0
|
|
|
if ($from->equal( $to )) { |
|
78
|
|
|
|
|
|
|
# no-op |
|
79
|
|
|
|
|
|
|
} else { |
|
80
|
0
|
|
|
|
|
|
my $model = $context->model; |
|
81
|
0
|
|
|
|
|
|
$model->begin_bulk_ops(); |
|
82
|
0
|
|
|
|
|
|
$model->remove_statements( undef, undef, undef, $to ); |
|
83
|
0
|
|
|
|
|
|
my $iter = $model->get_statements( undef, undef, undef, $from ); |
|
84
|
0
|
|
|
|
|
|
while (my $st = $iter->next) { |
|
85
|
0
|
|
|
|
|
|
$model->add_statement( $st, $to ); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
$model->end_bulk_ops(); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
|
$ok = 1; |
|
90
|
0
|
|
|
0
|
|
|
} catch RDF::Trine::Error with {}; |
|
91
|
0
|
|
|
|
|
|
$self->[0]{ok} = $ok; |
|
92
|
0
|
|
|
|
|
|
$self->state( $self->OPEN ); |
|
93
|
0
|
|
|
|
|
|
$self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<< next >> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub next { |
|
101
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
102
|
0
|
0
|
|
|
|
|
unless ($self->state == $self->OPEN) { |
|
103
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open COPY"; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $l = Log::Log4perl->get_logger("rdf.query.plan.copy"); |
|
107
|
0
|
|
|
|
|
|
$self->close(); |
|
108
|
0
|
0
|
|
|
|
|
if (my $d = $self->delegate) { |
|
109
|
0
|
|
|
|
|
|
$d->log_result( $self, $self->[0]{ok} ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
0
|
|
|
|
|
|
return $self->[0]{ok}; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item C<< close >> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub close { |
|
119
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
120
|
0
|
0
|
|
|
|
|
unless ($self->state == $self->OPEN) { |
|
121
|
0
|
|
|
|
|
|
throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open COPY"; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
delete $self->[0]{ok}; |
|
125
|
0
|
|
|
|
|
|
$self->SUPER::close(); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<< from >> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns the graph node which is to be copied. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub from { |
|
135
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
136
|
0
|
|
|
|
|
|
return $self->[1]; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item C<< to >> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns the graph node to which data is copied. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub to { |
|
146
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
147
|
0
|
|
|
|
|
|
return $self->[2]; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item C<< silent >> |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns the silent flag. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub silent { |
|
157
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
return $self->[3]; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item C<< distinct >> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return distinct results. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub distinct { |
|
168
|
0
|
|
|
0
|
1
|
|
return 1; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item C<< ordered >> |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return ordered results. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub ordered { |
|
178
|
0
|
|
|
0
|
1
|
|
return []; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item C<< plan_node_name >> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returns the string name of this plan node, suitable for use in serialization. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub plan_node_name { |
|
188
|
0
|
|
|
0
|
1
|
|
return 'copy'; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item C<< plan_prototype >> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns a list of scalar identifiers for the type of the content (children) |
|
194
|
|
|
|
|
|
|
nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable |
|
195
|
|
|
|
|
|
|
identifiers. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub plan_prototype { |
|
200
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
201
|
0
|
|
|
|
|
|
return qw(N N); |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item C<< plan_node_data >> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Returns the data for this plan node that corresponds to the values described by |
|
207
|
|
|
|
|
|
|
the signature returned by C<< plan_prototype >>. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub plan_node_data { |
|
212
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
213
|
0
|
|
|
|
|
|
return ($self->from, $self->to); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item C<< graph ( $g ) >> |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub graph { |
|
221
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
222
|
0
|
|
|
|
|
|
my $g = shift; |
|
223
|
0
|
|
|
|
|
|
my $label = $self->graph_labels; |
|
224
|
0
|
|
|
|
|
|
my $furl = $self->from->uri_value; |
|
225
|
0
|
|
|
|
|
|
my $turl = $self->to->uri_value; |
|
226
|
0
|
|
|
|
|
|
$g->add_node( "$self", label => "Copy" . $self->graph_labels ); |
|
227
|
0
|
|
|
|
|
|
$g->add_node( "${self}$furl", label => $furl ); |
|
228
|
0
|
|
|
|
|
|
$g->add_node( "${self}$turl", label => $turl ); |
|
229
|
0
|
|
|
|
|
|
$g->add_edge( "$self" => "${self}$furl", label => 'from' ); |
|
230
|
0
|
|
|
|
|
|
$g->add_edge( "$self" => "${self}$turl", label => 'to' ); |
|
231
|
0
|
|
|
|
|
|
return "$self"; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item C<< is_update >> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Returns true if the plan represents an update operation. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub is_update { |
|
241
|
0
|
|
|
0
|
1
|
|
return 1; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
1; |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
__END__ |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=back |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 AUTHOR |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |