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.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::Constant; |
22
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
136
|
use strict; |
|
35
|
|
|
|
|
51
|
|
|
35
|
|
|
|
|
856
|
|
24
|
35
|
|
|
35
|
|
120
|
use warnings; |
|
35
|
|
|
|
|
47
|
|
|
35
|
|
|
|
|
769
|
|
25
|
35
|
|
|
35
|
|
120
|
use base qw(RDF::Query::Plan); |
|
35
|
|
|
|
|
59
|
|
|
35
|
|
|
|
|
2520
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
###################################################################### |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our ($VERSION); |
30
|
|
|
|
|
|
|
BEGIN { |
31
|
35
|
|
|
35
|
|
15536
|
$VERSION = '2.918'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
###################################################################### |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item C<< new ( @variable_bindings ) >> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
41
|
21
|
|
|
21
|
1
|
37
|
my $class = shift; |
42
|
21
|
|
|
|
|
46
|
my @binds = @_; |
43
|
21
|
|
|
|
|
128
|
my $self = $class->SUPER::new( \@binds ); |
44
|
21
|
|
|
|
|
38
|
$self->[0]{referenced_variables} = [ keys %{ $binds[0] } ]; |
|
21
|
|
|
|
|
188
|
|
45
|
21
|
|
|
|
|
57
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C<< execute ( $execution_context ) >> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub execute ($) { |
53
|
35
|
|
|
35
|
1
|
50
|
my $self = shift; |
54
|
35
|
|
|
|
|
44
|
my $context = shift; |
55
|
35
|
|
|
|
|
103
|
$self->[0]{delegate} = $context->delegate; |
56
|
35
|
50
|
|
|
|
101
|
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
|
|
|
|
|
75
|
$self->[0]{'index'} = 0; |
61
|
35
|
|
|
|
|
99
|
$self->state( $self->OPEN ); |
62
|
35
|
|
|
|
|
114
|
$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
|
149
|
my $self = shift; |
97
|
69
|
50
|
|
|
|
147
|
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
|
|
|
|
|
89
|
my $binds = $self->[1]; |
101
|
69
|
100
|
|
|
|
74
|
if ($self->[0]{'index'} > $#{ $binds }) { |
|
69
|
|
|
|
|
161
|
|
102
|
30
|
|
|
|
|
87
|
return; |
103
|
|
|
|
|
|
|
} |
104
|
39
|
|
|
|
|
76
|
my $row = $binds->[ $self->[0]{'index'}++ ]; |
105
|
39
|
50
|
|
|
|
157
|
if ($row) { |
106
|
39
|
|
|
|
|
102
|
my $bindings = RDF::Query::VariableBindings->new( $row ); |
107
|
39
|
50
|
|
|
|
129
|
if (my $d = $self->delegate) { |
108
|
0
|
|
|
|
|
0
|
$d->log_result( $self, $bindings ); |
109
|
|
|
|
|
|
|
} |
110
|
39
|
|
|
|
|
123
|
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
|
39
|
my $self = shift; |
122
|
31
|
50
|
|
|
|
72
|
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
|
|
|
|
|
52
|
delete $self->[0]{'index'}; |
126
|
31
|
|
|
|
|
98
|
$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
|
44
|
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
|
80
|
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
|
13
|
my $self = shift; |
180
|
6
|
|
|
|
|
21
|
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
|
15
|
my $self = shift; |
192
|
9
|
|
|
|
|
18
|
my $binds = $self->[1]; |
193
|
9
|
|
|
|
|
25
|
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 |