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