line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
50
|
|
|
50
|
|
664
|
use v5.14; |
|
50
|
|
|
|
|
168
|
|
2
|
50
|
|
|
50
|
|
261
|
use warnings; |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
7400
|
|
3
|
50
|
|
|
50
|
|
342
|
use utf8; |
|
50
|
|
|
|
|
99
|
|
|
50
|
|
|
|
|
445
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Attean::Plan - Representation of SPARQL query plan operators |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This document describes Attean::Plan version 0.032 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use v5.14; |
16
|
|
|
|
|
|
|
use Attean; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is a utility package that defines all the Attean query plan classes |
21
|
|
|
|
|
|
|
in the Attean::Plan namespace: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over 4 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
50
|
|
|
50
|
|
1351
|
use Attean::API::Query; |
|
50
|
|
|
|
|
103
|
|
|
50
|
|
|
|
|
1737
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item * L<Attean::Plan::Quad> |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Evaluates a quad pattern against the model. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Moo; |
36
|
50
|
|
|
50
|
|
253
|
use Scalar::Util qw(blessed reftype); |
|
50
|
|
|
|
|
100
|
|
|
50
|
|
|
|
|
566
|
|
37
|
50
|
|
|
50
|
|
16387
|
use Types::Standard qw(ConsumerOf ArrayRef); |
|
50
|
|
|
|
|
114
|
|
|
50
|
|
|
|
|
3193
|
|
38
|
50
|
|
|
50
|
|
309
|
use namespace::clean; |
|
50
|
|
|
|
|
97
|
|
|
50
|
|
|
|
|
436
|
|
39
|
50
|
|
|
50
|
|
30279
|
|
|
50
|
|
|
|
|
143
|
|
|
50
|
|
|
|
|
499
|
|
40
|
|
|
|
|
|
|
has 'subject' => (is => 'ro', required => 1); |
41
|
|
|
|
|
|
|
has 'predicate' => (is => 'ro', required => 1); |
42
|
|
|
|
|
|
|
has 'object' => (is => 'ro', required => 1); |
43
|
|
|
|
|
|
|
has 'graph' => (is => 'ro', required => 1); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::NullaryQueryTree'; |
46
|
|
|
|
|
|
|
with 'Attean::API::QuadPattern'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
around 'BUILDARGS' => sub { |
49
|
|
|
|
|
|
|
my $orig = shift; |
50
|
|
|
|
|
|
|
my $class = shift; |
51
|
|
|
|
|
|
|
my $args = $orig->( $class, @_ ); |
52
|
|
|
|
|
|
|
if (exists $args->{in_scope_variables}) { |
53
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my %vars; |
57
|
|
|
|
|
|
|
foreach my $pos (qw(subject predicate object graph)) { |
58
|
|
|
|
|
|
|
my $term = $args->{$pos}; |
59
|
|
|
|
|
|
|
if (blessed($term) and $term->does('Attean::API::Variable')) { |
60
|
|
|
|
|
|
|
$vars{$term->value} = $term; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @vars = keys %vars; |
65
|
|
|
|
|
|
|
$args->{in_scope_variables} = [@vars]; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return $args; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
my @nodes = $self->values; |
72
|
10
|
|
|
10
|
0
|
21
|
my @strings; |
73
|
10
|
|
|
|
|
39
|
foreach my $t (@nodes) { |
74
|
10
|
|
|
|
|
20
|
if (ref($t) eq 'ARRAY') { |
75
|
10
|
|
|
|
|
22
|
my @tstrings = map { $_->ntriples_string } @$t; |
76
|
40
|
100
|
|
|
|
590
|
if (scalar(@tstrings) == 1) { |
|
|
50
|
|
|
|
|
|
77
|
7
|
|
|
|
|
18
|
push(@strings, @tstrings); |
|
7
|
|
|
|
|
163
|
|
78
|
7
|
50
|
|
|
|
73
|
} else { |
79
|
7
|
|
|
|
|
29
|
push(@strings, '[' . join(', ', @tstrings) . ']'); |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
0
|
} elsif ($t->does('Attean::API::TermOrVariable')) { |
82
|
|
|
|
|
|
|
push(@strings, $t->ntriples_string); |
83
|
|
|
|
|
|
|
} else { |
84
|
33
|
|
|
|
|
896
|
use Data::Dumper; |
85
|
|
|
|
|
|
|
die "Unrecognized node in quad pattern: " . Dumper($t); |
86
|
50
|
|
|
50
|
|
32777
|
} |
|
50
|
|
|
|
|
107
|
|
|
50
|
|
|
|
|
19317
|
|
87
|
0
|
|
|
|
|
0
|
} |
88
|
|
|
|
|
|
|
return sprintf('Quad { %s }', join(', ', @strings)); |
89
|
|
|
|
|
|
|
} |
90
|
10
|
|
|
|
|
98
|
|
91
|
|
|
|
|
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
my $model = shift; |
93
|
|
|
|
|
|
|
my $b = shift; |
94
|
0
|
|
|
0
|
0
|
0
|
my @values = $self->values; |
95
|
0
|
|
|
|
|
0
|
foreach my $i (0 .. $#values) { |
96
|
0
|
|
|
|
|
0
|
my $value = $values[$i]; |
97
|
0
|
|
|
|
|
0
|
if (reftype($value) eq 'ARRAY') { |
98
|
0
|
|
|
|
|
0
|
my @values; |
99
|
0
|
|
|
|
|
0
|
foreach my $value (@{ $value }) { |
100
|
0
|
0
|
|
|
|
0
|
my $name = $value->value; |
|
|
0
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
if (my $node = $b->value($name)) { |
102
|
0
|
|
|
|
|
0
|
push(@values, $node); |
|
0
|
|
|
|
|
0
|
|
103
|
0
|
|
|
|
|
0
|
} else { |
104
|
0
|
0
|
|
|
|
0
|
push(@values, $value); |
105
|
0
|
|
|
|
|
0
|
} |
106
|
|
|
|
|
|
|
$values[$i] = \@values; |
107
|
0
|
|
|
|
|
0
|
} |
108
|
|
|
|
|
|
|
} elsif ($value->does('Attean::API::Variable')) { |
109
|
0
|
|
|
|
|
0
|
my $name = $value->value; |
110
|
|
|
|
|
|
|
if (my $node = $b->value($name)) { |
111
|
|
|
|
|
|
|
$values[$i] = $node; |
112
|
0
|
|
|
|
|
0
|
} |
113
|
0
|
0
|
|
|
|
0
|
} |
114
|
0
|
|
|
|
|
0
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
return sub { |
117
|
|
|
|
|
|
|
return $model->get_bindings( @values ); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
0
|
|
|
0
|
|
0
|
|
121
|
|
|
|
|
|
|
my $self = shift; |
122
|
0
|
|
|
|
|
0
|
my $model = shift; |
123
|
|
|
|
|
|
|
my @values = $self->values; |
124
|
|
|
|
|
|
|
return sub { |
125
|
11
|
|
|
11
|
0
|
43
|
return $model->get_bindings( @values ); |
126
|
11
|
|
|
|
|
23
|
} |
127
|
11
|
|
|
|
|
43
|
} |
128
|
|
|
|
|
|
|
} |
129
|
11
|
|
|
11
|
|
66
|
|
130
|
|
|
|
|
|
|
=item * L<Attean::Plan::NestedLoopJoin> |
131
|
11
|
|
|
|
|
69
|
|
132
|
|
|
|
|
|
|
Evaluates a join (natural-, anti-, or left-) using a nested loop. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
use Moo; |
137
|
|
|
|
|
|
|
use List::MoreUtils qw(all); |
138
|
|
|
|
|
|
|
use namespace::clean; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan'; |
141
|
50
|
|
|
50
|
|
18988
|
with 'Attean::API::Plan::Join'; |
|
50
|
|
|
|
|
104
|
|
|
50
|
|
|
|
|
226
|
|
142
|
50
|
|
|
50
|
|
17023
|
my $self = shift; |
|
50
|
|
|
|
|
136
|
|
|
50
|
|
|
|
|
505
|
|
143
|
50
|
|
|
50
|
|
46675
|
if ($self->left) { |
|
50
|
|
|
|
|
135
|
|
|
50
|
|
|
|
|
242
|
|
144
|
|
|
|
|
|
|
return 'NestedLoop Left Join'; |
145
|
|
|
|
|
|
|
} elsif ($self->anti) { |
146
|
|
|
|
|
|
|
return 'NestedLoop Anti Join'; |
147
|
|
|
|
|
|
|
} else { |
148
|
1
|
|
|
1
|
0
|
2
|
return 'NestedLoop Join'; |
149
|
1
|
50
|
|
|
|
10
|
} |
|
|
50
|
|
|
|
|
|
150
|
0
|
|
|
|
|
0
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
0
|
my $self = shift; |
153
|
|
|
|
|
|
|
my $model = shift; |
154
|
1
|
|
|
|
|
4
|
my @children = map { $_->impl($model) } @{ $self->children }; |
155
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my $self = shift; |
159
|
4
|
|
|
4
|
0
|
9
|
my $model = shift; |
160
|
4
|
|
|
|
|
9
|
my $b = shift; |
161
|
4
|
|
|
|
|
9
|
unless (all { $_->does('Attean::API::BindingSubstitutionPlan') } @{ $self->children }) { |
|
8
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
13
|
|
162
|
4
|
|
|
|
|
24
|
die "Plan children do not all consume BindingSubstitutionPlan role:\n" . $self->as_string; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my @children = map { $_->substitute_impl($model, $b) } @{ $self->children }; |
166
|
0
|
|
|
0
|
0
|
0
|
return $self->_impl($model, @children); |
167
|
0
|
|
|
|
|
0
|
} |
168
|
0
|
|
|
|
|
0
|
|
169
|
0
|
0
|
|
0
|
|
0
|
my $self = shift; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
170
|
0
|
|
|
|
|
0
|
my $model = shift; |
171
|
|
|
|
|
|
|
my @children = @_; |
172
|
|
|
|
|
|
|
my $left = $self->left; |
173
|
0
|
|
|
|
|
0
|
my $anti = $self->anti; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
174
|
0
|
|
|
|
|
0
|
my $iter_variables = $self->in_scope_variables; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
return sub { |
177
|
|
|
|
|
|
|
my ($lhs, $rhs) = map { $_->() } @children; |
178
|
4
|
|
|
4
|
|
10
|
my @right = $rhs->elements; |
179
|
4
|
|
|
|
|
12
|
my @results; |
180
|
4
|
|
|
|
|
10
|
while (my $l = $lhs->next) { |
181
|
4
|
|
|
|
|
17
|
my $seen = 0; |
182
|
4
|
|
|
|
|
17
|
foreach my $r (@right) { |
183
|
4
|
|
|
|
|
12
|
my @shared = $l->shared_domain($r); |
184
|
|
|
|
|
|
|
if ($anti and scalar(@shared) == 0) { |
185
|
|
|
|
|
|
|
# in a MINUS, two results that have disjoint domains are considered not to be joinable |
186
|
4
|
|
|
4
|
|
11
|
next; |
|
8
|
|
|
|
|
163
|
|
187
|
4
|
|
|
|
|
190
|
} |
188
|
4
|
|
|
|
|
10
|
if (my $j = $l->join($r)) { |
189
|
4
|
|
|
|
|
14
|
$seen++; |
190
|
2
|
|
|
|
|
6
|
if ($left) { |
191
|
2
|
|
|
|
|
7
|
# TODO: filter with expression |
192
|
2
|
|
|
|
|
12
|
push(@results, $j); |
193
|
2
|
50
|
33
|
|
|
24
|
} elsif ($anti) { |
194
|
|
|
|
|
|
|
} else { |
195
|
0
|
|
|
|
|
0
|
push(@results, $j); |
196
|
|
|
|
|
|
|
} |
197
|
2
|
50
|
|
|
|
13
|
} |
198
|
2
|
|
|
|
|
5
|
} |
199
|
2
|
50
|
|
|
|
22
|
if ($left and not($seen)) { |
|
|
50
|
|
|
|
|
|
200
|
|
|
|
|
|
|
push(@results, $l); |
201
|
0
|
|
|
|
|
0
|
} elsif ($anti and not($seen)) { |
202
|
|
|
|
|
|
|
push(@results, $l); |
203
|
|
|
|
|
|
|
} |
204
|
2
|
|
|
|
|
13
|
} |
205
|
|
|
|
|
|
|
return Attean::ListIterator->new( |
206
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
207
|
|
|
|
|
|
|
variables => $iter_variables, |
208
|
2
|
50
|
33
|
|
|
40
|
values => \@results, |
|
|
50
|
33
|
|
|
|
|
209
|
0
|
|
|
|
|
0
|
); |
210
|
|
|
|
|
|
|
} |
211
|
0
|
|
|
|
|
0
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
4
|
|
|
|
|
101
|
=item * L<Attean::Plan::HashJoin> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Evaluates a join (natural-, anti-, or left-) using a hash join. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
4
|
|
|
|
|
29
|
use Moo; |
221
|
|
|
|
|
|
|
use List::MoreUtils qw(all); |
222
|
|
|
|
|
|
|
use namespace::clean; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $self = shift; |
225
|
|
|
|
|
|
|
if ($self->anti) { |
226
|
|
|
|
|
|
|
die "Cannot use a HashJoin for anti-joins"; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
50
|
|
|
50
|
|
50607
|
with 'Attean::API::BindingSubstitutionPlan'; |
|
50
|
|
|
|
|
129
|
|
|
50
|
|
|
|
|
217
|
|
231
|
50
|
|
|
50
|
|
16095
|
with 'Attean::API::Plan::Join'; |
|
50
|
|
|
|
|
124
|
|
|
50
|
|
|
|
|
280
|
|
232
|
50
|
|
|
50
|
|
28021
|
my $self = shift; |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
225
|
|
233
|
|
|
|
|
|
|
my $name; |
234
|
|
|
|
|
|
|
if ($self->left) { |
235
|
622
|
|
|
622
|
0
|
89884
|
$name = "Hash Left Join"; |
236
|
622
|
50
|
|
|
|
3273
|
} else { |
237
|
0
|
|
|
|
|
0
|
$name = "Hash Join"; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
return sprintf('%s { %s }', $name, join(', ', @{$self->join_variables})); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
my $self = shift; |
243
|
|
|
|
|
|
|
my $model = shift; |
244
|
1
|
|
|
1
|
0
|
2
|
my @children = map { $_->impl($model) } @{ $self->children }; |
245
|
1
|
|
|
|
|
2
|
return $self->_impl($model, @children); |
246
|
1
|
50
|
|
|
|
5
|
} |
247
|
0
|
|
|
|
|
0
|
|
248
|
|
|
|
|
|
|
my $self = shift; |
249
|
1
|
|
|
|
|
3
|
my $model = shift; |
250
|
|
|
|
|
|
|
my $b = shift; |
251
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
252
|
|
|
|
|
|
|
unless (all { $_->does('Attean::API::BindingSubstitutionPlan') } @{ $self->children }) { |
253
|
|
|
|
|
|
|
die "Plan children do not all consume BindingSubstitutionPlan role:\n" . $self->as_string; |
254
|
|
|
|
|
|
|
} |
255
|
0
|
|
|
0
|
0
|
0
|
|
256
|
0
|
|
|
|
|
0
|
my @children = map { $_->substitute_impl($model, $b) } @{ $self->children }; |
257
|
0
|
|
|
|
|
0
|
return $self->_impl($model, @children); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
258
|
0
|
|
|
|
|
0
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
my $self = shift; |
261
|
|
|
|
|
|
|
my $model = shift; |
262
|
0
|
|
|
0
|
0
|
0
|
my @children = @_; |
263
|
0
|
|
|
|
|
0
|
my $left = $self->left; |
264
|
0
|
|
|
|
|
0
|
my $iter_variables = $self->in_scope_variables; |
265
|
|
|
|
|
|
|
|
266
|
0
|
0
|
|
0
|
|
0
|
return sub { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
267
|
0
|
|
|
|
|
0
|
my %hash; |
268
|
|
|
|
|
|
|
my @vars = @{ $self->join_variables }; |
269
|
|
|
|
|
|
|
my $rhs = $children[1]->(); |
270
|
0
|
|
|
|
|
0
|
while (my $r = $rhs->next()) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
271
|
0
|
|
|
|
|
0
|
my $has_unbound_right_join_var = 0; |
272
|
|
|
|
|
|
|
my @values; |
273
|
|
|
|
|
|
|
foreach my $var (@vars) { |
274
|
|
|
|
|
|
|
my $value = $r->value($var); |
275
|
0
|
|
|
0
|
|
0
|
unless (defined($value)) { |
276
|
0
|
|
|
|
|
0
|
$has_unbound_right_join_var++; |
277
|
0
|
|
|
|
|
0
|
} |
278
|
0
|
|
|
|
|
0
|
push(@values, $value); |
279
|
0
|
|
|
|
|
0
|
} |
280
|
|
|
|
|
|
|
if ($has_unbound_right_join_var) { |
281
|
|
|
|
|
|
|
# this is a RHS row that doesn't have a term bound to one of the join variables. |
282
|
0
|
|
|
0
|
|
0
|
# this will make it impossible to compute the proper hash key to access the row bucket, |
283
|
0
|
|
|
|
|
0
|
# so we add this row to the null bucket (hash key '') which we try to join all LHS rows |
|
0
|
|
|
|
|
0
|
|
284
|
0
|
|
|
|
|
0
|
# against. |
285
|
0
|
|
|
|
|
0
|
push(@{ $hash{''} }, $r); |
286
|
0
|
|
|
|
|
0
|
} else { |
287
|
0
|
|
|
|
|
0
|
my $key = join(',', map { ref($_) ? $_->as_string : '' } @values); |
288
|
0
|
|
|
|
|
0
|
push(@{ $hash{$key} }, $r); |
289
|
0
|
|
|
|
|
0
|
} |
290
|
0
|
0
|
|
|
|
0
|
} |
291
|
0
|
|
|
|
|
0
|
|
292
|
|
|
|
|
|
|
my @results; |
293
|
0
|
|
|
|
|
0
|
my $lhs = $children[0]->(); |
294
|
|
|
|
|
|
|
while (my $l = $lhs->next()) { |
295
|
0
|
0
|
|
|
|
0
|
my $seen = 0; |
296
|
|
|
|
|
|
|
my @values; |
297
|
|
|
|
|
|
|
my $has_unbound_left_join_var = 0; |
298
|
|
|
|
|
|
|
foreach my $var (@vars) { |
299
|
|
|
|
|
|
|
my $value = $l->value($var); |
300
|
0
|
|
|
|
|
0
|
unless (defined($value)) { |
|
0
|
|
|
|
|
0
|
|
301
|
|
|
|
|
|
|
$has_unbound_left_join_var++; |
302
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
303
|
0
|
|
|
|
|
0
|
push(@values, $value); |
|
0
|
|
|
|
|
0
|
|
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
my @buckets; |
307
|
0
|
|
|
|
|
0
|
if (my $b = $hash{''}) { |
308
|
0
|
|
|
|
|
0
|
push(@buckets, $b); |
309
|
0
|
|
|
|
|
0
|
} |
310
|
0
|
|
|
|
|
0
|
|
311
|
0
|
|
|
|
|
0
|
if ($has_unbound_left_join_var) { |
312
|
0
|
|
|
|
|
0
|
my $pattern = join(',', map { ref($_) ? quotemeta($_->as_string) : '.*' } @values); |
313
|
0
|
|
|
|
|
0
|
foreach my $key (keys %hash) { |
314
|
0
|
|
|
|
|
0
|
if ($key =~ /^${pattern}$/) { |
315
|
0
|
0
|
|
|
|
0
|
push(@buckets, $hash{$key}); |
316
|
0
|
|
|
|
|
0
|
} |
317
|
|
|
|
|
|
|
} |
318
|
0
|
|
|
|
|
0
|
} else { |
319
|
|
|
|
|
|
|
my $key = join(',', map { ref($_) ? $_->as_string : '' } @values); |
320
|
|
|
|
|
|
|
if (my $rows = $hash{$key}) { |
321
|
0
|
|
|
|
|
0
|
push(@buckets, $rows); |
322
|
0
|
0
|
|
|
|
0
|
} |
323
|
0
|
|
|
|
|
0
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
foreach my $rows (@buckets) { |
326
|
0
|
0
|
|
|
|
0
|
foreach my $r (@$rows) { |
327
|
0
|
0
|
|
|
|
0
|
if (my $j = $l->join($r)) { |
|
0
|
|
|
|
|
0
|
|
328
|
0
|
|
|
|
|
0
|
$seen++; |
329
|
0
|
0
|
|
|
|
0
|
if ($left) { |
330
|
0
|
|
|
|
|
0
|
# TODO: filter with expression |
331
|
|
|
|
|
|
|
push(@results, $j); |
332
|
|
|
|
|
|
|
} else { |
333
|
|
|
|
|
|
|
push(@results, $j); |
334
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
335
|
0
|
0
|
|
|
|
0
|
} |
336
|
0
|
|
|
|
|
0
|
} |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
if ($left and not($seen)) { |
339
|
|
|
|
|
|
|
push(@results, $l); |
340
|
0
|
|
|
|
|
0
|
} |
341
|
0
|
|
|
|
|
0
|
} |
342
|
0
|
0
|
|
|
|
0
|
return Attean::ListIterator->new( |
343
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Result', |
344
|
0
|
0
|
|
|
|
0
|
variables => $iter_variables, |
345
|
|
|
|
|
|
|
values => \@results |
346
|
0
|
|
|
|
|
0
|
); |
347
|
|
|
|
|
|
|
} |
348
|
0
|
|
|
|
|
0
|
} |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=item * L<Attean::Plan::Construct> |
352
|
|
|
|
|
|
|
|
353
|
0
|
0
|
0
|
|
|
0
|
=cut |
354
|
0
|
|
|
|
|
0
|
|
355
|
|
|
|
|
|
|
use Moo; |
356
|
|
|
|
|
|
|
use List::MoreUtils qw(all); |
357
|
0
|
|
|
|
|
0
|
use Types::Standard qw(Str ArrayRef ConsumerOf InstanceOf); |
358
|
|
|
|
|
|
|
use namespace::clean; |
359
|
|
|
|
|
|
|
has 'triples' => (is => 'ro', 'isa' => ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']], required => 1); |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree'; |
362
|
|
|
|
|
|
|
|
363
|
0
|
|
|
|
|
0
|
my $self = shift; |
364
|
|
|
|
|
|
|
my $triples = $self->triples; |
365
|
|
|
|
|
|
|
return sprintf('Construct { %s }', join(' . ', map { $_->as_string } @$triples)); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
# TODO: this code is repeated in several plan classes; figure out a way to share it. |
369
|
|
|
|
|
|
|
my $class = shift; |
370
|
|
|
|
|
|
|
my %args = @_; |
371
|
50
|
|
|
50
|
|
67798
|
my %vars = map { $_ => 1 } map { @{ $_->in_scope_variables } } @{ $args{ children } }; |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
225
|
|
372
|
50
|
|
|
50
|
|
15209
|
my @vars = keys %vars; |
|
50
|
|
|
|
|
134
|
|
|
50
|
|
|
|
|
290
|
|
373
|
50
|
|
|
50
|
|
38384
|
|
|
50
|
|
|
|
|
113
|
|
|
50
|
|
|
|
|
255
|
|
374
|
50
|
|
|
50
|
|
37708
|
if (exists $args{in_scope_variables}) { |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
249
|
|
375
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
376
|
|
|
|
|
|
|
} |
377
|
|
|
|
|
|
|
$args{in_scope_variables} = \@vars; |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
return $class->SUPER::BUILDARGS(%args); |
380
|
3
|
|
|
3
|
0
|
6
|
} |
381
|
3
|
|
|
|
|
7
|
|
382
|
3
|
|
|
|
|
7
|
my $self = shift; |
|
3
|
|
|
|
|
10
|
|
383
|
|
|
|
|
|
|
my $model = shift; |
384
|
|
|
|
|
|
|
my @children = map { $_->impl($model) } @{ $self->children }; |
385
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
386
|
|
|
|
|
|
|
} |
387
|
1
|
|
|
1
|
0
|
4623
|
|
388
|
1
|
|
|
|
|
9
|
my $self = shift; |
389
|
1
|
|
|
|
|
3
|
my $model = shift; |
|
2
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
390
|
1
|
|
|
|
|
4
|
my $b = shift; |
391
|
|
|
|
|
|
|
unless (all { $_->does('Attean::API::BindingSubstitutionPlan') } @{ $self->children }) { |
392
|
1
|
50
|
|
|
|
5
|
die "Plan children do not all consume BindingSubstitutionPlan role:\n" . $self->as_string; |
393
|
0
|
|
|
|
|
0
|
} |
394
|
|
|
|
|
|
|
|
395
|
1
|
|
|
|
|
3
|
warn "TODO: fix substitute_impl to substitute construct triples"; |
396
|
|
|
|
|
|
|
my @children = map { $_->substitute_impl($model, $b) } @{ $self->children }; |
397
|
1
|
|
|
|
|
9
|
return $self->_impl($model, @children); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
my $self = shift; |
401
|
0
|
|
|
0
|
0
|
0
|
my $model = shift; |
402
|
0
|
|
|
|
|
0
|
my $child = shift; |
403
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
404
|
0
|
|
|
|
|
0
|
my @triples = @{ $self->triples }; |
405
|
|
|
|
|
|
|
return sub { |
406
|
|
|
|
|
|
|
my $iter = $child->(); |
407
|
|
|
|
|
|
|
my @buffer; |
408
|
0
|
|
|
0
|
0
|
0
|
my %seen; |
409
|
0
|
|
|
|
|
0
|
return Attean::CodeIterator->new( |
410
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Triple', |
411
|
0
|
0
|
|
0
|
|
0
|
generator => sub { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
412
|
0
|
|
|
|
|
0
|
if (scalar(@buffer)) { |
413
|
|
|
|
|
|
|
return shift(@buffer); |
414
|
|
|
|
|
|
|
} |
415
|
0
|
|
|
|
|
0
|
while (my $row = $iter->next) { |
416
|
0
|
|
|
|
|
0
|
foreach my $tp (@triples) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
417
|
0
|
|
|
|
|
0
|
my $tp = $tp->apply_bindings($row); |
418
|
|
|
|
|
|
|
my $t = eval { $tp->as_triple }; |
419
|
|
|
|
|
|
|
if ($t) { |
420
|
|
|
|
|
|
|
push(@buffer, $t); |
421
|
0
|
|
|
0
|
|
0
|
} |
422
|
0
|
|
|
|
|
0
|
} |
423
|
0
|
|
|
|
|
0
|
if (scalar(@buffer)) { |
424
|
|
|
|
|
|
|
my $t = shift(@buffer); |
425
|
0
|
|
|
|
|
0
|
return $t; |
|
0
|
|
|
|
|
0
|
|
426
|
|
|
|
|
|
|
} |
427
|
0
|
|
|
0
|
|
0
|
} |
428
|
0
|
|
|
|
|
0
|
} |
429
|
|
|
|
|
|
|
)->grep(sub { |
430
|
|
|
|
|
|
|
return not $seen{$_->as_string}++; |
431
|
|
|
|
|
|
|
}); |
432
|
|
|
|
|
|
|
} |
433
|
0
|
0
|
|
|
|
0
|
} |
434
|
0
|
|
|
|
|
0
|
} |
435
|
|
|
|
|
|
|
|
436
|
0
|
|
|
|
|
0
|
=item * L<Attean::Plan::Describe> |
437
|
0
|
|
|
|
|
0
|
|
438
|
0
|
|
|
|
|
0
|
=cut |
439
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
440
|
0
|
0
|
|
|
|
0
|
use Moo; |
441
|
0
|
|
|
|
|
0
|
use Attean::RDF; |
442
|
|
|
|
|
|
|
use List::MoreUtils qw(all); |
443
|
|
|
|
|
|
|
use Types::Standard qw(Str ArrayRef ConsumerOf InstanceOf); |
444
|
0
|
0
|
|
|
|
0
|
use namespace::clean; |
445
|
0
|
|
|
|
|
0
|
|
446
|
0
|
|
|
|
|
0
|
has 'graph' => (is => 'ro'); |
447
|
|
|
|
|
|
|
has 'terms' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TermOrVariable']]); |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree'; |
450
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
451
|
0
|
|
|
|
|
0
|
|
452
|
0
|
|
|
|
|
0
|
my $self = shift; |
453
|
|
|
|
|
|
|
my $terms = $self->terms; |
454
|
0
|
|
|
|
|
0
|
return sprintf('Describe { %s }', join(' . ', map { $_->as_string } @$terms)); |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
my $self = shift; |
458
|
|
|
|
|
|
|
my $model = shift; |
459
|
|
|
|
|
|
|
my @children = map { $_->impl($model) } @{ $self->children }; |
460
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
461
|
|
|
|
|
|
|
} |
462
|
50
|
|
|
50
|
|
64054
|
|
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
254
|
|
463
|
50
|
|
|
50
|
|
16081
|
my $self = shift; |
|
50
|
|
|
|
|
135
|
|
|
50
|
|
|
|
|
497
|
|
464
|
50
|
|
|
50
|
|
40003
|
my $model = shift; |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
220
|
|
465
|
50
|
|
|
50
|
|
44266
|
my $b = shift; |
|
50
|
|
|
|
|
117
|
|
|
50
|
|
|
|
|
237
|
|
466
|
50
|
|
|
50
|
|
36648
|
unless (all { $_->does('Attean::API::BindingSubstitutionPlan') } @{ $self->children }) { |
|
50
|
|
|
|
|
118
|
|
|
50
|
|
|
|
|
259
|
|
467
|
|
|
|
|
|
|
die "Plan children do not all consume BindingSubstitutionPlan role:\n" . $self->as_string; |
468
|
|
|
|
|
|
|
} |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
warn "TODO: fix substitute_impl to substitute describe terms"; |
471
|
|
|
|
|
|
|
my @children = map { $_->substitute_impl($model, $b) } @{ $self->children }; |
472
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
476
|
1
|
|
|
|
|
4
|
my $model = shift; |
477
|
1
|
|
|
|
|
4
|
my $child = shift; |
|
1
|
|
|
|
|
5
|
|
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
my $graph = $self->graph; |
480
|
|
|
|
|
|
|
my @terms = @{ $self->terms }; |
481
|
1
|
|
|
1
|
0
|
3
|
# TODO: Split @terms into ground terms and variables. |
482
|
1
|
|
|
|
|
2
|
# Only call get_quads once for ground terms. |
483
|
1
|
|
|
|
|
3
|
# For variable terms, call get_quads for each variable-result combination. |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
6
|
|
484
|
1
|
|
|
|
|
5
|
return sub { |
485
|
|
|
|
|
|
|
my $iter = $child->(); |
486
|
|
|
|
|
|
|
my @buffer; |
487
|
|
|
|
|
|
|
my %seen; |
488
|
0
|
|
|
0
|
0
|
0
|
return Attean::CodeIterator->new( |
489
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Triple', |
490
|
0
|
|
|
|
|
0
|
generator => sub { |
491
|
0
|
0
|
|
0
|
|
0
|
if (scalar(@buffer)) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
492
|
0
|
|
|
|
|
0
|
return shift(@buffer); |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
while (my $row = $iter->next) { |
495
|
0
|
|
|
|
|
0
|
foreach my $term (@terms) { |
496
|
0
|
|
|
|
|
0
|
my $value = $term->apply_binding($row); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
497
|
0
|
|
|
|
|
0
|
if ($value->does('Attean::API::Term')) { |
498
|
|
|
|
|
|
|
my $iter = $model->get_quads( $value, variable('predicate'), variable('object'), $graph ); |
499
|
|
|
|
|
|
|
push(@buffer, $iter->elements); |
500
|
|
|
|
|
|
|
} |
501
|
1
|
|
|
1
|
|
2
|
if (scalar(@buffer)) { |
502
|
1
|
|
|
|
|
3
|
return shift(@buffer); |
503
|
1
|
|
|
|
|
1
|
} |
504
|
|
|
|
|
|
|
} |
505
|
1
|
|
|
|
|
3
|
} |
506
|
1
|
|
|
|
|
2
|
} |
|
1
|
|
|
|
|
4
|
|
507
|
|
|
|
|
|
|
)->grep(sub { |
508
|
|
|
|
|
|
|
return not $seen{$_->as_string}++; |
509
|
|
|
|
|
|
|
}); |
510
|
|
|
|
|
|
|
} |
511
|
1
|
|
|
1
|
|
5
|
} |
512
|
1
|
|
|
|
|
61
|
} |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=item * L<Attean::Plan::EBVFilter> |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
Filters results from a sub-plan based on the effective boolean value of a |
517
|
1
|
50
|
|
|
|
4
|
named variable binding. |
518
|
0
|
|
|
|
|
0
|
|
519
|
|
|
|
|
|
|
=cut |
520
|
1
|
|
|
|
|
7
|
|
521
|
1
|
|
|
|
|
3
|
use Moo; |
522
|
1
|
|
|
|
|
5
|
use Scalar::Util qw(blessed); |
523
|
1
|
50
|
|
|
|
3
|
use Types::Standard qw(Str ConsumerOf); |
524
|
1
|
|
|
|
|
26
|
use namespace::clean; |
525
|
1
|
|
|
|
|
12
|
|
526
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree'; |
527
|
1
|
50
|
|
|
|
20
|
with 'Attean::API::UnionScopeVariablesPlan'; |
528
|
1
|
|
|
|
|
9
|
|
529
|
|
|
|
|
|
|
has 'variable' => (is => 'ro', isa => Str, required => 1); |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
my $self = shift; |
532
|
|
|
|
|
|
|
return sprintf('EBVFilter { ?%s }', $self->variable); |
533
|
|
|
|
|
|
|
} |
534
|
1
|
|
|
|
|
6
|
|
535
|
1
|
|
|
|
|
26
|
my $self = shift; |
536
|
|
|
|
|
|
|
my $model = shift; |
537
|
1
|
|
|
|
|
6
|
my $bind = shift; |
538
|
|
|
|
|
|
|
my ($impl) = map { $_->substitute_impl($model, $bind) } @{ $self->children }; |
539
|
|
|
|
|
|
|
my $var = $self->variable; |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
return sub { |
542
|
|
|
|
|
|
|
my $iter = $impl->(); |
543
|
|
|
|
|
|
|
return $iter->grep(sub { |
544
|
|
|
|
|
|
|
my $r = shift; |
545
|
|
|
|
|
|
|
my $term = $r->value($var); |
546
|
|
|
|
|
|
|
return 0 unless (blessed($term) and $term->does('Attean::API::Term')); |
547
|
|
|
|
|
|
|
return $term->ebv; |
548
|
50
|
|
|
50
|
|
77246
|
}); |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
269
|
|
549
|
50
|
|
|
50
|
|
17760
|
}; |
|
50
|
|
|
|
|
151
|
|
|
50
|
|
|
|
|
2678
|
|
550
|
50
|
|
|
50
|
|
366
|
} |
|
50
|
|
|
|
|
153
|
|
|
50
|
|
|
|
|
331
|
|
551
|
50
|
|
|
50
|
|
26788
|
|
|
50
|
|
|
|
|
114
|
|
|
50
|
|
|
|
|
258
|
|
552
|
|
|
|
|
|
|
my $self = shift; |
553
|
|
|
|
|
|
|
my $model = shift; |
554
|
|
|
|
|
|
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
555
|
|
|
|
|
|
|
my $var = $self->variable; |
556
|
|
|
|
|
|
|
return sub { |
557
|
|
|
|
|
|
|
my $iter = $impl->(); |
558
|
|
|
|
|
|
|
return $iter->grep(sub { |
559
|
1
|
|
|
1
|
0
|
3
|
my $r = shift; |
560
|
1
|
|
|
|
|
11
|
my $term = $r->value($var); |
561
|
|
|
|
|
|
|
return 0 unless (blessed($term) and $term->does('Attean::API::Term')); |
562
|
0
|
|
|
0
|
0
|
0
|
return $term->ebv; |
563
|
|
|
|
|
|
|
}); |
564
|
|
|
|
|
|
|
}; |
565
|
0
|
|
|
0
|
0
|
0
|
} |
566
|
0
|
|
|
|
|
0
|
} |
567
|
0
|
|
|
|
|
0
|
|
568
|
0
|
|
|
|
|
0
|
=item * L<Attean::Plan::Merge> |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
569
|
0
|
|
|
|
|
0
|
|
570
|
|
|
|
|
|
|
Evaluates a set of sub-plans, returning the merged union of results, preserving |
571
|
|
|
|
|
|
|
ordering. |
572
|
0
|
|
|
0
|
|
0
|
|
573
|
|
|
|
|
|
|
=cut |
574
|
0
|
|
|
|
|
0
|
|
575
|
0
|
|
|
|
|
0
|
use Moo; |
576
|
0
|
0
|
0
|
|
|
0
|
use Scalar::Util qw(blessed); |
577
|
0
|
|
|
|
|
0
|
use Types::Standard qw(Str ArrayRef ConsumerOf); |
578
|
0
|
|
|
|
|
0
|
use namespace::clean; |
579
|
0
|
|
|
|
|
0
|
|
580
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::BinaryQueryTree'; |
581
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
582
|
|
|
|
|
|
|
|
583
|
0
|
|
|
0
|
0
|
0
|
has 'variables' => (is => 'ro', isa => ArrayRef[Str], required => 1); |
584
|
0
|
|
|
|
|
0
|
|
585
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
586
|
0
|
|
|
|
|
0
|
my $self = shift; |
587
|
|
|
|
|
|
|
my $model = shift; |
588
|
0
|
|
|
0
|
|
0
|
my @children = map { $_->impl($model) } @{ $self->children }; |
589
|
|
|
|
|
|
|
return sub { |
590
|
0
|
|
|
|
|
0
|
die "Unimplemented"; |
591
|
0
|
|
|
|
|
0
|
}; |
592
|
0
|
0
|
0
|
|
|
0
|
} |
593
|
0
|
|
|
|
|
0
|
} |
594
|
0
|
|
|
|
|
0
|
|
595
|
0
|
|
|
|
|
0
|
=item * L<Attean::Plan::Union> |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
Evaluates a set of sub-plans, returning the union of results. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=cut |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
use Moo; |
602
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
603
|
|
|
|
|
|
|
use namespace::clean; |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::BinaryQueryTree'; |
606
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
607
|
50
|
|
|
50
|
|
47000
|
|
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
220
|
|
608
|
50
|
|
|
50
|
|
15642
|
|
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
2434
|
|
609
|
50
|
|
|
50
|
|
366
|
my $self = shift; |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
357
|
|
610
|
50
|
|
|
50
|
|
30938
|
my $model = shift; |
|
50
|
|
|
|
|
115
|
|
|
50
|
|
|
|
|
243
|
|
611
|
|
|
|
|
|
|
my @children = map { $_->impl($model) } @{ $self->children }; |
612
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
my $self = shift; |
616
|
|
|
|
|
|
|
my $model = shift; |
617
|
0
|
|
|
0
|
0
|
0
|
my $b = shift; |
618
|
|
|
|
|
|
|
unless (all { $_->does('Attean::API::BindingSubstitutionPlan') } @{ $self->children }) { |
619
|
|
|
|
|
|
|
die "Plan children do not all consume BindingSubstitutionPlan role:\n" . $self->as_string; |
620
|
0
|
|
|
0
|
0
|
0
|
} |
621
|
0
|
|
|
|
|
0
|
|
622
|
0
|
|
|
|
|
0
|
my @children = map { $_->substitute_impl($model, $b) } @{ $self->children }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
623
|
|
|
|
|
|
|
return $self->_impl($model, @children); |
624
|
0
|
|
|
0
|
|
0
|
} |
625
|
0
|
|
|
|
|
0
|
|
626
|
|
|
|
|
|
|
my $self = shift; |
627
|
|
|
|
|
|
|
my $model = shift; |
628
|
|
|
|
|
|
|
my @children = @_; |
629
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
return sub { |
632
|
|
|
|
|
|
|
if (my $current = shift(@children)) { |
633
|
|
|
|
|
|
|
my $iter = $current->(); |
634
|
|
|
|
|
|
|
return Attean::CodeIterator->new( |
635
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
636
|
50
|
|
|
50
|
|
36163
|
variables => $iter_variables, |
|
50
|
|
|
|
|
139
|
|
|
50
|
|
|
|
|
236
|
|
637
|
50
|
|
|
50
|
|
16882
|
generator => sub { |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
2400
|
|
638
|
50
|
|
|
50
|
|
332
|
while (blessed($iter)) { |
|
50
|
|
|
|
|
138
|
|
|
50
|
|
|
|
|
272
|
|
639
|
|
|
|
|
|
|
my $row = $iter->next(); |
640
|
|
|
|
|
|
|
if ($row) { |
641
|
|
|
|
|
|
|
return $row; |
642
|
|
|
|
|
|
|
} else { |
643
|
1
|
|
|
1
|
0
|
4
|
$current = shift(@children); |
644
|
|
|
|
|
|
|
if ($current) { |
645
|
|
|
|
|
|
|
$iter = $current->(); |
646
|
0
|
|
|
0
|
0
|
0
|
} else { |
647
|
0
|
|
|
|
|
0
|
undef $iter; |
648
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
649
|
0
|
|
|
|
|
0
|
} |
650
|
|
|
|
|
|
|
} |
651
|
|
|
|
|
|
|
}, |
652
|
|
|
|
|
|
|
); |
653
|
0
|
|
|
0
|
0
|
0
|
} else { |
654
|
0
|
|
|
|
|
0
|
return Attean::ListIterator->new( item_type => 'Attean::API::Result', variables => [], values => [], ); |
655
|
0
|
|
|
|
|
0
|
} |
656
|
0
|
0
|
|
|
|
0
|
}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
657
|
0
|
|
|
|
|
0
|
} |
658
|
|
|
|
|
|
|
} |
659
|
|
|
|
|
|
|
|
660
|
0
|
|
|
|
|
0
|
=item * L<Attean::Plan::Extend> |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
661
|
0
|
|
|
|
|
0
|
|
662
|
|
|
|
|
|
|
Evaluates a sub-plan, and extends each result by evaluating a set of |
663
|
|
|
|
|
|
|
expressions, binding the produced values to new variables. |
664
|
|
|
|
|
|
|
|
665
|
0
|
|
|
0
|
|
0
|
=cut |
666
|
0
|
|
|
|
|
0
|
|
667
|
0
|
|
|
|
|
0
|
use Moo; |
668
|
0
|
|
|
|
|
0
|
use Encode; |
669
|
|
|
|
|
|
|
use UUID::Tiny ':std'; |
670
|
|
|
|
|
|
|
use URI::Escape; |
671
|
0
|
0
|
|
0
|
|
0
|
use Data::Dumper; |
672
|
0
|
|
|
|
|
0
|
use I18N::LangTags; |
673
|
|
|
|
|
|
|
use POSIX qw(ceil floor); |
674
|
|
|
|
|
|
|
use Digest::SHA; |
675
|
|
|
|
|
|
|
use Digest::MD5 qw(md5_hex); |
676
|
|
|
|
|
|
|
use Scalar::Util qw(blessed looks_like_number); |
677
|
0
|
|
|
|
|
0
|
use List::MoreUtils qw(uniq all); |
678
|
0
|
|
|
|
|
0
|
use Types::Standard qw(ConsumerOf InstanceOf HashRef); |
679
|
0
|
0
|
|
|
|
0
|
use namespace::clean; |
680
|
0
|
|
|
|
|
0
|
|
681
|
|
|
|
|
|
|
with 'MooX::Log::Any'; |
682
|
0
|
|
|
|
|
0
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree'; |
683
|
0
|
0
|
|
|
|
0
|
has 'expressions' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Expression']], required => 1); |
684
|
0
|
|
|
|
|
0
|
|
685
|
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
0
|
my $self = shift; |
687
|
|
|
|
|
|
|
my @strings = map { sprintf('?%s ← %s', $_, $self->expressions->{$_}->as_string) } keys %{ $self->expressions }; |
688
|
|
|
|
|
|
|
return sprintf('Extend { %s }', join(', ', @strings)); |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
|
691
|
0
|
|
|
|
|
0
|
my $class = shift; |
692
|
|
|
|
|
|
|
my %args = @_; |
693
|
0
|
|
|
|
|
0
|
my $exprs = $args{ expressions }; |
694
|
|
|
|
|
|
|
my @vars = map { @{ $_->in_scope_variables } } @{ $args{ children } }; |
695
|
0
|
|
|
|
|
0
|
my @evars = (@vars, keys %$exprs); |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
if (exists $args{in_scope_variables}) { |
698
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
$args{in_scope_variables} = [@evars]; |
701
|
|
|
|
|
|
|
return $class->SUPER::BUILDARGS(%args); |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
my $self = shift; |
705
|
|
|
|
|
|
|
my $model = shift; |
706
|
|
|
|
|
|
|
my $expr = shift; |
707
|
50
|
|
|
50
|
|
47017
|
my $r = shift; |
|
50
|
|
|
|
|
132
|
|
|
50
|
|
|
|
|
211
|
|
708
|
50
|
|
|
50
|
|
14931
|
Carp::confess unless ($expr->can('operator')); |
|
50
|
|
|
|
|
147
|
|
|
50
|
|
|
|
|
4316
|
|
709
|
50
|
|
|
50
|
|
341
|
my $op = $expr->operator; |
|
50
|
|
|
|
|
134
|
|
|
50
|
|
|
|
|
11316
|
|
710
|
50
|
|
|
50
|
|
391
|
|
|
50
|
|
|
|
|
104
|
|
|
50
|
|
|
|
|
2710
|
|
711
|
50
|
|
|
50
|
|
323
|
state $true = Attean::Literal->true; |
|
50
|
|
|
|
|
96
|
|
|
50
|
|
|
|
|
1939
|
|
712
|
50
|
|
|
50
|
|
29676
|
state $false = Attean::Literal->false; |
|
50
|
|
|
|
|
127613
|
|
|
50
|
|
|
|
|
2476
|
|
713
|
50
|
|
|
50
|
|
410
|
state $type_roles = { qw(URI IRI IRI IRI BLANK Blank LITERAL Literal NUMERIC NumericLiteral TRIPLE Triple) }; |
|
50
|
|
|
|
|
112
|
|
|
50
|
|
|
|
|
482
|
|
714
|
50
|
|
|
50
|
|
4030
|
state $type_classes = { qw(URI Attean::IRI IRI Attean::IRI STR Attean::Literal) }; |
|
50
|
|
|
|
|
149
|
|
|
50
|
|
|
|
|
1758
|
|
715
|
50
|
|
|
50
|
|
270
|
|
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
1674
|
|
716
|
50
|
|
|
50
|
|
293
|
if ($expr->isa('Attean::CastExpression')) { |
|
50
|
|
|
|
|
117
|
|
|
50
|
|
|
|
|
2098
|
|
717
|
50
|
|
|
50
|
|
300
|
my $datatype = $expr->datatype->value; |
|
50
|
|
|
|
|
102
|
|
|
50
|
|
|
|
|
428
|
|
718
|
50
|
|
|
50
|
|
49761
|
my ($child) = @{ $expr->children }; |
|
50
|
|
|
|
|
120
|
|
|
50
|
|
|
|
|
336
|
|
719
|
50
|
|
|
50
|
|
32319
|
my $term = $self->evaluate_expression($model, $child, $r); |
|
50
|
|
|
|
|
131
|
|
|
50
|
|
|
|
|
382
|
|
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
if ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#string$>) { |
722
|
|
|
|
|
|
|
my $value = $term->value; |
723
|
|
|
|
|
|
|
if ($term->does('Attean::API::IRI')) { |
724
|
|
|
|
|
|
|
return Attean::Literal->new(value => $term->value); |
725
|
|
|
|
|
|
|
} elsif ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') { |
726
|
|
|
|
|
|
|
my $v = ($value eq 'true' or $value eq '1') ? 'true' : 'false'; |
727
|
0
|
|
|
0
|
0
|
0
|
return Attean::Literal->new(value => $v); |
728
|
0
|
|
|
|
|
0
|
} elsif ($term->does('Attean::API::NumericLiteral')) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
729
|
0
|
|
|
|
|
0
|
my $v = $term->numeric_value(); |
730
|
|
|
|
|
|
|
if ($v == int($v)) { |
731
|
0
|
|
|
0
|
0
|
0
|
return Attean::Literal->new(value => int($v)); |
732
|
|
|
|
|
|
|
} |
733
|
|
|
|
|
|
|
} |
734
|
10
|
|
|
10
|
0
|
12921
|
|
735
|
10
|
|
|
|
|
35
|
return Attean::Literal->new(value => $value); |
736
|
10
|
|
|
|
|
24
|
} |
737
|
10
|
|
|
|
|
615
|
|
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
47
|
|
|
10
|
|
|
|
|
25
|
|
738
|
10
|
|
|
|
|
33
|
die "TypeError $op" unless (blessed($term) and $term->does('Attean::API::Literal')); |
739
|
|
|
|
|
|
|
if ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#(integer|float|double|decimal)>) { |
740
|
10
|
50
|
|
|
|
30
|
my $value = $term->value; |
741
|
0
|
|
|
|
|
0
|
my $num; |
742
|
|
|
|
|
|
|
if ($datatype eq 'http://www.w3.org/2001/XMLSchema#integer') { |
743
|
10
|
|
|
|
|
23
|
if ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') { |
744
|
10
|
|
|
|
|
57
|
$value = ($value eq 'true' or $value eq '1') ? '1' : '0'; |
745
|
|
|
|
|
|
|
} elsif ($term->does('Attean::API::NumericLiteral')) { |
746
|
|
|
|
|
|
|
my $v = $term->numeric_value(); |
747
|
|
|
|
|
|
|
$v =~ s/[.].*$//; |
748
|
0
|
|
|
0
|
0
|
0
|
$value = int($v); |
749
|
0
|
|
|
|
|
0
|
} elsif ($value =~ /^[-+]\d+$/) { |
750
|
0
|
|
|
|
|
0
|
my ($v) = "$value"; |
751
|
0
|
|
|
|
|
0
|
$v =~ s/[.].*$//; |
752
|
0
|
0
|
|
|
|
0
|
$value = int($v); |
753
|
0
|
|
|
|
|
0
|
} |
754
|
|
|
|
|
|
|
$num = $value; |
755
|
0
|
|
|
|
|
0
|
} elsif ($datatype eq 'http://www.w3.org/2001/XMLSchema#decimal') { |
756
|
0
|
|
|
|
|
0
|
if ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') { |
757
|
0
|
|
|
|
|
0
|
$value = ($value eq 'true') ? '1' : '0'; |
758
|
0
|
|
|
|
|
0
|
} elsif ($term->does('Attean::API::NumericLiteral')) { |
759
|
|
|
|
|
|
|
$value = $term->numeric_value; |
760
|
0
|
0
|
|
|
|
0
|
} elsif (looks_like_number($value)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
761
|
0
|
|
|
|
|
0
|
if ($value =~ /[eE]/) { # double |
762
|
0
|
|
|
|
|
0
|
die "cannot cast to xsd:decimal as precision would be lost"; |
|
0
|
|
|
|
|
0
|
|
763
|
0
|
|
|
|
|
0
|
} |
764
|
|
|
|
|
|
|
$value = +$value; |
765
|
0
|
0
|
|
|
|
0
|
} |
766
|
0
|
|
|
|
|
0
|
$num = "$value"; |
767
|
0
|
0
|
|
|
|
0
|
$num =~ s/[.]0+$/.0/; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
768
|
0
|
|
|
|
|
0
|
$num =~ s/[.](\d+)0*$/.$1/; |
769
|
|
|
|
|
|
|
} elsif ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#(float|double)$>) { |
770
|
0
|
0
|
0
|
|
|
0
|
my $typename = $1; |
771
|
0
|
|
|
|
|
0
|
if ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') { |
772
|
|
|
|
|
|
|
$value = ($value eq 'true') ? '1.0' : '0.0'; |
773
|
0
|
|
|
|
|
0
|
} elsif ($term->does('Attean::API::NumericLiteral')) { |
774
|
0
|
0
|
|
|
|
0
|
# no-op |
775
|
0
|
|
|
|
|
0
|
} elsif (looks_like_number($value)) { |
776
|
|
|
|
|
|
|
$value = +$value; |
777
|
|
|
|
|
|
|
} else { |
778
|
|
|
|
|
|
|
die "cannot cast unrecognized value '$value' to xsd:$typename"; |
779
|
0
|
|
|
|
|
0
|
} |
780
|
|
|
|
|
|
|
$num = sprintf("%e", $value); |
781
|
|
|
|
|
|
|
} |
782
|
0
|
0
|
0
|
|
|
0
|
my $c = Attean::Literal->new(value => $num, datatype => $expr->datatype); |
783
|
0
|
0
|
|
|
|
0
|
if (my $term = $c->canonicalized_term()) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
784
|
0
|
|
|
|
|
0
|
return $term; |
785
|
0
|
|
|
|
|
0
|
} else { |
786
|
0
|
0
|
|
|
|
0
|
die "Term value is not a valid lexical form for $datatype"; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
787
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
788
|
0
|
0
|
0
|
|
|
0
|
} elsif ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#boolean$>) { |
789
|
|
|
|
|
|
|
if ($term->does('Attean::API::NumericLiteral')) { |
790
|
0
|
|
|
|
|
0
|
my $value = $term->numeric_value; |
791
|
0
|
|
|
|
|
0
|
return ($value == 0) ? Attean::Literal->false : Attean::Literal->true; |
792
|
0
|
|
|
|
|
0
|
} else { |
793
|
|
|
|
|
|
|
my $value = $term->value; |
794
|
0
|
|
|
|
|
0
|
if ($value =~ m/^(true|false|0|1)$/) { |
795
|
0
|
|
|
|
|
0
|
return ($value eq 'true' or $value eq '1') ? Attean::Literal->true : Attean::Literal->false; |
796
|
0
|
|
|
|
|
0
|
} else { |
797
|
|
|
|
|
|
|
die "Bad lexical form for xsd:boolean: '$value'"; |
798
|
0
|
|
|
|
|
0
|
} |
799
|
|
|
|
|
|
|
} |
800
|
0
|
0
|
|
|
|
0
|
} elsif ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#dateTime$>) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
801
|
0
|
0
|
|
|
|
0
|
my $value = $term->value; |
802
|
|
|
|
|
|
|
my $c = Attean::Literal->new(value => $value, datatype => $expr->datatype); |
803
|
0
|
|
|
|
|
0
|
if ($c->does('Attean::API::DateTimeLiteral') and $c->datetime) { |
804
|
|
|
|
|
|
|
return $c; |
805
|
0
|
0
|
|
|
|
0
|
} else { |
806
|
0
|
|
|
|
|
0
|
die "Bad lexical form for xsd:dateTime: '$value'"; |
807
|
|
|
|
|
|
|
} |
808
|
0
|
|
|
|
|
0
|
} |
809
|
|
|
|
|
|
|
$self->log->warn("Cast expression unimplemented for $datatype: " . Dumper($expr)); |
810
|
0
|
|
|
|
|
0
|
} elsif ($expr->isa('Attean::ValueExpression')) { |
811
|
0
|
|
|
|
|
0
|
my $node = $expr->value; |
812
|
0
|
|
|
|
|
0
|
if ($node->does('Attean::API::Variable')) { |
813
|
|
|
|
|
|
|
return $r->value($node->value); |
814
|
0
|
|
|
|
|
0
|
} else { |
815
|
0
|
0
|
|
|
|
0
|
return $node; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
816
|
0
|
0
|
|
|
|
0
|
} |
817
|
|
|
|
|
|
|
} elsif ($expr->isa('Attean::UnaryExpression')) { |
818
|
|
|
|
|
|
|
my ($child) = @{ $expr->children }; |
819
|
|
|
|
|
|
|
my $term = $self->evaluate_expression($model, $child, $r); |
820
|
0
|
|
|
|
|
0
|
if ($op eq '!') { |
821
|
|
|
|
|
|
|
return ($term->ebv) ? $false : $true; |
822
|
0
|
|
|
|
|
0
|
} elsif ($op eq '-' or $op eq '+') { |
823
|
|
|
|
|
|
|
die "TypeError $op" unless (blessed($term) and $term->does('Attean::API::NumericLiteral')); |
824
|
0
|
|
|
|
|
0
|
my $v = $term->numeric_value; |
825
|
|
|
|
|
|
|
return Attean::Literal->new( value => eval "$op$v", datatype => $term->datatype ); |
826
|
0
|
|
|
|
|
0
|
} |
827
|
0
|
0
|
|
|
|
0
|
die "Unimplemented UnaryExpression evaluation: " . $expr->operator; |
828
|
0
|
|
|
|
|
0
|
} elsif ($expr->isa('Attean::BinaryExpression')) { |
829
|
|
|
|
|
|
|
my $op = $expr->operator; |
830
|
0
|
|
|
|
|
0
|
if ($op eq '&&') { |
831
|
|
|
|
|
|
|
foreach my $child (@{ $expr->children }) { |
832
|
|
|
|
|
|
|
my $term = $self->evaluate_expression($model, $child, $r); |
833
|
0
|
0
|
|
|
|
0
|
unless ($term->ebv) { |
834
|
0
|
|
|
|
|
0
|
return $false; |
835
|
0
|
0
|
|
|
|
0
|
} |
836
|
|
|
|
|
|
|
} |
837
|
0
|
|
|
|
|
0
|
return $true; |
838
|
0
|
0
|
|
|
|
0
|
} elsif ($op eq '||') { |
839
|
0
|
0
|
0
|
|
|
0
|
foreach my $child (@{ $expr->children }) { |
840
|
|
|
|
|
|
|
my $term = $self->evaluate_expression($model, $child, $r); |
841
|
0
|
|
|
|
|
0
|
if (blessed($term) and $term->ebv) { |
842
|
|
|
|
|
|
|
return $true; |
843
|
|
|
|
|
|
|
} |
844
|
|
|
|
|
|
|
} |
845
|
0
|
|
|
|
|
0
|
return $false; |
846
|
0
|
|
|
|
|
0
|
} elsif ($op eq '=') { |
847
|
0
|
0
|
0
|
|
|
0
|
my ($lhs, $rhs) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
848
|
0
|
|
|
|
|
0
|
return $lhs->equals($rhs) ? $true : $false; # TODO: this may not be using value-space comparision for numerics... |
849
|
|
|
|
|
|
|
} elsif ($op eq '!=') { |
850
|
0
|
|
|
|
|
0
|
my ($lhs, $rhs) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
851
|
|
|
|
|
|
|
return not($lhs->equals($rhs)) ? $true : $false; # TODO: this may not be using value-space comparision for numerics... |
852
|
|
|
|
|
|
|
} elsif ($op =~ m#[<>]=?#) { |
853
|
0
|
|
|
|
|
0
|
my ($lhs, $rhs) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
854
|
|
|
|
|
|
|
my $cmp = $lhs->compare($rhs); |
855
|
0
|
|
|
|
|
0
|
if ($cmp < 0) { |
856
|
0
|
0
|
|
|
|
0
|
return ($op =~ /^<=?/) ? $true : $false; |
857
|
0
|
|
|
|
|
0
|
} elsif ($cmp > 0) { |
858
|
|
|
|
|
|
|
return ($op =~ /^>=?/) ? $true : $false; |
859
|
0
|
|
|
|
|
0
|
} else { |
860
|
|
|
|
|
|
|
return ($op =~ /=/) ? $true : $false; |
861
|
|
|
|
|
|
|
} |
862
|
0
|
|
|
|
|
0
|
} elsif ($op =~ m<^[-+*/]$>) { |
|
0
|
|
|
|
|
0
|
|
863
|
0
|
|
|
|
|
0
|
my ($lhs, $rhs) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
864
|
0
|
0
|
0
|
|
|
0
|
die "TypeError $op" unless all { blessed($_) and $_->does('Attean::API::NumericLiteral') } ($lhs, $rhs); |
|
|
0
|
|
|
|
|
|
865
|
0
|
0
|
|
|
|
0
|
my ($lv, $rv) = map { $_->numeric_value } ($lhs, $rhs); |
866
|
|
|
|
|
|
|
my $type = $lhs->binary_promotion_type($rhs, $op); |
867
|
0
|
0
|
0
|
|
|
0
|
if ($op eq '+') { |
868
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => ($lv + $rv), datatype => $type); |
869
|
0
|
|
|
|
|
0
|
} elsif ($op eq '-') { |
870
|
|
|
|
|
|
|
return Attean::Literal->new(value => ($lv - $rv), datatype => $type); |
871
|
0
|
|
|
|
|
0
|
} elsif ($op eq '*') { |
872
|
|
|
|
|
|
|
return Attean::Literal->new(value => ($lv * $rv), datatype => $type); |
873
|
0
|
|
|
|
|
0
|
} elsif ($op eq '/') { |
874
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => ($lv / $rv), datatype => $type); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
875
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
876
|
0
|
|
|
|
|
0
|
} |
877
|
0
|
0
|
|
|
|
0
|
|
878
|
0
|
|
|
|
|
0
|
$self->log->warn("Binary operator $op expression evaluation unimplemented: " . Dumper($expr)); |
879
|
|
|
|
|
|
|
die "Expression evaluation unimplemented: " . $expr->as_string; |
880
|
|
|
|
|
|
|
} elsif ($expr->isa('Attean::FunctionExpression')) { |
881
|
0
|
|
|
|
|
0
|
my $func = $expr->operator; |
882
|
|
|
|
|
|
|
if ($func eq 'IF') { |
883
|
0
|
|
|
|
|
0
|
my ($check, @children) = @{ $expr->children }; |
|
0
|
|
|
|
|
0
|
|
884
|
0
|
|
|
|
|
0
|
my ($term) = $self->evaluate_expression($model, $check, $r); |
885
|
0
|
0
|
0
|
|
|
0
|
$self->log->warn($@) if ($@); |
886
|
0
|
|
|
|
|
0
|
my $expr = $children[ (blessed($term) and $term->ebv) ? 0 : 1 ]; |
887
|
|
|
|
|
|
|
my $value = $self->evaluate_expression($model, $expr, $r); |
888
|
|
|
|
|
|
|
# warn '############# ' . $value->as_string; |
889
|
0
|
|
|
|
|
0
|
return $value; |
890
|
|
|
|
|
|
|
} elsif ($func eq 'COALESCE') { |
891
|
0
|
|
|
|
|
0
|
# warn "COALESCE: . " . $r->as_string . "\n"; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
892
|
0
|
0
|
|
|
|
0
|
foreach my $child (@{ $expr->children }) { |
893
|
|
|
|
|
|
|
# warn '- ' . $child->as_string . "\n"; |
894
|
0
|
|
|
|
|
0
|
my $term = eval { $self->evaluate_expression($model, $child, $r) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
895
|
0
|
0
|
|
|
|
0
|
# warn $@ if $@; |
896
|
|
|
|
|
|
|
if (blessed($term)) { |
897
|
0
|
|
|
|
|
0
|
# warn ' returning ' . $term->as_string . "\n"; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
898
|
0
|
|
|
|
|
0
|
return $term; |
899
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
900
|
0
|
0
|
|
|
|
0
|
} |
901
|
|
|
|
|
|
|
# warn " no value\n"; |
902
|
0
|
0
|
|
|
|
0
|
return; |
903
|
|
|
|
|
|
|
} |
904
|
0
|
0
|
|
|
|
0
|
|
905
|
|
|
|
|
|
|
my @terms = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
906
|
|
|
|
|
|
|
if ($func =~ /^IS([UI]RI|BLANK|LITERAL|NUMERIC|TRIPLE)$/) { |
907
|
0
|
|
|
|
|
0
|
my $role = "Attean::API::$type_roles->{$1}"; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
908
|
0
|
0
|
|
0
|
|
0
|
my $t = shift(@terms); |
|
0
|
0
|
|
|
|
0
|
|
909
|
0
|
|
|
|
|
0
|
my $ok = (blessed($t) and $t->does($role)); |
|
0
|
|
|
|
|
0
|
|
910
|
0
|
|
|
|
|
0
|
return $ok ? $true : $false; |
911
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'REGEX') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
912
|
0
|
|
|
|
|
0
|
my ($string, $pattern, $flags) = @terms; |
913
|
|
|
|
|
|
|
# my ($string, $pattern, $flags) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
914
|
0
|
|
|
|
|
0
|
# TODO: ensure that $string is a literal |
915
|
|
|
|
|
|
|
($string, $pattern, $flags) = map { blessed($_) ? $_->value : '' } ($string, $pattern, $flags); |
916
|
0
|
|
|
|
|
0
|
my $re; |
917
|
|
|
|
|
|
|
if ($flags =~ /i/) { |
918
|
0
|
|
|
|
|
0
|
$re = qr/$pattern/i; |
919
|
|
|
|
|
|
|
} else { |
920
|
|
|
|
|
|
|
$re = qr/$pattern/; |
921
|
|
|
|
|
|
|
} |
922
|
0
|
|
|
|
|
0
|
return ($string =~ $re) ? $true : $false; |
923
|
0
|
|
|
|
|
0
|
} elsif ($func =~ /^(NOT)?IN$/) { |
924
|
|
|
|
|
|
|
my $ok = ($func eq 'IN') ? $true : $false; |
925
|
0
|
|
|
|
|
0
|
my $notok = ($func eq 'IN') ? $false : $true; |
926
|
0
|
0
|
|
|
|
0
|
# my @children = @{ $expr->children }; |
|
|
0
|
|
|
|
|
|
927
|
0
|
|
|
|
|
0
|
my ($term, @children) = @terms; |
|
0
|
|
|
|
|
0
|
|
928
|
0
|
|
|
|
|
0
|
# my ($term) = $self->evaluate_expression($model, shift(@children), $r); |
929
|
0
|
0
|
|
|
|
0
|
# foreach my $child (@{ $expr->children }) { |
930
|
0
|
0
|
0
|
|
|
0
|
foreach my $value (@children) { |
931
|
0
|
|
|
|
|
0
|
# my $value = $self->evaluate_expression($model, $child, $r); |
932
|
|
|
|
|
|
|
if ($term->equals($value)) { |
933
|
0
|
|
|
|
|
0
|
return $ok; |
934
|
|
|
|
|
|
|
} |
935
|
|
|
|
|
|
|
} |
936
|
0
|
|
|
|
|
0
|
return $notok; |
|
0
|
|
|
|
|
0
|
|
937
|
|
|
|
|
|
|
} elsif ($func eq 'NOW') { |
938
|
0
|
|
|
|
|
0
|
my $dt = DateTime->now; |
|
0
|
|
|
|
|
0
|
|
939
|
|
|
|
|
|
|
my $value = DateTime::Format::W3CDTF->new->format_datetime( $dt ); |
940
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => $value, datatype => 'http://www.w3.org/2001/XMLSchema#dateTime'); |
941
|
|
|
|
|
|
|
} elsif ($func eq 'STR') { |
942
|
0
|
|
|
|
|
0
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
943
|
|
|
|
|
|
|
return Attean::Literal->new(value => $term->value); |
944
|
|
|
|
|
|
|
} elsif ($func =~ /^[UI]RI$/) { # IRI URI |
945
|
|
|
|
|
|
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
946
|
0
|
|
|
|
|
0
|
return Attean::IRI->new(value => $term->value, base => $expr->base); |
947
|
|
|
|
|
|
|
} elsif ($func eq 'ABS') { |
948
|
|
|
|
|
|
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
949
|
0
|
|
|
|
|
0
|
my $value = abs($string->numeric_value); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
950
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => $value, datatype => $string->datatype); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
951
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'ROUND') { |
952
|
0
|
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
953
|
0
|
|
0
|
|
|
0
|
my $value = $string->numeric_value; |
954
|
0
|
0
|
|
|
|
0
|
my $mult = 1; |
955
|
|
|
|
|
|
|
if ($value < 0) { |
956
|
0
|
|
|
|
|
0
|
$mult = -1; |
957
|
|
|
|
|
|
|
$value = -$value; |
958
|
|
|
|
|
|
|
} |
959
|
0
|
0
|
|
|
|
0
|
my $round = $mult * POSIX::floor($value + 0.50000000000008); |
|
0
|
|
|
|
|
0
|
|
960
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $round, datatype => $string->datatype); |
961
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'CEIL') { |
962
|
0
|
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
963
|
|
|
|
|
|
|
my $value = ceil($string->numeric_value); |
964
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $value, datatype => $string->datatype); |
965
|
|
|
|
|
|
|
} elsif ($func eq 'FLOOR') { |
966
|
0
|
0
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
967
|
|
|
|
|
|
|
my $value = floor($string->numeric_value); |
968
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => $value, datatype => $string->datatype); |
969
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'CONCAT') { |
970
|
|
|
|
|
|
|
my @strings = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
971
|
0
|
|
|
|
|
0
|
# die "CONCAT called with terms that are not argument compatible" unless ($strings[0]->argument_compatible(@strings)); |
972
|
|
|
|
|
|
|
my %args; |
973
|
|
|
|
|
|
|
if (my $l = $strings[0]->language) { |
974
|
0
|
|
|
|
|
0
|
$args{language} = $l; |
975
|
|
|
|
|
|
|
} else { |
976
|
0
|
0
|
|
|
|
0
|
my $dt = $strings[0]->datatype; |
977
|
0
|
|
|
|
|
0
|
if ($dt->value eq '') { |
978
|
|
|
|
|
|
|
$args{datatype} = 'http://www.w3.org/2001/XMLSchema#string'; |
979
|
|
|
|
|
|
|
} |
980
|
0
|
|
|
|
|
0
|
} |
981
|
|
|
|
|
|
|
foreach my $s (@strings) { |
982
|
0
|
|
|
|
|
0
|
die unless ($s->does('Attean::API::Literal')); |
983
|
0
|
|
|
|
|
0
|
die if ($s->datatype and not($s->datatype->value =~ m<http://www.w3.org/(1999/02/22-rdf-syntax-ns#langString|2001/XMLSchema#string)>)); |
984
|
0
|
|
|
|
|
0
|
if (my $l2 = $s->language) { |
985
|
|
|
|
|
|
|
if (my $l1 = $args{language}) { |
986
|
0
|
|
|
|
|
0
|
if ($l1 ne $l2) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
987
|
0
|
|
|
|
|
0
|
delete $args{language}; |
988
|
|
|
|
|
|
|
} |
989
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
990
|
0
|
|
|
|
|
0
|
} else { |
991
|
|
|
|
|
|
|
delete $args{language}; |
992
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
993
|
0
|
|
|
|
|
0
|
} |
994
|
0
|
|
|
|
|
0
|
my $c = Attean::Literal->new(value => join('', map { $_->value } @strings), %args); |
995
|
|
|
|
|
|
|
return $c; |
996
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'DATATYPE') { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
997
|
0
|
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
998
|
0
|
|
|
|
|
0
|
die unless ($string->does('Attean::API::Literal')); |
999
|
0
|
0
|
|
|
|
0
|
return $string->datatype; |
1000
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'LANG') { |
1001
|
0
|
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1002
|
|
|
|
|
|
|
die unless ($string->does('Attean::API::Literal')); |
1003
|
0
|
|
|
|
|
0
|
my $value = $string->language // ''; |
1004
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $value); |
1005
|
|
|
|
|
|
|
} elsif ($func eq 'LANGMATCHES') { |
1006
|
0
|
|
|
|
|
0
|
my ($term, $pat) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1007
|
0
|
|
|
|
|
0
|
my $lang = $term->value; |
1008
|
0
|
|
|
|
|
0
|
my $match = $pat->value; |
1009
|
|
|
|
|
|
|
if ($match eq '*') { |
1010
|
0
|
|
|
|
|
0
|
# """A language-range of "*" matches any non-empty language-tag string.""" |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1011
|
0
|
|
|
|
|
0
|
return $lang ? $true : $false; |
1012
|
0
|
|
|
|
|
0
|
} else { |
1013
|
|
|
|
|
|
|
return (I18N::LangTags::is_dialect_of( $lang, $match )) ? $true : $false; |
1014
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1015
|
|
|
|
|
|
|
|
1016
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'ENCODE_FOR_URI') { |
1017
|
0
|
0
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1018
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => uri_escape_utf8($string->value)); |
1019
|
|
|
|
|
|
|
} elsif ($func =~ /^[LU]CASE$/) { |
1020
|
0
|
|
|
|
|
0
|
my $term = shift(@terms); |
1021
|
0
|
0
|
|
|
|
0
|
my $value = ($func eq 'LCASE') ? lc($term->value) : uc($term->value); |
1022
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $value, $term->construct_args); |
1023
|
|
|
|
|
|
|
} elsif ($func eq 'STRLANG') { |
1024
|
|
|
|
|
|
|
my ($term, $lang) = @terms; |
1025
|
0
|
|
|
|
|
0
|
die unless ($term->does('Attean::API::Literal')); |
1026
|
0
|
0
|
|
|
|
0
|
die unless ($term->datatype->value =~ m<http://www.w3.org/(1999/02/22-rdf-syntax-ns#langString|2001/XMLSchema#string)>); |
1027
|
0
|
0
|
0
|
|
|
0
|
die if ($term->language); |
1028
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => $term->value, language => $lang->value); |
1029
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'STRDT') { |
1030
|
0
|
0
|
|
|
|
0
|
my ($term, $dt) = @terms; |
1031
|
0
|
|
|
|
|
0
|
die unless ($term->does('Attean::API::Literal')); |
1032
|
|
|
|
|
|
|
die unless ($term->datatype->value =~ m<http://www.w3.org/(1999/02/22-rdf-syntax-ns#langString|2001/XMLSchema#string)>); |
1033
|
|
|
|
|
|
|
die if ($term->language); |
1034
|
|
|
|
|
|
|
# my ($term, $dt) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1035
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $term->value, datatype => $dt->value); |
1036
|
|
|
|
|
|
|
} elsif ($func eq 'REPLACE') { |
1037
|
|
|
|
|
|
|
my ($term, $pat, $rep) = @terms; |
1038
|
0
|
|
|
|
|
0
|
die unless ($term->does('Attean::API::Literal')); |
|
0
|
|
|
|
|
0
|
|
1039
|
0
|
|
|
|
|
0
|
die unless ($term->language or $term->datatype->value =~ m<http://www.w3.org/(1999/02/22-rdf-syntax-ns#langString|2001/XMLSchema#string)>); |
1040
|
|
|
|
|
|
|
# my ($term, $pat, $rep) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1041
|
0
|
|
|
|
|
0
|
my $value = $term->value; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1042
|
0
|
0
|
|
|
|
0
|
my $pattern = $pat->value; |
1043
|
0
|
|
|
|
|
0
|
my $replace = $rep->value; |
1044
|
|
|
|
|
|
|
die 'REPLACE() called with unsafe ?{} match pattern' if (index($pattern, '(?{') != -1 or index($pattern, '(??{') != -1); |
1045
|
0
|
|
|
|
|
0
|
die 'REPLACE() called with unsafe ?{} replace pattern' if (index($replace, '(?{') != -1 or index($replace, '(??{') != -1); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1046
|
0
|
0
|
|
|
|
0
|
|
1047
|
0
|
|
0
|
|
|
0
|
$replace =~ s/\\/\\\\/g; |
1048
|
0
|
|
|
|
|
0
|
$replace =~ s/\$(\d+)/\$$1/g; |
1049
|
|
|
|
|
|
|
$replace =~ s/"/\\"/g; |
1050
|
0
|
|
|
|
|
0
|
$replace = qq["$replace"]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1051
|
0
|
|
|
|
|
0
|
no warnings 'uninitialized'; |
1052
|
0
|
|
|
|
|
0
|
$value =~ s/$pattern/"$replace"/eeg; |
1053
|
0
|
0
|
|
|
|
0
|
# warn "==> " . Dumper($value); |
1054
|
|
|
|
|
|
|
return Attean::Literal->new(value => $value, $term->construct_args); |
1055
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'SUBSTR') { |
1056
|
|
|
|
|
|
|
my ($term, @args) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1057
|
0
|
0
|
|
|
|
0
|
my $value = $term->value; |
1058
|
|
|
|
|
|
|
my @nums; |
1059
|
|
|
|
|
|
|
foreach my $i (0 .. $#args) { |
1060
|
|
|
|
|
|
|
my $argnum = $i + 2; |
1061
|
0
|
|
|
|
|
0
|
my $arg = $args[ $i ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1062
|
0
|
|
|
|
|
0
|
push(@nums, $arg->numeric_value); |
1063
|
|
|
|
|
|
|
} |
1064
|
0
|
|
|
|
|
0
|
$nums[0]--; |
1065
|
0
|
0
|
|
|
|
0
|
my $substring = (scalar(@nums) > 1) ? substr($value, $nums[0], $nums[1]) : substr($value, $nums[0]); |
1066
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $substring, $term->construct_args); |
1067
|
|
|
|
|
|
|
} elsif ($func eq 'CONTAINS') { |
1068
|
0
|
|
|
|
|
0
|
my ($term, $pattern) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1069
|
0
|
0
|
|
|
|
0
|
if ($term->has_language and $pattern->has_language) { |
1070
|
0
|
0
|
|
|
|
0
|
if ($term->literal_value_language ne $pattern->literal_value_language) { |
1071
|
0
|
0
|
|
|
|
0
|
die "CONTAINS called with literals of different languages"; |
1072
|
0
|
|
|
|
|
0
|
} |
1073
|
|
|
|
|
|
|
} |
1074
|
0
|
|
|
|
|
0
|
my ($string, $pat) = map { $_->value } ($term, $pattern); |
1075
|
0
|
0
|
|
|
|
0
|
my $pos = index($string, $pat); |
1076
|
0
|
0
|
|
|
|
0
|
return ($pos >= 0) ? $true : $false; |
1077
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'STRSTARTS') { |
1078
|
|
|
|
|
|
|
my (@terms) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1079
|
0
|
|
|
|
|
0
|
my ($string, $pat) = map { $_->value } @terms; |
1080
|
|
|
|
|
|
|
return (substr($string, 0, length($pat)) eq $pat) ? $true : $false; |
1081
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'STRENDS') { |
1082
|
0
|
0
|
|
|
|
0
|
my (@terms) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1083
|
0
|
0
|
0
|
|
|
0
|
my ($string, $pat) = map { $_->value } @terms; |
1084
|
|
|
|
|
|
|
return (substr($string, length($string) - length($pat)) eq $pat) ? $true : $false; |
1085
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'STRAFTER') { |
1086
|
0
|
|
|
|
|
0
|
my ($term, $pat) = @terms; |
1087
|
0
|
|
|
|
|
0
|
die "STRAFTER called without a literal" unless ($term->does('Attean::API::Literal')); |
1088
|
0
|
0
|
0
|
|
|
0
|
die "STRAFTER called without a plain literal" unless ($term->language or $term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string'); |
1089
|
0
|
0
|
0
|
|
|
0
|
die "$func arguments are not term compatible: " . join(', ', map { $_->as_string } @terms) unless ($term->argument_compatible($pat)); |
1090
|
|
|
|
|
|
|
# TODO: check that the terms are argument compatible |
1091
|
0
|
|
|
|
|
0
|
my $value = $term->value; |
1092
|
0
|
|
|
|
|
0
|
my $match = $pat->value; |
1093
|
0
|
|
|
|
|
0
|
my $i = index($value, $match, 0); |
1094
|
0
|
|
|
|
|
0
|
if ($i < 0) { |
1095
|
50
|
|
|
50
|
|
221999
|
return Attean::Literal->new(value => ''); |
|
50
|
|
|
|
|
134
|
|
|
50
|
|
|
|
|
161067
|
|
1096
|
0
|
|
|
|
|
0
|
} else { |
|
0
|
|
|
|
|
0
|
|
1097
|
|
|
|
|
|
|
return Attean::Literal->new(value => substr($value, $i+length($match)), $term->construct_args); |
1098
|
0
|
|
|
|
|
0
|
} |
1099
|
|
|
|
|
|
|
} elsif ($func eq 'STRBEFORE') { |
1100
|
0
|
|
|
|
|
0
|
my ($term, $pat) = @terms; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1101
|
0
|
|
|
|
|
0
|
die "STRBEFORE called without a literal" unless ($term->does('Attean::API::Literal')); |
1102
|
0
|
|
|
|
|
0
|
die "STRBEFORE called without a plain literal" unless ($term->language or $term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string'); |
1103
|
0
|
|
|
|
|
0
|
die "$func arguments are not term compatible: " . join(', ', map { $_->as_string } @terms) unless ($term->argument_compatible($pat)); |
1104
|
0
|
|
|
|
|
0
|
# TODO: check that the terms are argument compatible |
1105
|
0
|
|
|
|
|
0
|
my $value = $term->value; |
1106
|
0
|
|
|
|
|
0
|
my $match = $pat->value; |
1107
|
|
|
|
|
|
|
my $i = index($value, $match, 0); |
1108
|
0
|
|
|
|
|
0
|
if ($i < 0) { |
1109
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => ''); |
1110
|
0
|
|
|
|
|
0
|
} else { |
1111
|
|
|
|
|
|
|
return Attean::Literal->new(value => substr($value, 0, $i), $term->construct_args); |
1112
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1113
|
0
|
0
|
0
|
|
|
0
|
} elsif ($func eq 'STRLEN') { |
1114
|
0
|
0
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1115
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => length($string->value), datatype => 'http://www.w3.org/2001/XMLSchema#integer'); |
1116
|
|
|
|
|
|
|
} elsif ($func eq 'MD5') { |
1117
|
|
|
|
|
|
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1118
|
0
|
|
|
|
|
0
|
my $bytes = encode('UTF-8', $string->value, Encode::FB_CROAK); |
|
0
|
|
|
|
|
0
|
|
1119
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => md5_hex($bytes)); |
1120
|
0
|
0
|
|
|
|
0
|
} elsif ($func =~ /^SHA(\d+)$/) { |
1121
|
|
|
|
|
|
|
my $sha = Digest::SHA->new($1); |
1122
|
0
|
|
|
|
|
0
|
my ($string) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1123
|
0
|
|
|
|
|
0
|
my $bytes = encode('UTF-8', $string->value, Encode::FB_CROAK); |
|
0
|
|
|
|
|
0
|
|
1124
|
0
|
0
|
|
|
|
0
|
$sha->add($bytes); |
1125
|
|
|
|
|
|
|
return Attean::Literal->new(value => $sha->hexdigest); |
1126
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'RAND') { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1127
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => rand(), datatype => 'http://www.w3.org/2001/XMLSchema#double'); |
|
0
|
|
|
|
|
0
|
|
1128
|
0
|
0
|
|
|
|
0
|
} elsif ($func =~ /^(YEAR|MONTH|DAY|HOUR|MINUTE)S?$/) { |
1129
|
|
|
|
|
|
|
my $method = lc($1); |
1130
|
0
|
|
|
|
|
0
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1131
|
0
|
0
|
|
|
|
0
|
my $dt = $term->datetime; |
1132
|
0
|
0
|
0
|
|
|
0
|
return Attean::Literal->new(value => $dt->$method(), datatype => 'http://www.w3.org/2001/XMLSchema#integer'); |
1133
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'SECONDS') { |
|
0
|
|
|
|
|
0
|
|
1134
|
|
|
|
|
|
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1135
|
0
|
|
|
|
|
0
|
my $dt = $term->datetime; |
1136
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $dt->second, datatype => 'http://www.w3.org/2001/XMLSchema#decimal'); |
1137
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'TIMEZONE') { |
1138
|
0
|
0
|
|
|
|
0
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1139
|
0
|
|
|
|
|
0
|
my $dt = $term->datetime; |
1140
|
|
|
|
|
|
|
my $tz = $dt->time_zone; |
1141
|
0
|
|
|
|
|
0
|
die "TIMEZONE called with a dateTime without a timezone" if ($tz->is_floating); |
1142
|
|
|
|
|
|
|
my $offset = $tz->offset_for_datetime( $dt ); |
1143
|
|
|
|
|
|
|
my $minus = ''; |
1144
|
0
|
|
|
|
|
0
|
if ($offset < 0) { |
1145
|
0
|
0
|
|
|
|
0
|
$minus = '-'; |
1146
|
0
|
0
|
0
|
|
|
0
|
$offset = -$offset; |
1147
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1148
|
|
|
|
|
|
|
|
1149
|
0
|
|
|
|
|
0
|
my $duration = "${minus}PT"; |
1150
|
0
|
|
|
|
|
0
|
if ($offset >= 60*60) { |
1151
|
0
|
|
|
|
|
0
|
my $h = int($offset / (60*60)); |
1152
|
0
|
0
|
|
|
|
0
|
$duration .= "${h}H" if ($h > 0); |
1153
|
0
|
|
|
|
|
0
|
$offset = $offset % (60*60); |
1154
|
|
|
|
|
|
|
} |
1155
|
0
|
|
|
|
|
0
|
if ($offset >= 60) { |
1156
|
|
|
|
|
|
|
my $m = int($offset / 60); |
1157
|
|
|
|
|
|
|
$duration .= "${m}M" if ($m > 0); |
1158
|
0
|
|
|
|
|
0
|
$offset = $offset % 60; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1159
|
0
|
|
|
|
|
0
|
} |
1160
|
|
|
|
|
|
|
my $s = int($offset); |
1161
|
0
|
|
|
|
|
0
|
$duration .= "${s}S" if ($s > 0 or $duration eq 'PT'); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1162
|
0
|
|
|
|
|
0
|
|
1163
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $duration, datatype => 'http://www.w3.org/2001/XMLSchema#dayTimeDuration'); |
1164
|
|
|
|
|
|
|
} elsif ($func eq 'TZ') { |
1165
|
0
|
|
|
|
|
0
|
my ($term) = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1166
|
0
|
|
|
|
|
0
|
my $dt = $term->datetime; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1167
|
0
|
|
|
|
|
0
|
my $tz = $dt->time_zone; |
1168
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value =>'') if ($tz->is_floating); |
1169
|
0
|
|
|
|
|
0
|
return Attean::Literal->new('Z') if ($tz->is_utc); |
1170
|
|
|
|
|
|
|
my $offset = $tz->offset_for_datetime( $dt ); |
1171
|
0
|
|
|
|
|
0
|
my $hours = 0; |
1172
|
|
|
|
|
|
|
my $minutes = 0; |
1173
|
0
|
|
|
|
|
0
|
my $minus = '+'; |
1174
|
0
|
|
|
|
|
0
|
if ($offset < 0) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1175
|
0
|
|
|
|
|
0
|
$minus = '-'; |
1176
|
0
|
|
|
|
|
0
|
$offset = -$offset; |
1177
|
|
|
|
|
|
|
} |
1178
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1179
|
0
|
|
|
|
|
0
|
if ($offset >= 60*60) { |
1180
|
0
|
|
|
|
|
0
|
$hours = int($offset / (60*60)); |
1181
|
|
|
|
|
|
|
$offset = $offset % (60*60); |
1182
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1183
|
0
|
|
|
|
|
0
|
if ($offset >= 60) { |
1184
|
0
|
|
|
|
|
0
|
$minutes = int($offset / 60); |
1185
|
0
|
0
|
|
|
|
0
|
$offset = $offset % 60; |
1186
|
0
|
|
|
|
|
0
|
} |
1187
|
0
|
|
|
|
|
0
|
my $seconds = int($offset); |
1188
|
0
|
0
|
|
|
|
0
|
return Attean::Literal->new(value => sprintf('%s%02d:%02d', $minus, $hours, $minutes)); |
1189
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'UUID') { |
1190
|
0
|
|
|
|
|
0
|
my $uuid = 'urn:uuid:' . uc(uuid_to_string(create_uuid())); |
1191
|
|
|
|
|
|
|
return Attean::IRI->new(value => $uuid); |
1192
|
|
|
|
|
|
|
} elsif ($func eq 'STRUUID') { |
1193
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => uc(uuid_to_string(create_uuid()))); |
1194
|
0
|
0
|
|
|
|
0
|
} elsif ($func eq 'BNODE') { |
1195
|
0
|
|
|
|
|
0
|
if (scalar(@{ $expr->children })) { |
1196
|
0
|
0
|
|
|
|
0
|
my $string = $self->evaluate_expression($model, $expr->children->[0], $r); |
1197
|
0
|
|
|
|
|
0
|
my $value = $string->value; |
1198
|
|
|
|
|
|
|
my $b = (exists $r->eval_stash->{'sparql:bnode'}{$value}) |
1199
|
0
|
0
|
|
|
|
0
|
? $r->eval_stash->{'sparql:bnode'}{$value} |
1200
|
0
|
|
|
|
|
0
|
: Attean::Blank->new(); |
1201
|
0
|
0
|
|
|
|
0
|
$r->eval_stash->{'sparql:bnode'}{$value} = $b; |
1202
|
0
|
|
|
|
|
0
|
return $b; |
1203
|
|
|
|
|
|
|
} else { |
1204
|
0
|
|
|
|
|
0
|
return Attean::Blank->new(); |
1205
|
0
|
0
|
0
|
|
|
0
|
} |
1206
|
|
|
|
|
|
|
} elsif ($func eq 'SAMETERM') { |
1207
|
0
|
|
|
|
|
0
|
my @operands = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1208
|
|
|
|
|
|
|
my ($a, $b) = @operands; |
1209
|
0
|
|
|
|
|
0
|
die "TypeError: SAMETERM" unless (blessed($operands[0]) and blessed($operands[1])); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1210
|
0
|
|
|
|
|
0
|
if ($a->compare($b)) { |
1211
|
0
|
|
|
|
|
0
|
return $false; |
1212
|
0
|
0
|
|
|
|
0
|
} |
1213
|
0
|
0
|
|
|
|
0
|
if ($a->does('Attean::API::Binding')) { |
1214
|
0
|
|
|
|
|
0
|
my $ok = ($a->sameTerms($b)); |
1215
|
0
|
|
|
|
|
0
|
return $ok ? $true : $false; |
1216
|
0
|
|
|
|
|
0
|
} else { |
1217
|
0
|
|
|
|
|
0
|
my $ok = ($a->value eq $b->value); |
1218
|
0
|
0
|
|
|
|
0
|
return $ok ? $true : $false; |
1219
|
0
|
|
|
|
|
0
|
} |
1220
|
0
|
|
|
|
|
0
|
} elsif ($func =~ /^(SUBJECT|PREDICATE|OBJECT)$/) { |
1221
|
|
|
|
|
|
|
my @operands = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1222
|
|
|
|
|
|
|
my $pos = lc($func); |
1223
|
0
|
0
|
|
|
|
0
|
my $term = $operands[0]->$pos(); |
1224
|
0
|
|
|
|
|
0
|
return $term; |
1225
|
0
|
|
|
|
|
0
|
} elsif ($func eq 'INVOKE') { |
1226
|
|
|
|
|
|
|
my @operands = map { $self->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
1227
|
0
|
0
|
|
|
|
0
|
my $furi = shift(@operands)->value; |
1228
|
0
|
|
|
|
|
0
|
my $func = Attean->get_global_function($furi); |
1229
|
0
|
|
|
|
|
0
|
unless (ref($func)) { |
1230
|
|
|
|
|
|
|
die "No extension registered for <$furi>"; |
1231
|
0
|
|
|
|
|
0
|
} |
1232
|
0
|
|
|
|
|
0
|
return $func->(@operands); |
1233
|
|
|
|
|
|
|
} else { |
1234
|
0
|
|
|
|
|
0
|
warn "Expression evaluation unimplemented: " . $expr->as_string; |
1235
|
0
|
|
|
|
|
0
|
$self->log->warn("Expression evaluation unimplemented: " . $expr->as_string); |
1236
|
|
|
|
|
|
|
die "Expression evaluation unimplemented: " . $expr->as_string; |
1237
|
0
|
|
|
|
|
0
|
} |
1238
|
|
|
|
|
|
|
} elsif ($expr->isa('Attean::ExistsPlanExpression')) { |
1239
|
0
|
0
|
|
|
|
0
|
my $plan = $expr->plan; |
|
0
|
|
|
|
|
0
|
|
1240
|
0
|
|
|
|
|
0
|
my $impl = $plan->substitute_impl($model, $r); |
1241
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1242
|
|
|
|
|
|
|
my $found = 0; |
1243
|
0
|
0
|
|
|
|
0
|
if (my $row = $iter->next) { |
1244
|
|
|
|
|
|
|
# warn "EXISTS found row: " . $row->as_string; |
1245
|
0
|
|
|
|
|
0
|
$found++; |
1246
|
0
|
|
|
|
|
0
|
} |
1247
|
|
|
|
|
|
|
|
1248
|
0
|
|
|
|
|
0
|
return $found ? Attean::Literal->true : Attean::Literal->false; |
1249
|
|
|
|
|
|
|
} else { |
1250
|
|
|
|
|
|
|
$self->log->warn("Expression evaluation unimplemented: " . $expr->as_string); |
1251
|
0
|
|
|
|
|
0
|
die "Expression evaluation unimplemented: " . $expr->as_string; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1252
|
0
|
|
|
|
|
0
|
} |
1253
|
0
|
0
|
0
|
|
|
0
|
} |
1254
|
0
|
0
|
|
|
|
0
|
|
1255
|
0
|
|
|
|
|
0
|
my $self = shift; |
1256
|
|
|
|
|
|
|
my $model = shift; |
1257
|
0
|
0
|
|
|
|
0
|
my $bind = shift; |
1258
|
0
|
|
|
|
|
0
|
my %exprs = %{ $self->expressions }; |
1259
|
0
|
0
|
|
|
|
0
|
my ($impl) = map { $_->substitute_impl($model, $bind) } @{ $self->children }; |
1260
|
|
|
|
|
|
|
# TODO: substitute variables in the expression |
1261
|
0
|
|
|
|
|
0
|
return $self->_impl($model, $impl, %exprs); |
1262
|
0
|
0
|
|
|
|
0
|
} |
1263
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
my $self = shift; |
1265
|
0
|
|
|
|
|
0
|
my $model = shift; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1266
|
0
|
|
|
|
|
0
|
my %exprs = %{ $self->expressions }; |
1267
|
0
|
|
|
|
|
0
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1268
|
0
|
|
|
|
|
0
|
return $self->_impl($model, $impl, %exprs); |
1269
|
|
|
|
|
|
|
} |
1270
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1271
|
0
|
|
|
|
|
0
|
my $self = shift; |
1272
|
0
|
|
|
|
|
0
|
my $model = shift; |
1273
|
0
|
0
|
|
|
|
0
|
my $impl = shift; |
1274
|
0
|
|
|
|
|
0
|
my %exprs = @_; |
1275
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1276
|
0
|
|
|
|
|
0
|
|
1277
|
|
|
|
|
|
|
return sub { |
1278
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1279
|
0
|
|
|
|
|
0
|
return Attean::CodeIterator->new( |
1280
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Result', |
1281
|
|
|
|
|
|
|
variables => $iter_variables, |
1282
|
|
|
|
|
|
|
generator => sub { |
1283
|
0
|
|
|
|
|
0
|
ROW: while (my $r = $iter->next) { |
1284
|
0
|
|
|
|
|
0
|
# warn 'Extend Row -------------------------------> ' . $r->as_string; |
1285
|
0
|
|
|
|
|
0
|
my %row = map { $_ => $r->value($_) } $r->variables; |
1286
|
0
|
|
|
|
|
0
|
foreach my $var (keys %exprs) { |
1287
|
0
|
0
|
|
|
|
0
|
my $expr = $exprs{$var}; |
1288
|
|
|
|
|
|
|
# warn "-> $var => " . $expr->as_string; |
1289
|
0
|
|
|
|
|
0
|
my $term = eval { $self->evaluate_expression($model, $expr, $r) }; |
1290
|
|
|
|
|
|
|
# warn $@ if ($@); |
1291
|
|
|
|
|
|
|
if (blessed($term)) { |
1292
|
0
|
0
|
|
|
|
0
|
# warn "===> " . $term->as_string; |
1293
|
|
|
|
|
|
|
if ($row{ $var } and $term->as_string ne $row{ $var }->as_string) { |
1294
|
0
|
|
|
|
|
0
|
next ROW; |
1295
|
0
|
|
|
|
|
0
|
} |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
if ($term->does('Attean::API::Binding')) { |
1298
|
|
|
|
|
|
|
# patterns need to be made ground to be bound as values (e.g. TriplePattern -> Triple) |
1299
|
|
|
|
|
|
|
$term = $term->ground($r); |
1300
|
0
|
|
|
0
|
0
|
0
|
} |
1301
|
0
|
|
|
|
|
0
|
|
1302
|
0
|
|
|
|
|
0
|
$row{ $var } = $term; |
1303
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1304
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1305
|
|
|
|
|
|
|
return Attean::Result->new( bindings => \%row, eval_stash => $r->eval_stash ); |
1306
|
0
|
|
|
|
|
0
|
} |
1307
|
|
|
|
|
|
|
return; |
1308
|
|
|
|
|
|
|
} |
1309
|
|
|
|
|
|
|
); |
1310
|
0
|
|
|
0
|
0
|
0
|
}; |
1311
|
0
|
|
|
|
|
0
|
} |
1312
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1313
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1314
|
0
|
|
|
|
|
0
|
=item * L<Attean::Plan::HashDistinct> |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
Evaluates a sub-plan, and returns distinct results by checking a persistent |
1317
|
|
|
|
|
|
|
hash of already-seen results. |
1318
|
0
|
|
|
0
|
|
0
|
|
1319
|
0
|
|
|
|
|
0
|
=cut |
1320
|
0
|
|
|
|
|
0
|
|
1321
|
0
|
|
|
|
|
0
|
use Moo; |
1322
|
0
|
|
|
|
|
0
|
use namespace::clean; |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1325
|
0
|
|
|
0
|
|
0
|
with 'Attean::API::UnionScopeVariablesPlan'; |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
my $self = shift; |
1329
|
|
|
|
|
|
|
my $model = shift; |
1330
|
0
|
|
|
|
|
0
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1331
|
|
|
|
|
|
|
my %seen; |
1332
|
0
|
|
|
|
|
0
|
return sub { |
|
0
|
|
|
|
|
0
|
|
1333
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1334
|
0
|
|
|
|
|
0
|
return $iter->grep(sub { return not($seen{ shift->as_string }++); }); |
1335
|
|
|
|
|
|
|
}; |
1336
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1337
|
|
|
|
|
|
|
} |
1338
|
0
|
0
|
|
|
|
0
|
|
1339
|
|
|
|
|
|
|
=item * L<Attean::Plan::Unique> |
1340
|
0
|
0
|
0
|
|
|
0
|
|
1341
|
0
|
|
|
|
|
0
|
Evaluates an already-ordered sub-plan, and returns distinct results by |
1342
|
|
|
|
|
|
|
filtering out sequential duplicates. |
1343
|
|
|
|
|
|
|
|
1344
|
0
|
0
|
|
|
|
0
|
=cut |
1345
|
|
|
|
|
|
|
|
1346
|
0
|
|
|
|
|
0
|
use Moo; |
1347
|
|
|
|
|
|
|
use namespace::clean; |
1348
|
|
|
|
|
|
|
|
1349
|
0
|
|
|
|
|
0
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1350
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
1351
|
|
|
|
|
|
|
|
1352
|
0
|
|
|
|
|
0
|
|
1353
|
|
|
|
|
|
|
my $self = shift; |
1354
|
0
|
|
|
|
|
0
|
my $model = shift; |
1355
|
|
|
|
|
|
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1356
|
0
|
|
|
|
|
0
|
return sub { |
1357
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1358
|
|
|
|
|
|
|
my $last = ''; |
1359
|
|
|
|
|
|
|
return $iter->grep(sub { |
1360
|
|
|
|
|
|
|
my $r = shift; |
1361
|
|
|
|
|
|
|
my $s = $r->as_string; |
1362
|
|
|
|
|
|
|
my $ok = $s ne $last; |
1363
|
|
|
|
|
|
|
$last = $s; |
1364
|
|
|
|
|
|
|
return $ok; |
1365
|
|
|
|
|
|
|
}); |
1366
|
|
|
|
|
|
|
}; |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
} |
1369
|
50
|
|
|
50
|
|
76382
|
|
|
50
|
|
|
|
|
125
|
|
|
50
|
|
|
|
|
338
|
|
1370
|
50
|
|
|
50
|
|
16663
|
=item * L<Attean::Plan::Slice> |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
253
|
|
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
Evaluates a sub-plan, and returns the results after optionally skipping some |
1373
|
|
|
|
|
|
|
number of results ("offset") and limiting the total number of returned results |
1374
|
|
|
|
|
|
|
("limit"). |
1375
|
0
|
|
|
0
|
0
|
0
|
|
1376
|
|
|
|
|
|
|
=cut |
1377
|
|
|
|
|
|
|
|
1378
|
0
|
|
|
0
|
0
|
0
|
use Moo; |
1379
|
0
|
|
|
|
|
0
|
use Types::Standard qw(Int); |
1380
|
0
|
|
|
|
|
0
|
use namespace::clean; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1381
|
0
|
|
|
|
|
0
|
|
1382
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1383
|
0
|
|
|
0
|
|
0
|
with 'Attean::API::UnionScopeVariablesPlan'; |
1384
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1385
|
0
|
|
|
|
|
0
|
has 'limit' => (is => 'ro', isa => Int, default => -1); |
1386
|
|
|
|
|
|
|
has 'offset' => (is => 'ro', isa => Int, default => 0); |
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
my $self = shift; |
1389
|
|
|
|
|
|
|
my @str; |
1390
|
|
|
|
|
|
|
push(@str, "Limit=" . $self->limit) if ($self->limit >= 0); |
1391
|
|
|
|
|
|
|
push(@str, "Offset=" . $self->offset) if ($self->offset > 0); |
1392
|
|
|
|
|
|
|
return sprintf('Slice { %s }', join(' ', @str)); |
1393
|
|
|
|
|
|
|
} |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
my $self = shift; |
1396
|
|
|
|
|
|
|
my $model = shift; |
1397
|
50
|
|
|
50
|
|
31257
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
275
|
|
1398
|
50
|
|
|
50
|
|
14915
|
my $offset = $self->offset; |
|
50
|
|
|
|
|
136
|
|
|
50
|
|
|
|
|
267
|
|
1399
|
|
|
|
|
|
|
my $limit = $self->limit; |
1400
|
|
|
|
|
|
|
return sub { |
1401
|
|
|
|
|
|
|
my $iter = $impl->(); |
1402
|
|
|
|
|
|
|
$iter = $iter->offset($offset) if ($offset > 0); |
1403
|
0
|
|
|
0
|
0
|
0
|
$iter = $iter->limit($limit) if ($limit >= 0); |
1404
|
|
|
|
|
|
|
return $iter; |
1405
|
|
|
|
|
|
|
}; |
1406
|
0
|
|
|
0
|
0
|
0
|
} |
1407
|
0
|
|
|
|
|
0
|
} |
1408
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1409
|
|
|
|
|
|
|
=item * L<Attean::Plan::Project> |
1410
|
0
|
|
|
0
|
|
0
|
|
1411
|
0
|
|
|
|
|
0
|
Evaluates a sub-plan and returns projected results by only keeping a fixed-set |
1412
|
|
|
|
|
|
|
of variable bindings in each result. |
1413
|
0
|
|
|
|
|
0
|
|
1414
|
0
|
|
|
|
|
0
|
=cut |
1415
|
0
|
|
|
|
|
0
|
|
1416
|
0
|
|
|
|
|
0
|
use Moo; |
1417
|
0
|
|
|
|
|
0
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree'; |
1418
|
0
|
|
|
|
|
0
|
use Types::Standard qw(ArrayRef ConsumerOf); |
1419
|
0
|
|
|
|
|
0
|
has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1); |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
my $class = shift; |
1422
|
|
|
|
|
|
|
my %args = @_; |
1423
|
|
|
|
|
|
|
my @vars = map { $_->value } @{ $args{variables} }; |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
if (exists $args{in_scope_variables}) { |
1426
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
1427
|
|
|
|
|
|
|
} |
1428
|
|
|
|
|
|
|
$args{in_scope_variables} = \@vars; |
1429
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
return $class->SUPER::BUILDARGS(%args); |
1431
|
|
|
|
|
|
|
} |
1432
|
50
|
|
|
50
|
|
32537
|
|
|
50
|
|
|
|
|
128
|
|
|
50
|
|
|
|
|
219
|
|
1433
|
50
|
|
|
50
|
|
14846
|
# sub BUILD { |
|
50
|
|
|
|
|
128
|
|
|
50
|
|
|
|
|
364
|
|
1434
|
50
|
|
|
50
|
|
23166
|
# my $self = shift; |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
229
|
|
1435
|
|
|
|
|
|
|
# my @vars = map { $_->value } @{ $self->variables }; |
1436
|
|
|
|
|
|
|
# unless (scalar(@vars)) { |
1437
|
|
|
|
|
|
|
# Carp::confess "No vars in project?"; |
1438
|
|
|
|
|
|
|
# } |
1439
|
|
|
|
|
|
|
# } |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
my $self = shift; |
1442
|
|
|
|
|
|
|
return sprintf('Project { %s }', join(' ', map { '?' . $_->value } @{ $self->variables })); |
1443
|
0
|
|
|
0
|
0
|
0
|
} |
1444
|
0
|
|
|
|
|
0
|
|
1445
|
0
|
0
|
|
|
|
0
|
my $self = shift; |
1446
|
0
|
0
|
|
|
|
0
|
my $model = shift; |
1447
|
0
|
|
|
|
|
0
|
my $bind = shift; |
1448
|
|
|
|
|
|
|
my ($impl) = map { $_->substitute_impl($model, $bind) } @{ $self->children }; |
1449
|
|
|
|
|
|
|
my @vars = map { $_->value } @{ $self->variables }; |
1450
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1451
|
0
|
|
|
0
|
0
|
0
|
|
1452
|
0
|
|
|
|
|
0
|
# TODO: substitute variables in the projection where appropriate |
1453
|
0
|
|
|
|
|
0
|
return sub { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1454
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1455
|
0
|
|
|
|
|
0
|
return $iter->map(sub { |
1456
|
|
|
|
|
|
|
my $r = shift; |
1457
|
0
|
|
|
0
|
|
0
|
my $b = { map { my $t = $r->value($_); $t ? ($_ => $t) : () } @vars }; |
1458
|
0
|
0
|
|
|
|
0
|
return Attean::Result->new( bindings => $b ); |
1459
|
0
|
0
|
|
|
|
0
|
}, $iter->item_type, variables => $iter_variables); |
1460
|
0
|
|
|
|
|
0
|
}; |
1461
|
0
|
|
|
|
|
0
|
} |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
my $self = shift; |
1464
|
|
|
|
|
|
|
my $model = shift; |
1465
|
|
|
|
|
|
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1466
|
|
|
|
|
|
|
my @vars = map { $_->value } @{ $self->variables }; |
1467
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
return sub { |
1470
|
|
|
|
|
|
|
my $iter = $impl->(); |
1471
|
|
|
|
|
|
|
return $iter->map(sub { |
1472
|
|
|
|
|
|
|
my $r = shift; |
1473
|
50
|
|
|
50
|
|
36778
|
my $b = { map { my $t = $r->value($_); $t ? ($_ => $t) : () } @vars }; |
|
50
|
|
|
|
|
118
|
|
|
50
|
|
|
|
|
264
|
|
1474
|
|
|
|
|
|
|
return Attean::Result->new( bindings => $b ); |
1475
|
50
|
|
|
50
|
|
15622
|
}, $iter->item_type, variables => $iter_variables); |
|
50
|
|
|
|
|
140
|
|
|
50
|
|
|
|
|
276
|
|
1476
|
|
|
|
|
|
|
}; |
1477
|
|
|
|
|
|
|
} |
1478
|
|
|
|
|
|
|
} |
1479
|
10
|
|
|
10
|
0
|
17025
|
|
1480
|
10
|
|
|
|
|
40
|
=item * L<Attean::Plan::OrderBy> |
1481
|
10
|
|
|
|
|
17
|
|
|
16
|
|
|
|
|
59
|
|
|
10
|
|
|
|
|
29
|
|
1482
|
|
|
|
|
|
|
Evaluates a sub-plan and returns the results after fully materializing and |
1483
|
10
|
50
|
|
|
|
34
|
sorting is applied. |
1484
|
0
|
|
|
|
|
0
|
|
1485
|
|
|
|
|
|
|
=cut |
1486
|
10
|
|
|
|
|
23
|
|
1487
|
|
|
|
|
|
|
use Moo; |
1488
|
10
|
|
|
|
|
62
|
use Types::Standard qw(HashRef ArrayRef InstanceOf Bool Str); |
1489
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
1490
|
|
|
|
|
|
|
use namespace::clean; |
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1493
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
has 'variables' => (is => 'ro', isa => ArrayRef[Str], required => 1); |
1496
|
|
|
|
|
|
|
has 'ascending' => (is => 'ro', isa => HashRef[Bool], required => 1); |
1497
|
|
|
|
|
|
|
|
1498
|
|
|
|
|
|
|
my $self = shift; |
1499
|
|
|
|
|
|
|
my @vars = @{ $self->variables }; |
1500
|
0
|
|
|
0
|
0
|
0
|
my $ascending = $self->ascending; |
1501
|
0
|
|
|
|
|
0
|
my @strings = map { sprintf('%s(?%s)', ($ascending->{$_} ? 'ASC' : 'DESC'), $_) } @vars; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1502
|
|
|
|
|
|
|
return sprintf('Order { %s }', join(', ', @strings)); |
1503
|
0
|
|
|
0
|
0
|
0
|
} |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
my $self = shift; |
1506
|
0
|
|
|
0
|
0
|
0
|
my $vars = shift; |
1507
|
0
|
|
|
|
|
0
|
my $ascending = shift; |
1508
|
0
|
|
|
|
|
0
|
my $rows = shift; |
1509
|
0
|
|
|
|
|
0
|
local($Attean::API::Binding::ALLOW_IRI_COMPARISON) = 1; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1510
|
0
|
|
|
|
|
0
|
my @sorted = map { $_->[0] } sort { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1511
|
0
|
|
|
|
|
0
|
my ($ar, $avalues) = @$a; |
1512
|
|
|
|
|
|
|
my ($br, $bvalues) = @$b; |
1513
|
|
|
|
|
|
|
my $c = 0; |
1514
|
|
|
|
|
|
|
foreach my $i (0 .. $#{ $vars }) { |
1515
|
0
|
|
|
0
|
|
0
|
my $ascending = $ascending->{ $vars->[$i] }; |
1516
|
|
|
|
|
|
|
my ($av, $bv) = map { $_->[$i] } ($avalues, $bvalues); |
1517
|
0
|
|
|
|
|
0
|
|
1518
|
0
|
0
|
|
|
|
0
|
# Mirrors code in Attean::SimpleQueryEvaluator->evaluate |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1519
|
0
|
|
|
|
|
0
|
if (blessed($av) and $av->does('Attean::API::Binding') and (not(defined($bv)) or not($bv->does('Attean::API::Binding')))) { |
1520
|
0
|
|
|
|
|
0
|
$c = 1; |
1521
|
0
|
|
|
|
|
0
|
} elsif (blessed($bv) and $bv->does('Attean::API::Binding') and (not(defined($av)) or not($av->does('Attean::API::Binding')))) { |
1522
|
|
|
|
|
|
|
$c = -1; |
1523
|
|
|
|
|
|
|
} else { |
1524
|
|
|
|
|
|
|
$c = eval { $av ? $av->compare($bv) : 1 }; |
1525
|
2
|
|
|
2
|
0
|
6
|
if ($@) { |
1526
|
2
|
|
|
|
|
2
|
$c = 1; |
1527
|
2
|
|
|
|
|
5
|
} |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
8
|
|
1528
|
2
|
|
|
|
|
5
|
} |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
9
|
|
1529
|
2
|
|
|
|
|
9
|
$c *= -1 unless ($ascending); |
1530
|
|
|
|
|
|
|
last unless ($c == 0); |
1531
|
|
|
|
|
|
|
} |
1532
|
2
|
|
|
2
|
|
5
|
$c |
1533
|
|
|
|
|
|
|
} map { |
1534
|
2
|
|
|
|
|
6
|
my $r = $_; |
1535
|
2
|
50
|
|
|
|
7
|
[$r, [map { $r->value($_) } @$vars]] |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
1536
|
2
|
|
|
|
|
42
|
} @$rows; |
1537
|
2
|
|
|
|
|
104
|
return @sorted; |
1538
|
2
|
|
|
|
|
11
|
} |
1539
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
my $self = shift; |
1541
|
|
|
|
|
|
|
my $model = shift; |
1542
|
|
|
|
|
|
|
my $vars = $self->variables; |
1543
|
|
|
|
|
|
|
my $ascending = $self->ascending; |
1544
|
|
|
|
|
|
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1545
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1546
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
return sub { |
1548
|
|
|
|
|
|
|
my $iter = $impl->(); |
1549
|
|
|
|
|
|
|
my @rows = $iter->elements; |
1550
|
50
|
|
|
50
|
|
55014
|
my @sorted = $self->sort_rows($vars, $ascending, \@rows); |
|
50
|
|
|
|
|
150
|
|
|
50
|
|
|
|
|
307
|
|
1551
|
50
|
|
|
50
|
|
15717
|
return Attean::ListIterator->new( |
|
50
|
|
|
|
|
146
|
|
|
50
|
|
|
|
|
279
|
|
1552
|
50
|
|
|
50
|
|
40635
|
values => \@sorted, |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
2453
|
|
1553
|
50
|
|
|
50
|
|
289
|
variables => $iter_variables, |
|
50
|
|
|
|
|
116
|
|
|
50
|
|
|
|
|
286
|
|
1554
|
|
|
|
|
|
|
item_type => $iter->item_type |
1555
|
|
|
|
|
|
|
); |
1556
|
|
|
|
|
|
|
} |
1557
|
|
|
|
|
|
|
} |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
|
1560
|
|
|
|
|
|
|
=item * L<Attean::Plan::Service> |
1561
|
|
|
|
|
|
|
|
1562
|
1
|
|
|
1
|
0
|
4
|
Evaluates a SPARQL query against a remote endpoint. |
1563
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
1564
|
1
|
|
|
|
|
4
|
=cut |
1565
|
1
|
50
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
1566
|
1
|
|
|
|
|
7
|
use Moo; |
1567
|
|
|
|
|
|
|
use Types::Standard qw(ConsumerOf Bool Str); |
1568
|
|
|
|
|
|
|
use namespace::clean; |
1569
|
|
|
|
|
|
|
|
1570
|
0
|
|
|
0
|
0
|
0
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1571
|
0
|
|
|
|
|
0
|
|
1572
|
0
|
|
|
|
|
0
|
has 'endpoint' => (is => 'ro', isa => ConsumerOf['Attean::API::TermOrVariable'], required => 1); |
1573
|
0
|
|
|
|
|
0
|
has 'silent' => (is => 'ro', isa => Bool, default => 0); |
1574
|
0
|
|
|
|
|
0
|
has 'sparql' => (is => 'ro', isa => Str, required => 1); |
1575
|
0
|
|
|
|
|
0
|
|
1576
|
0
|
|
|
|
|
0
|
my $self = shift; |
1577
|
0
|
|
|
|
|
0
|
my $sparql = $self->sparql; |
1578
|
0
|
|
|
|
|
0
|
$sparql =~ s/\s+/ /g; |
1579
|
0
|
|
|
|
|
0
|
return sprintf('Service <%s> %s', $self->endpoint->as_string, $sparql); |
|
0
|
|
|
|
|
0
|
|
1580
|
0
|
|
|
|
|
0
|
} |
1581
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1582
|
|
|
|
|
|
|
my $self = shift; |
1583
|
|
|
|
|
|
|
my $model = shift; |
1584
|
0
|
0
|
0
|
|
|
0
|
die __PACKAGE__ . " unimplemented"; |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1585
|
0
|
|
|
|
|
0
|
} |
1586
|
|
|
|
|
|
|
} |
1587
|
0
|
|
|
|
|
0
|
|
1588
|
|
|
|
|
|
|
=item * L<Attean::Plan::Table> |
1589
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1590
|
0
|
0
|
|
|
|
0
|
Returns a constant set of results. |
1591
|
0
|
|
|
|
|
0
|
|
1592
|
|
|
|
|
|
|
=cut |
1593
|
|
|
|
|
|
|
|
1594
|
0
|
0
|
|
|
|
0
|
use Moo; |
1595
|
0
|
0
|
|
|
|
0
|
use Types::Standard qw(ArrayRef ConsumerOf); |
1596
|
|
|
|
|
|
|
use namespace::clean; |
1597
|
|
|
|
|
|
|
|
1598
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1599
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1600
|
0
|
|
|
|
|
0
|
has variables => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']]); |
|
0
|
|
|
|
|
0
|
|
1601
|
|
|
|
|
|
|
has rows => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Result']]); |
1602
|
0
|
|
|
|
|
0
|
|
1603
|
|
|
|
|
|
|
my $self = shift; |
1604
|
|
|
|
|
|
|
my $level = shift; |
1605
|
|
|
|
|
|
|
my $indent = ' ' x ($level + 1); |
1606
|
0
|
|
|
0
|
0
|
0
|
my $vars = join(', ', map { "?$_" } @{ $self->in_scope_variables }); |
1607
|
0
|
|
|
|
|
0
|
my $s = "Table (" . $vars . ")"; |
1608
|
0
|
|
|
|
|
0
|
foreach my $row (@{ $self->rows }) { |
1609
|
0
|
|
|
|
|
0
|
$s .= "\n-${indent} " . $row->as_string; |
1610
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1611
|
0
|
|
|
|
|
0
|
return $s; |
1612
|
|
|
|
|
|
|
} |
1613
|
|
|
|
|
|
|
|
1614
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
1615
|
0
|
|
|
|
|
0
|
my %args = @_; |
1616
|
0
|
|
|
|
|
0
|
my @vars = map { $_->value } @{ $args{variables} }; |
1617
|
0
|
|
|
|
|
0
|
|
1618
|
|
|
|
|
|
|
if (exists $args{in_scope_variables}) { |
1619
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
1620
|
|
|
|
|
|
|
} |
1621
|
|
|
|
|
|
|
$args{in_scope_variables} = \@vars; |
1622
|
|
|
|
|
|
|
|
1623
|
0
|
|
|
|
|
0
|
return $class->SUPER::BUILDARGS(%args); |
1624
|
|
|
|
|
|
|
} |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
my $self = shift; |
1627
|
|
|
|
|
|
|
my $model = shift; |
1628
|
|
|
|
|
|
|
my $rows = $self->rows; |
1629
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1630
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
return sub { |
1632
|
|
|
|
|
|
|
return Attean::ListIterator->new( |
1633
|
50
|
|
|
50
|
|
65391
|
item_type => 'Attean::API::Result', |
|
50
|
|
|
|
|
137
|
|
|
50
|
|
|
|
|
251
|
|
1634
|
50
|
|
|
50
|
|
15887
|
variables => $iter_variables, |
|
50
|
|
|
|
|
129
|
|
|
50
|
|
|
|
|
285
|
|
1635
|
50
|
|
|
50
|
|
31664
|
values => $rows |
|
50
|
|
|
|
|
120
|
|
|
50
|
|
|
|
|
248
|
|
1636
|
|
|
|
|
|
|
); |
1637
|
|
|
|
|
|
|
}; |
1638
|
|
|
|
|
|
|
} |
1639
|
|
|
|
|
|
|
} |
1640
|
|
|
|
|
|
|
|
1641
|
|
|
|
|
|
|
=item * L<Attean::Plan::Iterator> |
1642
|
|
|
|
|
|
|
|
1643
|
|
|
|
|
|
|
Returns a constant set of results. |
1644
|
0
|
|
|
0
|
0
|
0
|
|
1645
|
0
|
|
|
|
|
0
|
Be aware that if the iterator being wrapped is not repeatable (consuming the |
1646
|
0
|
|
|
|
|
0
|
L<Attean::API::RepeatableIterator> role), then this plan may only be evaluated |
1647
|
0
|
|
|
|
|
0
|
once. |
1648
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
A size estimate may be given if it is available. If the iterator is an |
1650
|
0
|
|
|
0
|
0
|
0
|
L<Attean::ListIterator>, the size of that iterator will be used. |
1651
|
|
|
|
|
|
|
|
1652
|
0
|
|
|
0
|
0
|
0
|
=cut |
1653
|
0
|
|
|
|
|
0
|
|
1654
|
0
|
|
|
|
|
0
|
use Moo; |
1655
|
|
|
|
|
|
|
use Types::Standard qw(ArrayRef ConsumerOf Int); |
1656
|
|
|
|
|
|
|
use namespace::clean; |
1657
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
has iterator => (is => 'ro', isa => ConsumerOf['Attean::API::ResultIterator']); |
1661
|
|
|
|
|
|
|
has size_estimate => (is => 'lazy', isa => Int, predicate => 1); |
1662
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
my $self = shift; |
1664
|
|
|
|
|
|
|
my $iter = $self->iterator; |
1665
|
50
|
|
|
50
|
|
38797
|
if ($iter->isa('Attean::ListIterator')) { |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
258
|
|
1666
|
50
|
|
|
50
|
|
15887
|
return $iter->size; |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
320
|
|
1667
|
50
|
|
|
50
|
|
25709
|
} |
|
50
|
|
|
|
|
124
|
|
|
50
|
|
|
|
|
241
|
|
1668
|
|
|
|
|
|
|
} |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
|
1671
|
|
|
|
|
|
|
my $self = shift; |
1672
|
|
|
|
|
|
|
my $level = shift; |
1673
|
|
|
|
|
|
|
my $indent = ' ' x ($level + 1); |
1674
|
0
|
|
|
0
|
0
|
0
|
my $string = 'Iterator ('; |
1675
|
|
|
|
|
|
|
$string .= join(', ', map { "?$_" } @{ $self->in_scope_variables }); |
1676
|
0
|
|
|
0
|
0
|
0
|
if ($self->has_size_estimate) { |
1677
|
0
|
|
|
|
|
0
|
$string .= ' with ' . $self->size_estimate . ' elements'; |
1678
|
0
|
|
|
|
|
0
|
} |
1679
|
0
|
|
|
|
|
0
|
$string .= ')'; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1680
|
0
|
|
|
|
|
0
|
return $string; |
1681
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1682
|
0
|
|
|
|
|
0
|
|
1683
|
|
|
|
|
|
|
my $class = shift; |
1684
|
0
|
|
|
|
|
0
|
my %args = @_; |
1685
|
|
|
|
|
|
|
my $vars = $args{iterator}->variables; |
1686
|
|
|
|
|
|
|
|
1687
|
|
|
|
|
|
|
if (exists $args{in_scope_variables}) { |
1688
|
8
|
|
|
8
|
0
|
18047
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
1689
|
8
|
|
|
|
|
38
|
} |
1690
|
8
|
|
|
|
|
17
|
$args{in_scope_variables} = $vars; |
|
0
|
|
|
|
|
0
|
|
|
8
|
|
|
|
|
21
|
|
1691
|
|
|
|
|
|
|
|
1692
|
8
|
50
|
|
|
|
31
|
return $class->SUPER::BUILDARGS(%args); |
1693
|
0
|
|
|
|
|
0
|
} |
1694
|
|
|
|
|
|
|
|
1695
|
8
|
|
|
|
|
19
|
my $self = shift; |
1696
|
|
|
|
|
|
|
my $model = shift; |
1697
|
8
|
|
|
|
|
53
|
my $iter = $self->iterator; |
1698
|
|
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
return sub { |
1700
|
|
|
|
|
|
|
if ($iter->does('Attean::API::RepeatableIterator')) { |
1701
|
0
|
|
|
0
|
0
|
0
|
$iter->reset; |
1702
|
0
|
|
|
|
|
0
|
} |
1703
|
0
|
|
|
|
|
0
|
return $iter; |
1704
|
0
|
|
|
|
|
0
|
}; |
1705
|
|
|
|
|
|
|
} |
1706
|
|
|
|
|
|
|
} |
1707
|
0
|
|
|
0
|
|
0
|
|
1708
|
|
|
|
|
|
|
=item * L<Attean::Plan::ALPPath> |
1709
|
|
|
|
|
|
|
|
1710
|
|
|
|
|
|
|
=cut |
1711
|
|
|
|
|
|
|
|
1712
|
0
|
|
|
|
|
0
|
use Moo; |
1713
|
|
|
|
|
|
|
use Attean::TreeRewriter; |
1714
|
|
|
|
|
|
|
use Types::Standard qw(ArrayRef ConsumerOf); |
1715
|
|
|
|
|
|
|
use namespace::clean; |
1716
|
|
|
|
|
|
|
|
1717
|
|
|
|
|
|
|
has 'subject' => (is => 'ro', required => 1); |
1718
|
|
|
|
|
|
|
has 'object' => (is => 'ro', required => 1); |
1719
|
|
|
|
|
|
|
has 'graph' => (is => 'ro', required => 1); |
1720
|
|
|
|
|
|
|
has 'step_begin' => (is => 'ro', required => 1); |
1721
|
|
|
|
|
|
|
has 'step_end' => (is => 'ro', required => 1); |
1722
|
|
|
|
|
|
|
has 'skip' => (is => 'ro', required => 1, default => 0); |
1723
|
|
|
|
|
|
|
# has 'children' => (is => 'ro', isa => ConsumerOf['Attean::API::BindingSubstitutionPlan'], required => 1); |
1724
|
|
|
|
|
|
|
|
1725
|
|
|
|
|
|
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::NullaryQueryTree'; |
1726
|
|
|
|
|
|
|
|
1727
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1728
|
|
|
|
|
|
|
|
1729
|
|
|
|
|
|
|
my $self = shift; |
1730
|
50
|
|
|
50
|
|
45442
|
my @strings; |
|
50
|
|
|
|
|
117
|
|
|
50
|
|
|
|
|
259
|
|
1731
|
50
|
|
|
50
|
|
15587
|
push(@strings, sprintf('%s ← %s', map { $_->ntriples_string } ($self->subject, $self->step_begin))); |
|
50
|
|
|
|
|
149
|
|
|
50
|
|
|
|
|
309
|
|
1732
|
50
|
|
|
50
|
|
31008
|
push(@strings, sprintf('%s ← %s', map { $_->ntriples_string } ($self->object, $self->step_end))); |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
232
|
|
1733
|
|
|
|
|
|
|
return sprintf('ALPPath %s', join(', ', @strings)); |
1734
|
|
|
|
|
|
|
} |
1735
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
my $class = shift; |
1737
|
|
|
|
|
|
|
my %args = @_; |
1738
|
|
|
|
|
|
|
my @vars = map { $_->value } grep { $_->does('Attean::API::Variable') } (@args{qw(subject object)}); |
1739
|
|
|
|
|
|
|
|
1740
|
1
|
|
|
1
|
|
1243
|
if (exists $args{in_scope_variables}) { |
1741
|
1
|
|
|
|
|
4
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
1742
|
1
|
50
|
|
|
|
7
|
} |
1743
|
1
|
|
|
|
|
10
|
$args{in_scope_variables} = \@vars; |
1744
|
|
|
|
|
|
|
|
1745
|
|
|
|
|
|
|
return $class->SUPER::BUILDARGS(%args); |
1746
|
|
|
|
|
|
|
} |
1747
|
|
|
|
|
|
|
|
1748
|
0
|
|
|
0
|
0
|
0
|
my $model = shift; |
1749
|
|
|
|
|
|
|
my $graph = shift; |
1750
|
4
|
|
|
4
|
0
|
8
|
my $skip = shift; |
1751
|
4
|
|
|
|
|
5
|
my $x = shift; |
1752
|
4
|
|
|
|
|
8
|
my $path = shift; |
1753
|
4
|
|
|
|
|
7
|
my $v = shift; |
1754
|
4
|
|
|
|
|
6
|
my $start = shift; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
10
|
|
1755
|
4
|
100
|
|
|
|
13
|
my $end = shift; |
1756
|
3
|
|
|
|
|
44
|
my $bind = shift; |
1757
|
|
|
|
|
|
|
if (exists $v->{$x->as_string}) { |
1758
|
4
|
|
|
|
|
24
|
return; |
1759
|
4
|
|
|
|
|
12
|
} |
1760
|
|
|
|
|
|
|
my $binding = Attean::Result->new( bindings => { $start => $x } )->join($bind); |
1761
|
|
|
|
|
|
|
unless ($binding) { |
1762
|
|
|
|
|
|
|
return; |
1763
|
5
|
|
|
5
|
0
|
5210
|
} |
1764
|
5
|
|
|
|
|
23
|
|
1765
|
5
|
|
|
|
|
85
|
if ($skip) { |
1766
|
|
|
|
|
|
|
$skip--; |
1767
|
5
|
50
|
|
|
|
38
|
} else { |
1768
|
0
|
|
|
|
|
0
|
$v->{$x->as_string} = $x; |
1769
|
|
|
|
|
|
|
} |
1770
|
5
|
|
|
|
|
10
|
|
1771
|
|
|
|
|
|
|
my $impl = $path->substitute_impl($model, $binding); |
1772
|
5
|
|
|
|
|
24
|
my $iter = $impl->(); |
1773
|
|
|
|
|
|
|
while (my $row = $iter->next()) { |
1774
|
|
|
|
|
|
|
my $n = $row->value($end); |
1775
|
|
|
|
|
|
|
alp($model, $graph, $skip, $n, $path, $v, $start, $end, $bind); |
1776
|
1
|
|
|
1
|
0
|
208
|
} |
1777
|
1
|
|
|
|
|
3
|
} |
1778
|
1
|
|
|
|
|
4
|
|
1779
|
|
|
|
|
|
|
my $self = shift; |
1780
|
|
|
|
|
|
|
my $model = shift; |
1781
|
1
|
50
|
|
1
|
|
551
|
my $bind = shift; |
1782
|
1
|
|
|
|
|
44
|
my $path = $self->children->[0]; |
1783
|
|
|
|
|
|
|
my $subject = $self->subject; |
1784
|
1
|
|
|
|
|
33
|
my $object = $self->object; |
1785
|
1
|
|
|
|
|
5
|
my $graph = $self->graph; |
1786
|
|
|
|
|
|
|
my $start = $self->step_begin->value; |
1787
|
|
|
|
|
|
|
my $end = $self->step_end->value; |
1788
|
|
|
|
|
|
|
my $skip = $self->skip; |
1789
|
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
1790
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
for ($subject, $object) { |
1792
|
|
|
|
|
|
|
if ($_->does('Attean::API::Variable')) { |
1793
|
|
|
|
|
|
|
my $name = $_->value; |
1794
|
50
|
|
|
50
|
|
47405
|
if (my $node = $bind->value($name)) { |
|
50
|
|
|
|
|
164
|
|
|
50
|
|
|
|
|
248
|
|
1795
|
50
|
|
|
50
|
|
37395
|
$_ = $node; |
|
50
|
|
|
|
|
151
|
|
|
50
|
|
|
|
|
1879
|
|
1796
|
50
|
|
|
50
|
|
364
|
} |
|
50
|
|
|
|
|
104
|
|
|
50
|
|
|
|
|
399
|
|
1797
|
50
|
|
|
50
|
|
27828
|
} |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
344
|
|
1798
|
|
|
|
|
|
|
} |
1799
|
|
|
|
|
|
|
|
1800
|
|
|
|
|
|
|
my $s_var = $subject->does('Attean::API::Variable'); |
1801
|
|
|
|
|
|
|
my $o_var = $object->does('Attean::API::Variable'); |
1802
|
|
|
|
|
|
|
if ($s_var and $o_var) { |
1803
|
|
|
|
|
|
|
return sub { |
1804
|
|
|
|
|
|
|
my $nodes = $model->graph_nodes($graph); |
1805
|
|
|
|
|
|
|
my @rows; |
1806
|
|
|
|
|
|
|
while (my $n = $nodes->next) { |
1807
|
|
|
|
|
|
|
my %seen; |
1808
|
|
|
|
|
|
|
alp($model, $graph, $skip, $n, $path, \%seen, $start, $end, $bind); |
1809
|
0
|
|
|
0
|
0
|
0
|
foreach my $term (values %seen) { |
1810
|
|
|
|
|
|
|
my $b = Attean::Result->new( bindings => { |
1811
|
|
|
|
|
|
|
$subject->value => $n, |
1812
|
|
|
|
|
|
|
$object->value => $term, |
1813
|
0
|
|
|
0
|
0
|
0
|
} ); |
1814
|
0
|
|
|
|
|
0
|
push(@rows, $b); |
1815
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1816
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
1817
|
0
|
|
|
|
|
0
|
return Attean::ListIterator->new( |
1818
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
1819
|
|
|
|
|
|
|
variables => $iter_variables, |
1820
|
|
|
|
|
|
|
values => \@rows, |
1821
|
0
|
|
|
0
|
0
|
0
|
); |
1822
|
0
|
|
|
|
|
0
|
}; |
1823
|
0
|
|
|
|
|
0
|
} elsif ($o_var) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1824
|
|
|
|
|
|
|
return sub { |
1825
|
0
|
0
|
|
|
|
0
|
my %seen; |
1826
|
0
|
|
|
|
|
0
|
alp($model, $graph, $skip, $subject, $path, \%seen, $start, $end, $bind); |
1827
|
|
|
|
|
|
|
my @rows = map { Attean::Result->new( bindings => { $object->value => $_ } ) } (values %seen); |
1828
|
0
|
|
|
|
|
0
|
return Attean::ListIterator->new( |
1829
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
1830
|
0
|
|
|
|
|
0
|
variables => $iter_variables, |
1831
|
|
|
|
|
|
|
values => \@rows, |
1832
|
|
|
|
|
|
|
); |
1833
|
|
|
|
|
|
|
}; |
1834
|
0
|
|
|
0
|
0
|
0
|
} elsif ($s_var) { |
1835
|
0
|
|
|
|
|
0
|
die "ALP for FB should never occur in a plan (should be inversed during planning)"; |
1836
|
0
|
|
|
|
|
0
|
} else { |
1837
|
0
|
|
|
|
|
0
|
return sub { |
1838
|
0
|
|
|
|
|
0
|
my %seen; |
1839
|
0
|
|
|
|
|
0
|
alp($model, $graph, $skip, $subject, $path, \%seen, $start, $end, $bind); |
1840
|
0
|
|
|
|
|
0
|
if (exists $seen{ $object->as_string }) { |
1841
|
0
|
|
|
|
|
0
|
return Attean::ListIterator->new( |
1842
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Result', |
1843
|
0
|
0
|
|
|
|
0
|
variables => $iter_variables, |
1844
|
0
|
|
|
|
|
0
|
values => [Attean::Result->new()] |
1845
|
|
|
|
|
|
|
); |
1846
|
0
|
|
|
|
|
0
|
} else { |
1847
|
0
|
0
|
|
|
|
0
|
return Attean::ListIterator->new( |
1848
|
0
|
|
|
|
|
0
|
item_type => 'Attean::API::Result', |
1849
|
|
|
|
|
|
|
variables => $iter_variables, |
1850
|
|
|
|
|
|
|
values => [] |
1851
|
0
|
0
|
|
|
|
0
|
); |
1852
|
0
|
|
|
|
|
0
|
} |
1853
|
|
|
|
|
|
|
}; |
1854
|
0
|
|
|
|
|
0
|
} |
1855
|
|
|
|
|
|
|
} |
1856
|
|
|
|
|
|
|
} |
1857
|
0
|
|
|
|
|
0
|
|
1858
|
0
|
|
|
|
|
0
|
use Moo; |
1859
|
0
|
|
|
|
|
0
|
use Attean::TreeRewriter; |
1860
|
0
|
|
|
|
|
0
|
use Types::Standard qw(ArrayRef ConsumerOf); |
1861
|
0
|
|
|
|
|
0
|
use namespace::clean; |
1862
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
has 'subject' => (is => 'ro', required => 1); |
1864
|
|
|
|
|
|
|
has 'object' => (is => 'ro', required => 1); |
1865
|
|
|
|
|
|
|
has 'graph' => (is => 'ro', required => 1); |
1866
|
0
|
|
|
0
|
0
|
0
|
|
1867
|
0
|
|
|
|
|
0
|
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::NullaryQueryTree'; |
1868
|
0
|
|
|
|
|
0
|
|
1869
|
0
|
|
|
|
|
0
|
my $class = shift; |
1870
|
0
|
|
|
|
|
0
|
my %args = @_; |
1871
|
0
|
|
|
|
|
0
|
my @vars = map { $_->value } grep { $_->does('Attean::API::Variable') } (@args{qw(subject object)}); |
1872
|
0
|
|
|
|
|
0
|
|
1873
|
0
|
|
|
|
|
0
|
if (exists $args{in_scope_variables}) { |
1874
|
0
|
|
|
|
|
0
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
1875
|
0
|
|
|
|
|
0
|
} |
1876
|
0
|
|
|
|
|
0
|
$args{in_scope_variables} = \@vars; |
1877
|
|
|
|
|
|
|
|
1878
|
0
|
|
|
|
|
0
|
return $class->SUPER::BUILDARGS(%args); |
1879
|
0
|
0
|
|
|
|
0
|
} |
1880
|
0
|
|
|
|
|
0
|
|
1881
|
0
|
0
|
|
|
|
0
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1882
|
0
|
|
|
|
|
0
|
|
1883
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
my $self = shift; |
1885
|
|
|
|
|
|
|
my $model = shift; |
1886
|
|
|
|
|
|
|
my $bind = shift; |
1887
|
0
|
|
|
|
|
0
|
my ($impl) = map { $_->substitute_impl($model, $bind) } @{ $self->children }; |
1888
|
0
|
|
|
|
|
0
|
my $iter_variables = $self->in_scope_variables; |
1889
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
my $subject = $self->subject; |
1891
|
0
|
|
|
0
|
|
0
|
my $object = $self->object; |
1892
|
0
|
|
|
|
|
0
|
my $graph = $self->graph; |
1893
|
0
|
|
|
|
|
0
|
for ($subject, $object) { |
1894
|
0
|
|
|
|
|
0
|
if ($_->does('Attean::API::Variable')) { |
1895
|
0
|
|
|
|
|
0
|
my $name = $_->value; |
1896
|
0
|
|
|
|
|
0
|
if (my $node = $bind->value($name)) { |
1897
|
0
|
|
|
|
|
0
|
$_ = $node; |
1898
|
|
|
|
|
|
|
} |
1899
|
|
|
|
|
|
|
} |
1900
|
|
|
|
|
|
|
} |
1901
|
0
|
|
|
|
|
0
|
|
1902
|
|
|
|
|
|
|
my $s_var = $subject->does('Attean::API::Variable'); |
1903
|
|
|
|
|
|
|
my $o_var = $object->does('Attean::API::Variable'); |
1904
|
0
|
|
|
|
|
0
|
return sub { |
1905
|
|
|
|
|
|
|
my @extra; |
1906
|
|
|
|
|
|
|
if ($s_var and $o_var) { |
1907
|
|
|
|
|
|
|
my $nodes = $model->graph_nodes($graph); |
1908
|
|
|
|
|
|
|
while (my $n = $nodes->next) { |
1909
|
0
|
|
|
|
|
0
|
push(@extra, Attean::Result->new( bindings => { map { $_->value => $n } ($subject, $object) } )); |
1910
|
|
|
|
|
|
|
} |
1911
|
|
|
|
|
|
|
} elsif ($s_var) { |
1912
|
0
|
|
|
0
|
|
0
|
push(@extra, Attean::Result->new( bindings => { $subject->value => $object } )); |
1913
|
0
|
|
|
|
|
0
|
} elsif ($o_var) { |
1914
|
0
|
|
|
|
|
0
|
push(@extra, Attean::Result->new( bindings => { $object->value => $subject } )); |
|
0
|
|
|
|
|
0
|
|
1915
|
0
|
|
|
|
|
0
|
} else { |
1916
|
|
|
|
|
|
|
if (0 == $subject->compare($object)) { |
1917
|
|
|
|
|
|
|
push(@extra, Attean::Result->new( bindings => {} )); |
1918
|
|
|
|
|
|
|
} |
1919
|
|
|
|
|
|
|
} |
1920
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1921
|
|
|
|
|
|
|
my %seen; |
1922
|
0
|
|
|
|
|
0
|
return Attean::CodeIterator->new( |
1923
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
1924
|
|
|
|
|
|
|
variables => $iter_variables, |
1925
|
0
|
|
|
0
|
|
0
|
generator => sub { |
1926
|
0
|
|
|
|
|
0
|
while (scalar(@extra)) { |
1927
|
0
|
0
|
|
|
|
0
|
my $r = shift(@extra); |
1928
|
0
|
|
|
|
|
0
|
unless ($seen{$r->as_string}++) { |
1929
|
|
|
|
|
|
|
return $r; |
1930
|
|
|
|
|
|
|
} |
1931
|
|
|
|
|
|
|
} |
1932
|
|
|
|
|
|
|
while (my $r = $iter->next()) { |
1933
|
|
|
|
|
|
|
return unless ($r); |
1934
|
0
|
|
|
|
|
0
|
if ($seen{$r->as_string}++) { |
1935
|
|
|
|
|
|
|
next; |
1936
|
|
|
|
|
|
|
} |
1937
|
|
|
|
|
|
|
return $r; |
1938
|
|
|
|
|
|
|
} |
1939
|
|
|
|
|
|
|
} |
1940
|
0
|
|
|
|
|
0
|
); |
1941
|
|
|
|
|
|
|
}; |
1942
|
|
|
|
|
|
|
} |
1943
|
|
|
|
|
|
|
} |
1944
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
=item * L<Attean::Plan::Exists> |
1946
|
50
|
|
|
50
|
|
78839
|
|
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
253
|
|
1947
|
50
|
|
|
50
|
|
16726
|
Returns an iterator containing a single boolean term indicating whether any |
|
50
|
|
|
|
|
140
|
|
|
50
|
|
|
|
|
1405
|
|
1948
|
50
|
|
|
50
|
|
292
|
results were produced by evaluating the sub-plan. |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
298
|
|
1949
|
50
|
|
|
50
|
|
28484
|
|
|
50
|
|
|
|
|
131
|
|
|
50
|
|
|
|
|
243
|
|
1950
|
|
|
|
|
|
|
=cut |
1951
|
|
|
|
|
|
|
|
1952
|
|
|
|
|
|
|
use Moo; |
1953
|
|
|
|
|
|
|
use Types::Standard qw(ArrayRef ConsumerOf); |
1954
|
|
|
|
|
|
|
use namespace::clean; |
1955
|
|
|
|
|
|
|
|
1956
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1957
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
1958
|
0
|
|
|
0
|
0
|
0
|
|
1959
|
0
|
|
|
|
|
0
|
has variables => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']]); |
1960
|
0
|
|
|
|
|
0
|
has rows => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Result']]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1961
|
|
|
|
|
|
|
|
1962
|
0
|
0
|
|
|
|
0
|
|
1963
|
0
|
|
|
|
|
0
|
my $self = shift; |
1964
|
|
|
|
|
|
|
my $model = shift; |
1965
|
0
|
|
|
|
|
0
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
1966
|
|
|
|
|
|
|
return sub { |
1967
|
0
|
|
|
|
|
0
|
my $iter = $impl->(); |
1968
|
|
|
|
|
|
|
my $term = ($iter->next) ? Attean::Literal->true : Attean::Literal->false; |
1969
|
|
|
|
|
|
|
return Attean::ListIterator->new(values => [$term], item_type => 'Attean::API::Term'); |
1970
|
0
|
|
|
0
|
0
|
0
|
} |
1971
|
|
|
|
|
|
|
} |
1972
|
|
|
|
|
|
|
} |
1973
|
0
|
|
|
0
|
0
|
0
|
|
1974
|
|
|
|
|
|
|
=item * L<Attean::Plan::Aggregate> |
1975
|
|
|
|
|
|
|
|
1976
|
0
|
|
|
0
|
0
|
0
|
=cut |
1977
|
0
|
|
|
|
|
0
|
|
1978
|
0
|
|
|
|
|
0
|
use Moo; |
1979
|
0
|
|
|
|
|
0
|
use Encode; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1980
|
0
|
|
|
|
|
0
|
use UUID::Tiny ':std'; |
1981
|
|
|
|
|
|
|
use URI::Escape; |
1982
|
0
|
|
|
|
|
0
|
use I18N::LangTags; |
1983
|
0
|
|
|
|
|
0
|
use POSIX qw(ceil floor); |
1984
|
0
|
|
|
|
|
0
|
use Digest::SHA; |
1985
|
0
|
|
|
|
|
0
|
use Digest::MD5 qw(md5_hex); |
1986
|
0
|
0
|
|
|
|
0
|
use Scalar::Util qw(blessed); |
1987
|
0
|
|
|
|
|
0
|
use List::MoreUtils qw(uniq); |
1988
|
0
|
0
|
|
|
|
0
|
use Types::Standard qw(ConsumerOf InstanceOf HashRef ArrayRef); |
1989
|
0
|
|
|
|
|
0
|
use namespace::clean; |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
1992
|
|
|
|
|
|
|
has 'aggregates' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Expression']], required => 1); |
1993
|
|
|
|
|
|
|
has 'groups' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Expression']], required => 1); |
1994
|
0
|
|
|
|
|
0
|
|
1995
|
0
|
|
|
|
|
0
|
my $self = shift; |
1996
|
|
|
|
|
|
|
my @astrings = map { sprintf('?%s ← %s', $_, $self->aggregates->{$_}->as_string) } keys %{ $self->aggregates }; |
1997
|
0
|
|
|
0
|
|
0
|
my @gstrings = map { sprintf('%s', $_->as_string) } @{ $self->groups }; |
1998
|
0
|
0
|
0
|
|
|
0
|
return sprintf('Aggregate { %s } Groups { %s }', join(', ', @astrings), join(', ', @gstrings)); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1999
|
0
|
|
|
|
|
0
|
} |
2000
|
0
|
|
|
|
|
0
|
|
2001
|
0
|
|
|
|
|
0
|
my $class = shift; |
|
0
|
|
|
|
|
0
|
|
2002
|
|
|
|
|
|
|
my %args = @_; |
2003
|
|
|
|
|
|
|
my $aggs = $args{ aggregates }; |
2004
|
0
|
|
|
|
|
0
|
my @vars = map { $_->value } grep { $_->does('Attean::API::Variable') } map { $_->value } @{ $args{groups} // [] }; |
2005
|
|
|
|
|
|
|
my @evars = (@vars, keys %$aggs); |
2006
|
0
|
|
|
|
|
0
|
if (exists $args{in_scope_variables}) { |
2007
|
|
|
|
|
|
|
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor"; |
2008
|
0
|
0
|
|
|
|
0
|
} |
2009
|
0
|
|
|
|
|
0
|
$args{in_scope_variables} = [@evars]; |
2010
|
|
|
|
|
|
|
return $class->SUPER::BUILDARGS(%args); |
2011
|
|
|
|
|
|
|
} |
2012
|
0
|
|
|
|
|
0
|
|
2013
|
0
|
|
|
|
|
0
|
my $self = shift; |
2014
|
|
|
|
|
|
|
my $model = shift; |
2015
|
|
|
|
|
|
|
my $expr = shift; |
2016
|
|
|
|
|
|
|
my $rows = shift; |
2017
|
|
|
|
|
|
|
my $op = $expr->operator; |
2018
|
0
|
|
|
|
|
0
|
my ($e) = @{ $expr->children }; |
2019
|
0
|
|
|
|
|
0
|
# my @children = map { Attean::Plan::Extend->evaluate_expression($model, $_, $r) } @{ $expr->children }; |
2020
|
0
|
0
|
|
|
|
0
|
# warn "$op — " . join(' ', map { $_->as_string } @children); |
2021
|
0
|
|
|
|
|
0
|
if ($op eq 'COUNT') { |
2022
|
|
|
|
|
|
|
my $count = 0; |
2023
|
|
|
|
|
|
|
foreach my $r (@$rows) { |
2024
|
0
|
|
|
|
|
0
|
if ($e) { |
2025
|
0
|
0
|
|
|
|
0
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
2026
|
0
|
0
|
|
|
|
0
|
if ($term) { |
2027
|
0
|
|
|
|
|
0
|
$count++; |
2028
|
|
|
|
|
|
|
} |
2029
|
0
|
|
|
|
|
0
|
} else { |
2030
|
|
|
|
|
|
|
# This is the special-case branch for COUNT(*) |
2031
|
|
|
|
|
|
|
$count++; |
2032
|
0
|
|
|
|
|
0
|
} |
2033
|
0
|
|
|
|
|
0
|
} |
2034
|
|
|
|
|
|
|
return Attean::Literal->new(value => $count, datatype => 'http://www.w3.org/2001/XMLSchema#integer'); |
2035
|
|
|
|
|
|
|
} elsif ($op eq 'SUM') { |
2036
|
|
|
|
|
|
|
my @cmp; |
2037
|
|
|
|
|
|
|
my @terms; |
2038
|
|
|
|
|
|
|
foreach my $r (@$rows) { |
2039
|
|
|
|
|
|
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
2040
|
|
|
|
|
|
|
if ($term->does('Attean::API::NumericLiteral')) { |
2041
|
|
|
|
|
|
|
push(@terms, $term); |
2042
|
|
|
|
|
|
|
} |
2043
|
|
|
|
|
|
|
} |
2044
|
|
|
|
|
|
|
my $lhs = shift(@terms); |
2045
|
50
|
|
|
50
|
|
59104
|
while (my $rhs = shift(@terms)) { |
|
50
|
|
|
|
|
164
|
|
|
50
|
|
|
|
|
247
|
|
2046
|
50
|
|
|
50
|
|
15863
|
my $type = $lhs->binary_promotion_type($rhs, '+'); |
|
50
|
|
|
|
|
170
|
|
|
50
|
|
|
|
|
341
|
|
2047
|
50
|
|
|
50
|
|
27180
|
my ($lv, $rv) = map { $_->numeric_value } ($lhs, $rhs); |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
257
|
|
2048
|
|
|
|
|
|
|
$lhs = Attean::Literal->new(value => ($lv + $rv), datatype => $type); |
2049
|
|
|
|
|
|
|
} |
2050
|
|
|
|
|
|
|
return $lhs; |
2051
|
|
|
|
|
|
|
} elsif ($op eq 'AVG') { |
2052
|
|
|
|
|
|
|
my @cmp; |
2053
|
|
|
|
|
|
|
my $count = 0; |
2054
|
|
|
|
|
|
|
my $all_ints = 1; |
2055
|
0
|
|
|
0
|
0
|
0
|
my @terms; |
2056
|
0
|
|
|
0
|
0
|
0
|
foreach my $r (@$rows) { |
2057
|
|
|
|
|
|
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
2058
|
|
|
|
|
|
|
die unless ($term->does('Attean::API::NumericLiteral')); |
2059
|
4
|
|
|
4
|
0
|
10
|
push(@terms, $term); |
2060
|
4
|
|
|
|
|
10
|
$count++; |
2061
|
4
|
|
|
|
|
8
|
} |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
19
|
|
2062
|
|
|
|
|
|
|
my $lhs = shift(@terms); |
2063
|
4
|
|
|
4
|
|
12
|
while (my $rhs = shift(@terms)) { |
2064
|
4
|
100
|
|
|
|
2441
|
my $type = $lhs->binary_promotion_type($rhs, '+'); |
2065
|
4
|
|
|
|
|
150
|
my ($lv, $rv) = map { $_->numeric_value } ($lhs, $rhs); |
2066
|
|
|
|
|
|
|
$lhs = Attean::Literal->new(value => ($lv + $rv), datatype => $type); |
2067
|
4
|
|
|
|
|
21
|
} |
2068
|
|
|
|
|
|
|
|
2069
|
|
|
|
|
|
|
my $rhs = Attean::Literal->new(value => $count, datatype => 'http://www.w3.org/2001/XMLSchema#integer'); |
2070
|
|
|
|
|
|
|
my ($lv, $rv) = map { $_->numeric_value } ($lhs, $rhs); |
2071
|
|
|
|
|
|
|
my $type = $lhs->binary_promotion_type($rhs, '/'); |
2072
|
|
|
|
|
|
|
return Attean::Literal->new(value => ($lv / $rv), datatype => $type); |
2073
|
|
|
|
|
|
|
} elsif ($op eq 'SAMPLE') { |
2074
|
|
|
|
|
|
|
foreach my $r (@$rows) { |
2075
|
50
|
|
|
50
|
|
36093
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
|
50
|
|
|
|
|
129
|
|
|
50
|
|
|
|
|
265
|
|
2076
|
50
|
|
|
50
|
|
15299
|
return $term if (blessed($term)); |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
4149
|
|
2077
|
50
|
|
|
50
|
|
323
|
} |
|
50
|
|
|
|
|
131
|
|
|
50
|
|
|
|
|
9793
|
|
2078
|
50
|
|
|
50
|
|
358
|
} elsif ($op =~ /^(MIN|MAX)$/) { |
|
50
|
|
|
|
|
106
|
|
|
50
|
|
|
|
|
2512
|
|
2079
|
50
|
|
|
50
|
|
308
|
my @cmp; |
|
50
|
|
|
|
|
123
|
|
|
50
|
|
|
|
|
1873
|
|
2080
|
50
|
|
|
50
|
|
338
|
foreach my $r (@$rows) { |
|
50
|
|
|
|
|
131
|
|
|
50
|
|
|
|
|
417
|
|
2081
|
50
|
|
|
50
|
|
3671
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
|
50
|
|
|
|
|
115
|
|
|
50
|
|
|
|
|
1959
|
|
2082
|
50
|
|
|
50
|
|
289
|
push(@cmp, $term); |
|
50
|
|
|
|
|
125
|
|
|
50
|
|
|
|
|
2096
|
|
2083
|
50
|
|
|
50
|
|
325
|
} |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
2114
|
|
2084
|
50
|
|
|
50
|
|
331
|
@cmp = sort { $a->compare($b) } @cmp; |
|
50
|
|
|
|
|
116
|
|
|
50
|
|
|
|
|
450
|
|
2085
|
50
|
|
|
50
|
|
46605
|
return ($op eq 'MIN') ? shift(@cmp) : pop(@cmp); |
|
50
|
|
|
|
|
110
|
|
|
50
|
|
|
|
|
231
|
|
2086
|
50
|
|
|
50
|
|
36183
|
} elsif ($op eq 'GROUP_CONCAT') { |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
256
|
|
2087
|
|
|
|
|
|
|
my $sep = $expr->scalar_vars->{seperator} // ' '; |
2088
|
|
|
|
|
|
|
my @values; |
2089
|
|
|
|
|
|
|
foreach my $r (@$rows) { |
2090
|
|
|
|
|
|
|
my $term = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
2091
|
|
|
|
|
|
|
push(@values, $term->value); |
2092
|
|
|
|
|
|
|
} |
2093
|
0
|
|
|
0
|
0
|
0
|
my $string = join($sep, @values); |
2094
|
0
|
|
|
|
|
0
|
return Attean::Literal->new(value => $string); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2095
|
0
|
|
|
|
|
0
|
} elsif ($op eq 'CUSTOM') { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2096
|
0
|
|
|
|
|
0
|
my $iri = $expr->custom_iri; |
2097
|
|
|
|
|
|
|
my $data = Attean->get_global_aggregate($iri); |
2098
|
0
|
|
|
0
|
0
|
0
|
unless ($data) { |
2099
|
|
|
|
|
|
|
die "No extension aggregate registered for <$iri>"; |
2100
|
|
|
|
|
|
|
} |
2101
|
4
|
|
|
4
|
0
|
4616
|
my $start = $data->{'start'}; |
2102
|
4
|
|
|
|
|
13
|
my $process = $data->{'process'}; |
2103
|
4
|
|
|
|
|
9
|
my $finalize = $data->{'finalize'}; |
2104
|
4
|
|
50
|
|
|
4
|
|
|
4
|
|
|
|
|
70
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
14
|
|
2105
|
4
|
|
|
|
|
11
|
my $thunk = $start->(); |
2106
|
4
|
50
|
|
|
|
9
|
foreach my $r (@$rows) { |
2107
|
0
|
|
|
|
|
0
|
my $t = Attean::Plan::Extend->evaluate_expression($model, $e, $r); |
2108
|
|
|
|
|
|
|
$process->($thunk, $t); |
2109
|
4
|
|
|
|
|
10
|
} |
2110
|
4
|
|
|
|
|
46
|
return $finalize->($thunk); |
2111
|
|
|
|
|
|
|
} |
2112
|
|
|
|
|
|
|
die "$op not implemented"; |
2113
|
|
|
|
|
|
|
} |
2114
|
0
|
|
|
0
|
0
|
|
|
2115
|
0
|
|
|
|
|
|
my $self = shift; |
2116
|
0
|
|
|
|
|
|
my $model = shift; |
2117
|
0
|
|
|
|
|
|
my %aggs = %{ $self->aggregates }; |
2118
|
0
|
|
|
|
|
|
my @groups = @{ $self->groups }; |
2119
|
0
|
|
|
|
|
|
my $iter_variables = $self->in_scope_variables; |
|
0
|
|
|
|
|
|
|
2120
|
|
|
|
|
|
|
|
2121
|
|
|
|
|
|
|
my $group_template_generator = sub { |
2122
|
0
|
0
|
|
|
|
|
my $r = shift; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2123
|
0
|
|
|
|
|
|
my %components; |
2124
|
0
|
|
|
|
|
|
foreach my $g (@groups) { |
2125
|
0
|
0
|
|
|
|
|
if ($g->isa('Attean::ValueExpression')) { |
2126
|
0
|
|
|
|
|
|
my $value = $g->value; |
2127
|
0
|
0
|
|
|
|
|
if ($value->isa('Attean::Variable')) { |
2128
|
0
|
|
|
|
|
|
my $var = $value->value; |
2129
|
|
|
|
|
|
|
my $value = eval { Attean::Plan::Extend->evaluate_expression($model, $g, $r) }; |
2130
|
|
|
|
|
|
|
if (blessed($value)) { |
2131
|
|
|
|
|
|
|
$components{$var} = $value; |
2132
|
0
|
|
|
|
|
|
} |
2133
|
|
|
|
|
|
|
} |
2134
|
|
|
|
|
|
|
} |
2135
|
0
|
|
|
|
|
|
} |
2136
|
|
|
|
|
|
|
return %components; |
2137
|
0
|
|
|
|
|
|
}; |
2138
|
|
|
|
|
|
|
my $group_key_generator = sub { |
2139
|
0
|
|
|
|
|
|
my $r = shift; |
2140
|
0
|
|
|
|
|
|
my @components; |
2141
|
0
|
0
|
|
|
|
|
foreach my $g (@groups) { |
2142
|
0
|
|
|
|
|
|
my $value = eval { Attean::Plan::Extend->evaluate_expression($model, $g, $r) }; |
2143
|
|
|
|
|
|
|
my $key = blessed($value) ? $value->as_string : ''; |
2144
|
|
|
|
|
|
|
push(@components, $key); |
2145
|
0
|
|
|
|
|
|
} |
2146
|
0
|
|
|
|
|
|
my $group = join('|', @components); |
2147
|
0
|
|
|
|
|
|
return $group; |
2148
|
0
|
|
|
|
|
|
}; |
|
0
|
|
|
|
|
|
|
2149
|
0
|
|
|
|
|
|
|
2150
|
|
|
|
|
|
|
my $rank; |
2151
|
0
|
|
|
|
|
|
while (my($var, $agg) = each(%aggs)) { |
2152
|
|
|
|
|
|
|
if ($agg->operator eq 'RANK') { |
2153
|
0
|
|
|
|
|
|
$rank = $var; |
2154
|
0
|
|
|
|
|
|
} |
2155
|
0
|
|
|
|
|
|
} |
2156
|
0
|
|
|
|
|
|
|
2157
|
0
|
|
|
|
|
|
my ($impl) = map { $_->impl($model) } @{ $self->children }; |
2158
|
0
|
|
|
|
|
|
my %row_groups; |
2159
|
0
|
0
|
|
|
|
|
my %group_templates; |
2160
|
0
|
|
|
|
|
|
return sub { |
2161
|
0
|
|
|
|
|
|
my $iter = $impl->(); |
2162
|
|
|
|
|
|
|
while (my $r = $iter->next) { |
2163
|
0
|
|
|
|
|
|
my $group_key = $group_key_generator->($r); |
2164
|
0
|
|
|
|
|
|
push(@{ $row_groups{ $group_key } }, $r); |
2165
|
0
|
|
|
|
|
|
unless (exists $group_templates{ $group_key }) { |
2166
|
0
|
|
|
|
|
|
$group_templates{ $group_key } = { $group_template_generator->($r) }; |
|
0
|
|
|
|
|
|
|
2167
|
0
|
|
|
|
|
|
} |
2168
|
|
|
|
|
|
|
} |
2169
|
|
|
|
|
|
|
my @group_keys = keys %row_groups; |
2170
|
0
|
|
|
|
|
|
|
2171
|
0
|
|
|
|
|
|
# SPARQL evaluation of aggregates over an empty input sequence should |
|
0
|
|
|
|
|
|
|
2172
|
0
|
|
|
|
|
|
# result in an empty result <http://answers.semanticweb.com/questions/17410/semantics-of-sparql-aggregates> |
2173
|
0
|
|
|
|
|
|
|
2174
|
|
|
|
|
|
|
my @results; |
2175
|
0
|
|
|
|
|
|
if (scalar(@group_keys) == 0 and scalar(@groups) == 0) { |
2176
|
0
|
|
|
|
|
|
push(@group_keys, ''); |
2177
|
0
|
0
|
|
|
|
|
$row_groups{''} = []; |
2178
|
|
|
|
|
|
|
$group_templates{''} = {}; |
2179
|
|
|
|
|
|
|
} |
2180
|
0
|
|
|
|
|
|
foreach my $group (@group_keys) { |
2181
|
0
|
|
|
|
|
|
my %row = %{ $group_templates{ $group } }; |
2182
|
0
|
|
|
|
|
|
my $rows = $row_groups{$group}; |
2183
|
0
|
|
|
|
|
|
if (defined $rank) { |
2184
|
|
|
|
|
|
|
my $agg = $aggs{$rank}; |
2185
|
0
|
|
|
|
|
|
my $ascending = $agg->scalar_vars->{ascending} // {}; |
|
0
|
|
|
|
|
|
|
2186
|
0
|
0
|
|
|
|
|
my $vars = [map { $_->value->value } @{ $agg->children }]; |
2187
|
|
|
|
|
|
|
# TODO: support ordering by complex expressions in $vars, not just ValueExpressions with variables |
2188
|
0
|
|
0
|
|
|
|
my @sorted = Attean::Plan::OrderBy->sort_rows($vars, $ascending, $rows); |
2189
|
0
|
|
|
|
|
|
my $ord = 0; |
2190
|
0
|
|
|
|
|
|
foreach my $row (@sorted) { |
2191
|
0
|
|
|
|
|
|
my %b = %{ $row->bindings }; |
2192
|
0
|
|
|
|
|
|
$b{ $rank } = Attean::Literal->integer($ord++); |
2193
|
|
|
|
|
|
|
my $r = Attean::Result->new( bindings => \%b ); |
2194
|
0
|
|
|
|
|
|
push(@results, $r); |
2195
|
0
|
|
|
|
|
|
} |
2196
|
|
|
|
|
|
|
} else { |
2197
|
0
|
|
|
|
|
|
foreach my $var (keys %aggs) { |
2198
|
0
|
|
|
|
|
|
my $expr = $aggs{$var}; |
2199
|
0
|
0
|
|
|
|
|
my $value = eval { $self->evaluate_aggregate($model, $expr, $rows) }; |
2200
|
0
|
|
|
|
|
|
if ($value) { |
2201
|
|
|
|
|
|
|
$row{$var} = $value; |
2202
|
0
|
|
|
|
|
|
} |
2203
|
0
|
|
|
|
|
|
} |
2204
|
0
|
|
|
|
|
|
my $result = Attean::Result->new( bindings => \%row ); |
2205
|
|
|
|
|
|
|
push(@results, $result); |
2206
|
0
|
|
|
|
|
|
} |
2207
|
0
|
|
|
|
|
|
} |
2208
|
0
|
|
|
|
|
|
return Attean::ListIterator->new( |
2209
|
0
|
|
|
|
|
|
values => \@results, |
2210
|
|
|
|
|
|
|
variables => $iter_variables, |
2211
|
0
|
|
|
|
|
|
item_type => 'Attean::API::Result' |
2212
|
|
|
|
|
|
|
); |
2213
|
0
|
|
|
|
|
|
}; |
2214
|
|
|
|
|
|
|
} |
2215
|
|
|
|
|
|
|
} |
2216
|
|
|
|
|
|
|
|
2217
|
0
|
|
|
0
|
0
|
|
use Moo; |
2218
|
0
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
2219
|
0
|
|
|
|
|
|
use Types::Standard qw(ConsumerOf ArrayRef); |
|
0
|
|
|
|
|
|
|
2220
|
0
|
|
|
|
|
|
use namespace::clean; |
|
0
|
|
|
|
|
|
|
2221
|
0
|
|
|
|
|
|
|
2222
|
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::QueryTree'; |
2223
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
2224
|
0
|
|
|
0
|
|
|
|
2225
|
0
|
|
|
|
|
|
|
2226
|
0
|
|
|
|
|
|
my $self = shift; |
2227
|
0
|
0
|
|
|
|
|
my $model = shift; |
2228
|
0
|
|
|
|
|
|
my @children = map { $_->impl($model) } @{ $self->children }; |
2229
|
0
|
0
|
|
|
|
|
return sub { |
2230
|
0
|
|
|
|
|
|
foreach my $child (@children) { |
2231
|
0
|
|
|
|
|
|
my $iter = $child->(); |
|
0
|
|
|
|
|
|
|
2232
|
0
|
0
|
|
|
|
|
$iter->elements; |
2233
|
0
|
|
|
|
|
|
} |
2234
|
|
|
|
|
|
|
return Attean::ListIterator->new(values => [Attean::Literal->true], item_type => 'Attean::API::Term'); |
2235
|
|
|
|
|
|
|
}; |
2236
|
|
|
|
|
|
|
} |
2237
|
|
|
|
|
|
|
} |
2238
|
0
|
|
|
|
|
|
|
2239
|
0
|
|
|
|
|
|
use Moo; |
2240
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
2241
|
0
|
|
|
0
|
|
|
use Types::Standard qw(ConsumerOf ArrayRef); |
2242
|
0
|
|
|
|
|
|
use namespace::clean; |
2243
|
0
|
|
|
|
|
|
|
2244
|
0
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::NullaryQueryTree'; |
|
0
|
|
|
|
|
|
|
2245
|
0
|
0
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
2246
|
0
|
|
|
|
|
|
|
2247
|
|
|
|
|
|
|
has 'graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Term']]); |
2248
|
0
|
|
|
|
|
|
|
2249
|
0
|
|
|
|
|
|
my $self = shift; |
2250
|
0
|
|
|
|
|
|
my $level = shift; |
2251
|
|
|
|
|
|
|
my $indent = ' ' x (1+$level); |
2252
|
0
|
|
|
|
|
|
my $s = sprintf("Clear { %d graphs }", scalar(@{ $self->graphs })); |
2253
|
0
|
|
|
|
|
|
foreach my $g (@{ $self->graphs }) { |
2254
|
0
|
0
|
|
|
|
|
my $name = $g->as_sparql; |
2255
|
0
|
|
|
|
|
|
chomp($name); |
2256
|
|
|
|
|
|
|
$s .= "\n-${indent} $name"; |
2257
|
|
|
|
|
|
|
} |
2258
|
|
|
|
|
|
|
return $s; |
2259
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
2260
|
0
|
|
|
|
|
|
|
2261
|
|
|
|
|
|
|
my $self = shift; |
2262
|
|
|
|
|
|
|
my $model = shift; |
2263
|
0
|
|
|
0
|
|
|
my $graphs = $self->graphs; |
2264
|
0
|
|
|
|
|
|
return sub { |
2265
|
0
|
|
|
|
|
|
foreach my $g (@$graphs) { |
2266
|
0
|
|
|
|
|
|
$model->clear_graph($g); |
|
0
|
|
|
|
|
|
|
2267
|
0
|
0
|
|
|
|
|
} |
2268
|
0
|
|
|
|
|
|
return Attean::ListIterator->new(values => [Attean::Literal->true], item_type => 'Attean::API::Term'); |
2269
|
|
|
|
|
|
|
}; |
2270
|
|
|
|
|
|
|
} |
2271
|
0
|
|
|
|
|
|
} |
2272
|
|
|
|
|
|
|
|
2273
|
|
|
|
|
|
|
use Moo; |
2274
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
2275
|
|
|
|
|
|
|
use Types::Standard qw(ConsumerOf ArrayRef); |
2276
|
0
|
|
|
|
|
|
use namespace::clean; |
2277
|
0
|
0
|
0
|
|
|
|
|
2278
|
0
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::NullaryQueryTree'; |
2279
|
0
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
2280
|
0
|
|
|
|
|
|
|
2281
|
|
|
|
|
|
|
has 'graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Term']]); |
2282
|
0
|
|
|
|
|
|
|
2283
|
0
|
|
|
|
|
|
my $self = shift; |
|
0
|
|
|
|
|
|
|
2284
|
0
|
|
|
|
|
|
my $level = shift; |
2285
|
0
|
0
|
|
|
|
|
my $indent = ' ' x (1+$level); |
2286
|
0
|
|
|
|
|
|
my $s = sprintf("Drop { %d graphs }", scalar(@{ $self->graphs })); |
2287
|
0
|
|
0
|
|
|
|
foreach my $g (@{ $self->graphs }) { |
2288
|
0
|
|
|
|
|
|
$s .= "\n-${indent} " . $g->as_sparql; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
2289
|
|
|
|
|
|
|
} |
2290
|
0
|
|
|
|
|
|
return $s; |
2291
|
0
|
|
|
|
|
|
} |
2292
|
0
|
|
|
|
|
|
|
2293
|
0
|
|
|
|
|
|
my $self = shift; |
|
0
|
|
|
|
|
|
|
2294
|
0
|
|
|
|
|
|
my $model = shift; |
2295
|
0
|
|
|
|
|
|
my $graphs = $self->graphs; |
2296
|
0
|
|
|
|
|
|
return sub { |
2297
|
|
|
|
|
|
|
foreach my $g (@$graphs) { |
2298
|
|
|
|
|
|
|
$model->drop_graph($g); |
2299
|
0
|
|
|
|
|
|
} |
2300
|
0
|
|
|
|
|
|
return Attean::ListIterator->new(values => [Attean::Literal->true], item_type => 'Attean::API::Term'); |
2301
|
0
|
|
|
|
|
|
}; |
|
0
|
|
|
|
|
|
|
2302
|
0
|
0
|
|
|
|
|
} |
2303
|
0
|
|
|
|
|
|
} |
2304
|
|
|
|
|
|
|
|
2305
|
|
|
|
|
|
|
use Moo; |
2306
|
0
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
2307
|
0
|
|
|
|
|
|
use Types::Standard qw(ConsumerOf Str ArrayRef HashRef); |
2308
|
|
|
|
|
|
|
use namespace::clean; |
2309
|
|
|
|
|
|
|
|
2310
|
0
|
|
|
|
|
|
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree'; |
2311
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
2312
|
|
|
|
|
|
|
|
2313
|
|
|
|
|
|
|
has 'order' => (is => 'ro', isa => ArrayRef[Str], required => 1); |
2314
|
|
|
|
|
|
|
has 'patterns' => (is => 'ro', isa => HashRef[ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']]], required => 1); |
2315
|
0
|
|
|
|
|
|
has 'graph' => (is => 'ro', isa => ConsumerOf['Attean::API::Term']); |
2316
|
|
|
|
|
|
|
|
2317
|
|
|
|
|
|
|
my $self = shift; |
2318
|
|
|
|
|
|
|
my $level = shift; |
2319
|
|
|
|
|
|
|
my $indent = ' ' x (1+$level); |
2320
|
50
|
|
|
50
|
|
195544
|
my $s = sprintf("Template-to-Model { Default graph: %s }", $self->graph->as_string); |
|
50
|
|
|
|
|
132
|
|
|
50
|
|
|
|
|
266
|
|
2321
|
50
|
|
|
50
|
|
15175
|
foreach my $method (@{ $self->order }) { |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
2424
|
|
2322
|
50
|
|
|
50
|
|
291
|
my $pattern = $self->patterns->{ $method }; |
|
50
|
|
|
|
|
107
|
|
|
50
|
|
|
|
|
292
|
|
2323
|
50
|
|
|
50
|
|
27174
|
$s .= "\n-${indent} Method: ${method}"; |
|
50
|
|
|
|
|
126
|
|
|
50
|
|
|
|
|
237
|
|
2324
|
|
|
|
|
|
|
foreach my $p (@$pattern) { |
2325
|
|
|
|
|
|
|
$s .= "\n-${indent} " . $p->as_string; |
2326
|
|
|
|
|
|
|
} |
2327
|
|
|
|
|
|
|
} |
2328
|
0
|
|
|
0
|
0
|
|
return $s; |
2329
|
|
|
|
|
|
|
} |
2330
|
|
|
|
|
|
|
|
2331
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
2332
|
0
|
|
|
|
|
|
my $model = shift; |
2333
|
0
|
|
|
|
|
|
my $child = $self->children->[0]->impl($model); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
2334
|
|
|
|
|
|
|
|
2335
|
0
|
|
|
0
|
|
|
my $graph = $self->graph; |
2336
|
0
|
|
|
|
|
|
my @order = @{ $self->order }; |
2337
|
0
|
|
|
|
|
|
my $method = shift(@order); |
2338
|
|
|
|
|
|
|
my $pattern = $self->patterns->{ $method }; |
2339
|
0
|
|
|
|
|
|
|
2340
|
0
|
|
|
|
|
|
return sub { |
2341
|
|
|
|
|
|
|
my $iter = $child->(); |
2342
|
|
|
|
|
|
|
my @results; |
2343
|
|
|
|
|
|
|
while (my $t = $iter->next) { |
2344
|
|
|
|
|
|
|
if (scalar(@order)) { |
2345
|
50
|
|
|
50
|
|
37305
|
push(@results, $t); |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
223
|
|
2346
|
50
|
|
|
50
|
|
15427
|
} |
|
50
|
|
|
|
|
129
|
|
|
50
|
|
|
|
|
2343
|
|
2347
|
50
|
|
|
50
|
|
330
|
foreach my $p (@$pattern) { |
|
50
|
|
|
|
|
132
|
|
|
50
|
|
|
|
|
294
|
|
2348
|
50
|
|
|
50
|
|
25777
|
my $q = $p->apply_bindings($t); |
|
50
|
|
|
|
|
106
|
|
|
50
|
|
|
|
|
230
|
|
2349
|
|
|
|
|
|
|
my $quad = $q->does('Attean::API::QuadPattern') ? $q : $q->as_quad_pattern($graph); |
2350
|
|
|
|
|
|
|
if ($quad->is_ground) { |
2351
|
|
|
|
|
|
|
# warn "# $method: " . $quad->as_string . "\n"; |
2352
|
|
|
|
|
|
|
$model->$method($quad->as_quad); |
2353
|
|
|
|
|
|
|
} else { |
2354
|
|
|
|
|
|
|
# warn "not ground: " . $quad->as_string; |
2355
|
|
|
|
|
|
|
} |
2356
|
0
|
|
|
0
|
0
|
|
} |
2357
|
0
|
|
|
|
|
|
} |
2358
|
0
|
|
|
|
|
|
foreach my $method (@order) { |
2359
|
0
|
|
|
|
|
|
my $pattern = $self->patterns->{ $method }; |
|
0
|
|
|
|
|
|
|
2360
|
0
|
|
|
|
|
|
foreach my $t (@results) { |
|
0
|
|
|
|
|
|
|
2361
|
0
|
|
|
|
|
|
foreach my $p (@$pattern) { |
2362
|
0
|
|
|
|
|
|
my $q = $p->apply_bindings($t); |
2363
|
0
|
|
|
|
|
|
my $quad = $q->does('Attean::API::QuadPattern') ? $q : $q->as_quad_pattern($graph); |
2364
|
|
|
|
|
|
|
if ($quad->is_ground) { |
2365
|
0
|
|
|
|
|
|
# warn "# $method: " . $quad->as_string . "\n"; |
2366
|
|
|
|
|
|
|
$model->$method($quad->as_quad); |
2367
|
|
|
|
|
|
|
} else { |
2368
|
|
|
|
|
|
|
# warn "not ground: " . $quad->as_string; |
2369
|
0
|
|
|
0
|
0
|
|
} |
2370
|
0
|
|
|
|
|
|
} |
2371
|
0
|
|
|
|
|
|
} |
2372
|
|
|
|
|
|
|
} |
2373
|
0
|
|
|
0
|
|
|
return Attean::ListIterator->new(values => [Attean::Literal->integer($model->size)], item_type => 'Attean::API::Term'); |
2374
|
0
|
|
|
|
|
|
}; |
2375
|
|
|
|
|
|
|
} |
2376
|
0
|
|
|
|
|
|
} |
2377
|
0
|
|
|
|
|
|
|
2378
|
|
|
|
|
|
|
use Moo; |
2379
|
|
|
|
|
|
|
use Encode; |
2380
|
|
|
|
|
|
|
use LWP::UserAgent; |
2381
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
2382
|
50
|
|
|
50
|
|
40025
|
use Types::Standard qw(Bool Str); |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
217
|
|
2383
|
50
|
|
|
50
|
|
15884
|
use namespace::clean; |
|
50
|
|
|
|
|
136
|
|
|
50
|
|
|
|
|
2423
|
|
2384
|
50
|
|
|
50
|
|
338
|
|
|
50
|
|
|
|
|
134
|
|
|
50
|
|
|
|
|
252
|
|
2385
|
50
|
|
|
50
|
|
25469
|
with 'Attean::API::Plan', 'Attean::API::NullaryQueryTree'; |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
260
|
|
2386
|
|
|
|
|
|
|
with 'Attean::API::UnionScopeVariablesPlan'; |
2387
|
|
|
|
|
|
|
|
2388
|
|
|
|
|
|
|
has 'silent' => (is => 'ro', isa => Bool, default => 0); |
2389
|
|
|
|
|
|
|
has 'url' => (is => 'ro', isa => Str); |
2390
|
|
|
|
|
|
|
|
2391
|
|
|
|
|
|
|
my $self = shift; |
2392
|
|
|
|
|
|
|
return sprintf("Load { %s }", $self->url); |
2393
|
0
|
|
|
0
|
0
|
|
} |
2394
|
0
|
|
|
|
|
|
|
2395
|
0
|
|
|
|
|
|
my $self = shift; |
2396
|
0
|
|
|
|
|
|
my $url = $self->url; |
|
0
|
|
|
|
|
|
|
2397
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(); |
|
0
|
|
|
|
|
|
|
2398
|
0
|
|
|
|
|
|
my $silent = $self->silent; |
2399
|
|
|
|
|
|
|
my $accept = Attean->acceptable_parsers( handles => 'Attean::API::Triple' ); |
2400
|
0
|
|
|
|
|
|
$ua->default_headers->push_header( 'Accept' => $accept ); |
2401
|
|
|
|
|
|
|
return sub { |
2402
|
|
|
|
|
|
|
my $resp = $ua->get( $url ); |
2403
|
|
|
|
|
|
|
if ($resp->is_success) { |
2404
|
0
|
|
|
0
|
0
|
|
my $ct = $resp->header('Content-Type'); |
2405
|
0
|
|
|
|
|
|
if (my $pclass = Attean->get_parser( media_type => $ct )) { |
2406
|
0
|
|
|
|
|
|
my $p = $pclass->new(); |
2407
|
|
|
|
|
|
|
my $str = $resp->decoded_content; |
2408
|
0
|
|
|
0
|
|
|
my $bytes = encode('UTF-8', $str, Encode::FB_CROAK); |
2409
|
0
|
|
|
|
|
|
my $iter = $p->parse_iter_from_bytes( $bytes ); |
2410
|
|
|
|
|
|
|
return $iter; |
2411
|
0
|
|
|
|
|
|
} |
2412
|
0
|
|
|
|
|
|
} |
2413
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
if ($silent) { |
2415
|
|
|
|
|
|
|
return Attean::ListIterator->new(values => [], item_type => 'Attean::API::Triple'); |
2416
|
|
|
|
|
|
|
} else { |
2417
|
50
|
|
|
50
|
|
40269
|
die "Failed to load url: " . $resp->status_line; |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
252
|
|
2418
|
50
|
|
|
50
|
|
15395
|
} |
|
50
|
|
|
|
|
127
|
|
|
50
|
|
|
|
|
2364
|
|
2419
|
50
|
|
|
50
|
|
344
|
}; |
|
50
|
|
|
|
|
121
|
|
|
50
|
|
|
|
|
255
|
|
2420
|
50
|
|
|
50
|
|
35864
|
} |
|
50
|
|
|
|
|
115
|
|
|
50
|
|
|
|
|
250
|
|
2421
|
|
|
|
|
|
|
} |
2422
|
|
|
|
|
|
|
|
2423
|
|
|
|
|
|
|
# Create(iri) |
2424
|
|
|
|
|
|
|
|
2425
|
|
|
|
|
|
|
1; |
2426
|
|
|
|
|
|
|
|
2427
|
|
|
|
|
|
|
|
2428
|
|
|
|
|
|
|
=back |
2429
|
|
|
|
|
|
|
|
2430
|
0
|
|
|
0
|
0
|
|
=head1 BUGS |
2431
|
0
|
|
|
|
|
|
|
2432
|
0
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
2433
|
0
|
|
|
|
|
|
at L<https://github.com/kasei/attean/issues>. |
2434
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
2435
|
0
|
|
|
|
|
|
=head1 SEE ALSO |
2436
|
0
|
|
|
|
|
|
|
2437
|
0
|
|
|
|
|
|
|
2438
|
0
|
|
|
|
|
|
|
2439
|
|
|
|
|
|
|
=head1 AUTHOR |
2440
|
|
|
|
|
|
|
|
2441
|
0
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
2442
|
|
|
|
|
|
|
|
2443
|
|
|
|
|
|
|
=head1 COPYRIGHT |
2444
|
|
|
|
|
|
|
|
2445
|
0
|
|
|
0
|
0
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. |
2446
|
0
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
2447
|
0
|
|
|
|
|
|
the same terms as Perl itself. |
2448
|
|
|
|
|
|
|
|
2449
|
0
|
|
|
|
|
|
=cut |