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
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KJETILK'; |
50
|
|
|
|
|
|
|
our $VERSION = '0.010'; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
53
|
1
|
|
|
1
|
|
175
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
175
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
with 'Attean::API::QueryTree', |
56
|
|
|
|
|
|
|
'Attean::API::Plan', |
57
|
|
|
|
|
|
|
'Attean::API::UnionScopeVariablesPlan', |
58
|
|
|
|
|
|
|
'MooX::Log::Any'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub plan_as_string { |
61
|
1
|
|
|
1
|
0
|
3124
|
my $self = shift; |
62
|
1
|
|
|
|
|
7
|
return 'SPARQLBGP'; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub impl { |
66
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
my $model = shift; |
68
|
0
|
|
|
|
|
|
my $sparql = 'SELECT * WHERE {'; |
69
|
0
|
|
|
|
|
|
foreach my $child (@{$self->children}) { |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my @terms = $child->values; |
71
|
0
|
|
|
|
|
|
my $pattern = Attean::TriplePattern->new(@terms[0..2]); |
72
|
0
|
|
|
|
|
|
$sparql .= "\n " . $pattern->as_sparql . ' . '; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
$sparql .= "\n}\n"; |
75
|
0
|
|
|
|
|
|
$self->log->debug("Using query:\n$sparql"); |
76
|
|
|
|
|
|
|
return sub { |
77
|
0
|
|
|
0
|
|
|
return $model->get_sparql($sparql) |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |