| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# RDF::Query::Algebra::Construct |
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Algebra::Construct - Algebra class for construct query results |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Algebra::Construct version 2.916. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Algebra::Construct; |
|
15
|
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
184
|
use strict; |
|
|
36
|
|
|
|
|
71
|
|
|
|
36
|
|
|
|
|
1011
|
|
|
17
|
36
|
|
|
36
|
|
180
|
use warnings; |
|
|
36
|
|
|
|
|
64
|
|
|
|
36
|
|
|
|
|
966
|
|
|
18
|
36
|
|
|
36
|
|
237
|
no warnings 'redefine'; |
|
|
36
|
|
|
|
|
71
|
|
|
|
36
|
|
|
|
|
1175
|
|
|
19
|
36
|
|
|
36
|
|
187
|
use base qw(RDF::Query::Algebra); |
|
|
36
|
|
|
|
|
86
|
|
|
|
36
|
|
|
|
|
2889
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
204
|
use Data::Dumper; |
|
|
36
|
|
|
|
|
74
|
|
|
|
36
|
|
|
|
|
1730
|
|
|
22
|
36
|
|
|
36
|
|
194
|
use Set::Scalar; |
|
|
36
|
|
|
|
|
143
|
|
|
|
36
|
|
|
|
|
1443
|
|
|
23
|
36
|
|
|
36
|
|
254
|
use Scalar::Util qw(blessed); |
|
|
36
|
|
|
|
|
105
|
|
|
|
36
|
|
|
|
|
1772
|
|
|
24
|
36
|
|
|
36
|
|
181
|
use Carp qw(carp croak confess); |
|
|
36
|
|
|
|
|
66
|
|
|
|
36
|
|
|
|
|
2045
|
|
|
25
|
36
|
|
|
36
|
|
198
|
use RDF::Trine::Iterator qw(sgrep); |
|
|
36
|
|
|
|
|
68
|
|
|
|
36
|
|
|
|
|
2385
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
###################################################################### |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our ($VERSION); |
|
30
|
|
|
|
|
|
|
BEGIN { |
|
31
|
36
|
|
|
36
|
|
25886
|
$VERSION = '2.916'; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
###################################################################### |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
|
39
|
|
|
|
|
|
|
L<RDF::Query::Algebra> class. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item C<< new ( $query_pattern, \@construct_triples ) >> |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns a new Sort structure. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
|
52
|
6
|
|
|
6
|
1
|
12
|
my $class = shift; |
|
53
|
6
|
|
|
|
|
10
|
my $pattern = shift; |
|
54
|
6
|
|
|
|
|
12
|
my $triples = shift; |
|
55
|
6
|
|
|
|
|
26
|
return bless( [ $pattern, $triples ], $class ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item C<< construct_args >> |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns a list of arguments that, passed to this class' constructor, |
|
61
|
|
|
|
|
|
|
will produce a clone of this algebra pattern. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub construct_args { |
|
66
|
4
|
|
|
4
|
1
|
10
|
my $self = shift; |
|
67
|
4
|
|
|
|
|
16
|
my $pattern = $self->pattern; |
|
68
|
4
|
|
|
|
|
12
|
my $triples = $self->triples; |
|
69
|
4
|
|
|
|
|
16
|
return ($pattern, $triples); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C<< pattern >> |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns the pattern used to produce the variable bindings used in graph construction. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub pattern { |
|
79
|
16
|
|
|
16
|
1
|
28
|
my $self = shift; |
|
80
|
16
|
50
|
|
|
|
46
|
if (@_) { |
|
81
|
0
|
|
|
|
|
0
|
$self->[0] = shift; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
16
|
|
|
|
|
114
|
return $self->[0]; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C<< triples >> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns an ARRAY ref of triples to be used in graph construction. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub triples { |
|
93
|
14
|
|
|
14
|
1
|
22
|
my $self = shift; |
|
94
|
14
|
50
|
|
|
|
36
|
if (@_) { |
|
95
|
0
|
|
|
|
|
0
|
$self->[1] = shift; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
14
|
|
|
|
|
45
|
return $self->[1]; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C<< sse >> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the SSE string for this algebra expression. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub sse { |
|
107
|
4
|
|
|
4
|
1
|
12
|
my $self = shift; |
|
108
|
4
|
|
|
|
|
10
|
my $context = shift; |
|
109
|
4
|
|
50
|
|
|
22
|
my $prefix = shift || ''; |
|
110
|
4
|
|
50
|
|
|
17
|
my $indent = $context->{indent} || ' '; |
|
111
|
4
|
|
|
|
|
14
|
my $triples = join("\n${prefix}${indent}${indent}", map { $_->sse( $context, "${prefix}${indent}${indent}" ) } @{$self->triples}); |
|
|
7
|
|
|
|
|
1128
|
|
|
|
4
|
|
|
|
|
13
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
4
|
|
|
|
|
1010
|
return sprintf( |
|
114
|
|
|
|
|
|
|
"(construct\n${prefix}${indent}(\n${prefix}${indent}${indent}%s\n${prefix}${indent})\n${prefix}${indent}%s)", |
|
115
|
|
|
|
|
|
|
$triples, |
|
116
|
|
|
|
|
|
|
$self->pattern->sse( $context, "${prefix}${indent}" ), |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item C<< as_sparql >> |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the SPARQL string for this algebra expression. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub as_sparql { |
|
127
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
|
128
|
2
|
|
50
|
|
|
6
|
my $context = shift || {}; |
|
129
|
2
|
|
|
|
|
4
|
my $indent = shift; |
|
130
|
2
|
|
|
|
|
8
|
my $triples = $self->triples; |
|
131
|
2
|
|
|
|
|
9
|
my $bgp = RDF::Query::Algebra::BasicGraphPattern->new( @$triples ); |
|
132
|
2
|
|
|
|
|
8
|
my $ggp = RDF::Query::Algebra::GroupGraphPattern->new( $bgp ); |
|
133
|
2
|
|
50
|
|
|
11
|
my $force = $context->{ force_ggp_braces } || 0; |
|
134
|
|
|
|
|
|
|
|
|
135
|
2
|
|
|
|
|
4
|
my ($template, $pattern); |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
2
|
|
|
|
|
4
|
$context->{ force_ggp_braces } = $force + 1; |
|
138
|
2
|
|
|
|
|
10
|
$template = $ggp->as_sparql( $context, $indent ); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
2
|
|
|
|
|
3
|
$context->{ force_ggp_braces } = $force + 1; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
4
|
|
|
142
|
2
|
|
|
|
|
7
|
$pattern = $self->pattern->as_sparql( $context, $indent ); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
2
|
|
|
|
|
9
|
my $string = sprintf( |
|
146
|
|
|
|
|
|
|
"CONSTRUCT %s\n${indent}WHERE %s", |
|
147
|
|
|
|
|
|
|
$template, |
|
148
|
|
|
|
|
|
|
$pattern, |
|
149
|
|
|
|
|
|
|
); |
|
150
|
2
|
|
|
|
|
10
|
return $string; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item C<< as_hash >> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns the query as a nested set of plain data structures (no objects). |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub as_hash { |
|
160
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
161
|
0
|
|
|
|
|
0
|
my $context = shift; |
|
162
|
0
|
|
|
|
|
0
|
my $bgp = RDF::Query::Algebra::BasicGraphPattern->new( @{ $self->triples } ); |
|
|
0
|
|
|
|
|
0
|
|
|
163
|
|
|
|
|
|
|
return { |
|
164
|
0
|
|
|
|
|
0
|
type => lc($self->type), |
|
165
|
|
|
|
|
|
|
pattern => $self->pattern->as_hash, |
|
166
|
|
|
|
|
|
|
construct => $bgp->as_hash, |
|
167
|
|
|
|
|
|
|
}; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item C<< type >> |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Returns the type of this algebra expression. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub type { |
|
177
|
0
|
|
|
0
|
1
|
0
|
return 'CONSTRUCT'; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item C<< referenced_variables >> |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub referenced_variables { |
|
187
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
|
188
|
2
|
|
|
|
|
9
|
return RDF::Query::_uniq($self->pattern->referenced_variables); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item C<< potentially_bound >> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression that will |
|
194
|
|
|
|
|
|
|
bind values during execution. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub potentially_bound { |
|
199
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
200
|
0
|
|
|
|
|
|
return $self->pattern->potentially_bound; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item C<< definite_variables >> |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns a list of the variable names that will be bound after evaluating this algebra expression. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub definite_variables { |
|
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
211
|
0
|
|
|
|
|
|
return $self->pattern->definite_variables; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
1; |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
__END__ |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=back |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |