| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# RDF::Query::Plan::Constant |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Plan::Constant - Executable query plan for Constants. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Plan::Constant version 2.915_01. |
|
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::Constant; |
|
22
|
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
186
|
use strict; |
|
|
35
|
|
|
|
|
145
|
|
|
|
35
|
|
|
|
|
943
|
|
|
24
|
35
|
|
|
35
|
|
188
|
use warnings; |
|
|
35
|
|
|
|
|
77
|
|
|
|
35
|
|
|
|
|
947
|
|
|
25
|
35
|
|
|
35
|
|
190
|
use base qw(RDF::Query::Plan); |
|
|
35
|
|
|
|
|
74
|
|
|
|
35
|
|
|
|
|
3319
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
###################################################################### |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our ($VERSION); |
|
30
|
|
|
|
|
|
|
BEGIN { |
|
31
|
35
|
|
|
35
|
|
22407
|
$VERSION = '2.915_01'; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
###################################################################### |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item C<< new ( @variable_bindings ) >> |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
|
41
|
21
|
|
|
21
|
1
|
41
|
my $class = shift; |
|
42
|
21
|
|
|
|
|
53
|
my @binds = @_; |
|
43
|
21
|
|
|
|
|
134
|
my $self = $class->SUPER::new( \@binds ); |
|
44
|
21
|
|
|
|
|
45
|
$self->[0]{referenced_variables} = [ keys %{ $binds[0] } ]; |
|
|
21
|
|
|
|
|
233
|
|
|
45
|
21
|
|
|
|
|
81
|
return $self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub execute ($) { |
|
53
|
35
|
|
|
35
|
1
|
64
|
my $self = shift; |
|
54
|
35
|
|
|
|
|
54
|
my $context = shift; |
|
55
|
35
|
|
|
|
|
119
|
$self->[0]{delegate} = $context->delegate; |
|
56
|
35
|
50
|
|
|
|
139
|
if ($self->state == $self->OPEN) { |
|
57
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "CONSTANT plan can't be executed while already open"; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
35
|
|
|
|
|
91
|
$self->[0]{'index'} = 0; |
|
61
|
35
|
|
|
|
|
155
|
$self->state( $self->OPEN ); |
|
62
|
35
|
|
|
|
|
228
|
$self; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<< bindings >> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns a list of the variable bindings for this constant result set. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub bindings { |
|
72
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
73
|
0
|
|
0
|
|
|
0
|
my $binds = $self->[1] || []; |
|
74
|
0
|
|
|
|
|
0
|
return @$binds; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item C<< is_unit >> |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns true if this constant result set is comprised of a single, empty variable binding. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub is_unit { |
|
84
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
85
|
0
|
|
|
|
|
0
|
my @binds = $self->bindings; |
|
86
|
0
|
0
|
|
|
|
0
|
return 0 unless scalar(@binds) == 1; |
|
87
|
0
|
|
|
|
|
0
|
my @keys = keys %{ $binds[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
88
|
0
|
|
|
|
|
0
|
return not(scalar(@keys)); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item C<< next >> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub next { |
|
96
|
69
|
|
|
69
|
1
|
222
|
my $self = shift; |
|
97
|
69
|
50
|
|
|
|
207
|
unless ($self->state == $self->OPEN) { |
|
98
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open CONSTANT"; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
69
|
|
|
|
|
123
|
my $binds = $self->[1]; |
|
101
|
69
|
100
|
|
|
|
116
|
if ($self->[0]{'index'} > $#{ $binds }) { |
|
|
69
|
|
|
|
|
199
|
|
|
102
|
30
|
|
|
|
|
114
|
return; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
39
|
|
|
|
|
95
|
my $row = $binds->[ $self->[0]{'index'}++ ]; |
|
105
|
39
|
50
|
|
|
|
169
|
if ($row) { |
|
106
|
39
|
|
|
|
|
132
|
my $bindings = RDF::Query::VariableBindings->new( $row ); |
|
107
|
39
|
50
|
|
|
|
191
|
if (my $d = $self->delegate) { |
|
108
|
0
|
|
|
|
|
0
|
$d->log_result( $self, $bindings ); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
39
|
|
|
|
|
151
|
return $bindings; |
|
111
|
|
|
|
|
|
|
} else { |
|
112
|
0
|
|
|
|
|
0
|
return; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item C<< close >> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub close { |
|
121
|
31
|
|
|
31
|
1
|
52
|
my $self = shift; |
|
122
|
31
|
50
|
|
|
|
125
|
unless ($self->state == $self->OPEN) { |
|
123
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open CONSTANT"; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
31
|
|
|
|
|
76
|
delete $self->[0]{'index'}; |
|
126
|
31
|
|
|
|
|
121
|
$self->SUPER::close(); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item C<< size >> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub size { |
|
134
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
135
|
0
|
|
|
|
|
0
|
return scalar( @{ $self->[1] } ); |
|
|
0
|
|
|
|
|
0
|
|
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item C<< distinct >> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return distinct results. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub distinct { |
|
145
|
|
|
|
|
|
|
# XXX could check constant data to determine if it's unique |
|
146
|
12
|
|
|
12
|
1
|
50
|
return 0; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item C<< ordered >> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns true if the pattern is guaranteed to return ordered results. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub ordered { |
|
156
|
|
|
|
|
|
|
# XXX could check constant data to determine if it's ordered |
|
157
|
11
|
|
|
11
|
1
|
73
|
return []; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item C<< plan_node_name >> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns the string name of this plan node, suitable for use in serialization. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub plan_node_name { |
|
167
|
6
|
|
|
6
|
1
|
19
|
return 'table'; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item C<< plan_prototype >> |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Returns a list of scalar identifiers for the type of the content (children) |
|
173
|
|
|
|
|
|
|
nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable |
|
174
|
|
|
|
|
|
|
identifiers. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub plan_prototype { |
|
179
|
6
|
|
|
6
|
1
|
16
|
my $self = shift; |
|
180
|
6
|
|
|
|
|
20
|
return qw(*V); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item C<< plan_node_data >> |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns the data for this plan node that corresponds to the values described by |
|
186
|
|
|
|
|
|
|
the signature returned by C<< plan_prototype >>. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub plan_node_data { |
|
191
|
9
|
|
|
9
|
1
|
18
|
my $self = shift; |
|
192
|
9
|
|
|
|
|
17
|
my $binds = $self->[1]; |
|
193
|
9
|
|
|
|
|
28
|
return @$binds; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=back |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 AUTHOR |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |