| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
AtteanX::Plan::SPARQLBGP - Plan for efficient evaluation of SPARQL BGPs on remote endpoints |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This is typically only constructed by planning hacks deep in the code, |
|
8
|
|
|
|
|
|
|
but might look like: |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use v5.14; |
|
11
|
|
|
|
|
|
|
use AtteanX::Plan::SPARQLBGP; |
|
12
|
|
|
|
|
|
|
my $new_bgp_plan = AtteanX::Plan::SPARQLBGP->new(children => [$some_quads], |
|
13
|
|
|
|
|
|
|
distinct => 0, |
|
14
|
|
|
|
|
|
|
ordered => []); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This plan class implements compiling basic graph patterns that can be |
|
19
|
|
|
|
|
|
|
joined remotely on a SPARQL endpoint. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Attributes and methods |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Consumes L<Attean::API::QueryTree>, L<Attean::API::Plan> and |
|
24
|
|
|
|
|
|
|
L<Attean::API::UnionScopeVariablesPlan>, and introduces nothing |
|
25
|
|
|
|
|
|
|
new. The most notable attribute is: |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item C<< children >> |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
which takes an arrayref of L<Attean::Plan::Quad> objects to be |
|
32
|
|
|
|
|
|
|
included in the Basic Graph pattern that will be evaluated against the |
|
33
|
|
|
|
|
|
|
model. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=back |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 OTHER DETAILS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
For author, copyright and other details, see L<AtteanX::Store::SPARQL>. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package AtteanX::Plan::SPARQLBGP; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
7
|
use v5.14; |
|
|
1
|
|
|
|
|
2
|
|
|
47
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
19
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
2
|
use Moo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
50
|
1
|
|
|
1
|
|
169
|
use Scalar::Util qw(blessed); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
182
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with 'Attean::API::QueryTree', |
|
53
|
|
|
|
|
|
|
'Attean::API::Plan', |
|
54
|
|
|
|
|
|
|
'Attean::API::UnionScopeVariablesPlan', |
|
55
|
|
|
|
|
|
|
'MooX::Log::Any'; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub plan_as_string { |
|
58
|
1
|
|
|
1
|
0
|
3031
|
my $self = shift; |
|
59
|
1
|
|
|
|
|
6
|
return 'SPARQLBGP'; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub impl { |
|
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
64
|
0
|
|
|
|
|
|
my $model = shift; |
|
65
|
0
|
|
|
|
|
|
my $sparql = 'SELECT * WHERE {'; |
|
66
|
0
|
|
|
|
|
|
foreach my $child (@{$self->children}) { |
|
|
0
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @terms = $child->values; |
|
68
|
0
|
|
|
|
|
|
my $pattern = Attean::TriplePattern->new(@terms[0..2]); |
|
69
|
0
|
|
|
|
|
|
$sparql .= "\n " . $pattern->as_sparql . ' . '; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
|
|
|
|
|
$sparql .= "\n}\n"; |
|
72
|
0
|
|
|
|
|
|
$self->log->debug("Using query:\n$sparql"); |
|
73
|
|
|
|
|
|
|
return sub { |
|
74
|
0
|
|
|
0
|
|
|
return $model->get_sparql($sparql) |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |