line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
71
|
use 5.010001; |
|
5
|
|
|
|
|
14
|
|
2
|
5
|
|
|
5
|
|
15
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
115
|
|
3
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
159
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package AtteanX::Query::Cache::Analyzer::QueryPlanner; |
7
|
5
|
|
|
5
|
|
21
|
use Class::Method::Modifiers; |
|
5
|
|
|
|
|
3
|
|
|
5
|
|
|
|
|
323
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KJETILK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
20
|
use Moo; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
20
|
|
13
|
5
|
|
|
5
|
|
1113
|
use Attean::RDF qw(triplepattern variable iri); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
200
|
|
14
|
5
|
|
|
5
|
|
15
|
use Carp; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
205
|
|
15
|
5
|
|
|
5
|
|
19
|
use feature "state"; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
1597
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
extends 'AtteanX::QueryPlanner::Cache::LDF'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
around 'access_plans' => sub { |
20
|
|
|
|
|
|
|
my $orig = shift; |
21
|
|
|
|
|
|
|
my @params = @_; |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
my $model = shift; |
24
|
|
|
|
|
|
|
my $active_graphs = shift; |
25
|
|
|
|
|
|
|
my $pattern = shift; |
26
|
|
|
|
|
|
|
# First, add any plans coming from the original planner (which will |
27
|
|
|
|
|
|
|
# include queries to the remote SPARQL endpoint |
28
|
|
|
|
|
|
|
my @plans = $orig->(@params); |
29
|
|
|
|
|
|
|
my @vars = $pattern->values_consuming_role('Attean::API::Variable'); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Start checking the cache |
32
|
|
|
|
|
|
|
my $keypattern = $pattern->canonicalize->tuples_string; |
33
|
|
|
|
|
|
|
if ($model->is_cached($keypattern)) { |
34
|
|
|
|
|
|
|
$self->log->debug("Already accounted for by cache: $keypattern"); |
35
|
|
|
|
|
|
|
} elsif ($model->try eq $keypattern) { |
36
|
|
|
|
|
|
|
$self->log->debug("Creating dummy iterator for $keypattern"); |
37
|
|
|
|
|
|
|
my %row; |
38
|
|
|
|
|
|
|
foreach my $var (@vars) { |
39
|
|
|
|
|
|
|
$row{$var->value} = iri('urn:x-internal:dummy'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
my $iter = Attean::CodeIterator->new(generator => sub { |
42
|
|
|
|
|
|
|
state $i = 0; |
43
|
|
|
|
|
|
|
warn $i; |
44
|
|
|
|
|
|
|
if ($i) { |
45
|
|
|
|
|
|
|
return undef |
46
|
|
|
|
|
|
|
} else { |
47
|
|
|
|
|
|
|
$i++; |
48
|
|
|
|
|
|
|
return Attean::Result->new(bindings => \%row); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
item_type => 'Attean::API::Result', |
52
|
|
|
|
|
|
|
variables => [map { $_->value } @vars] |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
push(@plans, Attean::Plan::Iterator->new( variables => \@vars, |
55
|
|
|
|
|
|
|
iterator => $iter, |
56
|
|
|
|
|
|
|
distinct => 0, |
57
|
|
|
|
|
|
|
ordered => [] )); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
return @plans; |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |