| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# RDF::Query::Expression |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Expression - Class for Expr expressions |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Expression version 2.918. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Expression; |
|
15
|
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
158
|
use strict; |
|
|
36
|
|
|
|
|
54
|
|
|
|
36
|
|
|
|
|
882
|
|
|
17
|
36
|
|
|
36
|
|
123
|
use warnings; |
|
|
36
|
|
|
|
|
48
|
|
|
|
36
|
|
|
|
|
827
|
|
|
18
|
36
|
|
|
36
|
|
131
|
no warnings 'redefine'; |
|
|
36
|
|
|
|
|
56
|
|
|
|
36
|
|
|
|
|
952
|
|
|
19
|
36
|
|
|
36
|
|
159
|
use base qw(RDF::Query::Algebra); |
|
|
36
|
|
|
|
|
45
|
|
|
|
36
|
|
|
|
|
14530
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
196
|
use Data::Dumper; |
|
|
36
|
|
|
|
|
49
|
|
|
|
36
|
|
|
|
|
1555
|
|
|
22
|
36
|
|
|
36
|
|
144
|
use Scalar::Util qw(blessed); |
|
|
36
|
|
|
|
|
41
|
|
|
|
36
|
|
|
|
|
1363
|
|
|
23
|
36
|
|
|
36
|
|
133
|
use Carp qw(carp croak confess); |
|
|
36
|
|
|
|
|
42
|
|
|
|
36
|
|
|
|
|
2019
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
###################################################################### |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our ($VERSION); |
|
28
|
|
|
|
|
|
|
BEGIN { |
|
29
|
36
|
|
|
36
|
|
16080
|
$VERSION = '2.918'; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
###################################################################### |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=over 4 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item C<new ( $op, @operands )> |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns a new Expr structure. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
|
47
|
308
|
|
|
308
|
1
|
785
|
my $class = shift; |
|
48
|
308
|
|
|
|
|
359
|
my $op = shift; |
|
49
|
308
|
|
|
|
|
430
|
my @operands = @_; |
|
50
|
308
|
|
|
|
|
1097
|
return bless( [ $op, @operands ], $class ); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item C<< construct_args >> |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns a list of arguments that, passed to this class' constructor, |
|
56
|
|
|
|
|
|
|
will produce a clone of this algebra pattern. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub construct_args { |
|
61
|
256
|
|
|
256
|
1
|
244
|
my $self = shift; |
|
62
|
256
|
|
|
|
|
411
|
return ($self->op, $self->operands); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<< op >> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the operator of the expression. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub op { |
|
72
|
1037
|
|
|
1037
|
1
|
830
|
my $self = shift; |
|
73
|
1037
|
|
|
|
|
2311
|
return $self->[0]; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C<< operands >> |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns a list of the operands of the expression. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub operands { |
|
83
|
1391
|
|
|
1391
|
1
|
1120
|
my $self = shift; |
|
84
|
1391
|
|
|
|
|
1263
|
return @{ $self }[ 1 .. $#{ $self } ]; |
|
|
1391
|
|
|
|
|
3074
|
|
|
|
1391
|
|
|
|
|
1579
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C<< sse >> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns the SSE string for this algebra expression. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub sse { |
|
94
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
95
|
0
|
|
|
|
|
0
|
my $context = shift; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return sprintf( |
|
98
|
|
|
|
|
|
|
'(%s %s)', |
|
99
|
|
|
|
|
|
|
$self->op, |
|
100
|
0
|
|
|
|
|
0
|
join(' ', map { $_->sse( $context ) } $self->operands), |
|
|
0
|
|
|
|
|
0
|
|
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item C<< explain >> |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a string serialization of the expression appropriate for display on the |
|
107
|
|
|
|
|
|
|
command line. This method is primarily used by the C<< explain >> method of |
|
108
|
|
|
|
|
|
|
the subclasses of RDF::Query::Plan. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub explain { |
|
113
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
114
|
0
|
|
|
|
|
0
|
my $s = shift; |
|
115
|
0
|
|
|
|
|
0
|
my $count = shift; |
|
116
|
0
|
|
|
|
|
0
|
my $indent = $s x $count; |
|
117
|
0
|
|
|
|
|
0
|
my $type = $self->op; |
|
118
|
0
|
|
|
|
|
0
|
my $string = "${indent}${type}\n"; |
|
119
|
0
|
|
|
|
|
0
|
foreach my $p ($self->operands) { |
|
120
|
0
|
0
|
|
|
|
0
|
if ($p->can('explain')) { |
|
121
|
0
|
|
|
|
|
0
|
$string .= $p->explain( $s, $count+1 ); |
|
122
|
|
|
|
|
|
|
} else { |
|
123
|
0
|
|
|
|
|
0
|
$string .= $p->sse; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
0
|
|
|
|
|
0
|
return $string; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item C<< as_hash >> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns the expression as a nested set of plain data structures (no objects). |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub as_hash { |
|
136
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
137
|
0
|
|
|
|
|
0
|
my $context = shift; |
|
138
|
|
|
|
|
|
|
return { |
|
139
|
|
|
|
|
|
|
type => 'expression', |
|
140
|
|
|
|
|
|
|
operator => $self->op, |
|
141
|
0
|
|
|
|
|
0
|
operands => [map { $_->as_hash($context) } $self->operands], |
|
|
0
|
|
|
|
|
0
|
|
|
142
|
|
|
|
|
|
|
}; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item C<< type >> |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns the type of this algebra expression. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub type { |
|
152
|
0
|
|
|
0
|
1
|
0
|
return 'EXPR'; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item C<< referenced_variables >> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub referenced_variables { |
|
162
|
26
|
|
|
26
|
1
|
28
|
my $self = shift; |
|
163
|
26
|
|
|
|
|
38
|
my @ops = $self->operands; |
|
164
|
26
|
|
|
|
|
26
|
my @vars; |
|
165
|
26
|
|
|
|
|
38
|
foreach my $o (@ops) { |
|
166
|
40
|
100
|
|
|
|
166
|
if ($o->isa('RDF::Query::Node::Variable')) { |
|
|
|
100
|
|
|
|
|
|
|
167
|
20
|
|
|
|
|
41
|
push(@vars, $o->name); |
|
168
|
|
|
|
|
|
|
} elsif ($o->isa('RDF::Query::Expression')) { |
|
169
|
8
|
|
|
|
|
23
|
push(@vars, $o->referenced_variables); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
26
|
|
|
|
|
65
|
return RDF::Query::_uniq(@vars); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item C<< nonaggregated_referenced_variables >> |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression except |
|
178
|
|
|
|
|
|
|
those used as aliases for aggregate operations. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub nonaggregated_referenced_variables { |
|
183
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
184
|
0
|
|
|
|
|
|
my @ops = $self->operands; |
|
185
|
0
|
|
|
|
|
|
my @vars; |
|
186
|
0
|
|
|
|
|
|
foreach my $o (@ops) { |
|
187
|
0
|
0
|
|
|
|
|
if ($o->isa('RDF::Query::Node::Variable::ExpressionProxy')) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
} elsif ($o->isa('RDF::Query::Node::Variable')) { |
|
189
|
0
|
|
|
|
|
|
push(@vars, $o->name); |
|
190
|
|
|
|
|
|
|
} elsif ($o->isa('RDF::Query::Expression')) { |
|
191
|
0
|
|
|
|
|
|
push(@vars, $o->nonaggregated_referenced_variables); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
} |
|
194
|
0
|
|
|
|
|
|
return RDF::Query::_uniq(@vars); |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
__END__ |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 AUTHOR |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |