File Coverage

blib/lib/AtteanX/QueryPlanner/Cache/LDF.pm
Criterion Covered Total %
statement 14 40 35.0
branch 0 20 0.0
condition 0 2 0.0
subroutine 5 6 83.3
pod 0 1 0.0
total 19 69 27.5


line stmt bran cond sub pod time code
1 9     9   3746084 use 5.010001;
  9         26  
2 9     9   30 use strict;
  9         13  
  9         134  
3 9     9   29 use warnings;
  9         9  
  9         414  
4              
5              
6             package AtteanX::QueryPlanner::Cache::LDF;
7              
8             our $AUTHORITY = 'cpan:KJETILK';
9             our $VERSION = '0.002';
10              
11 9     9   31 use Moo;
  9         10  
  9         37  
12 9     9   4604 use AtteanX::Query::AccessPlan::PrefetchLDF;
  9         20  
  9         1997  
13              
14             extends 'AtteanX::QueryPlanner::Cache';
15             with 'AtteanX::Query::AccessPlan::PrefetchLDF';
16              
17             # Only allow rotation on joins who have one child matching: - Either a
18             # Attean::Plan::Quad, AtteanX::Plan::SPARQLBGP, or
19             # AtteanX::Plan::LDF::Triple and the other child being a join
20              
21             sub allow_join_rotation {
22 0     0 0   my $self = shift;
23 0           my $join = shift;
24 0   0       my $quads = shift // 0;
25 0           my $joins = 0;
26 0           my @grandchildren;
27 0           $self->log->trace("Seeking to rotate:\n" . $join->as_string);
28 0           foreach my $p (@{ $join->children }) {
  0            
29 0 0         $quads++ if ($p->isa('Attean::Plan::Quad'));
30 0 0         $quads++ if ($p->isa('AtteanX::Plan::LDF::Triple'));
31 0 0         $quads++ if ($p->isa('AtteanX::Plan::SPARQLBGP'));
32 0 0         if ($p->does('Attean::API::Plan::Join')) {
33 0           $joins++;
34 0           push(@grandchildren, @{ $p->children });
  0            
35             }
36             }
37 0 0         return 0 unless ($joins == 1);
38 0 0         return 0 unless ($quads == 1);
39 0           foreach my $p (@grandchildren) {
40 0 0         $quads++ if ($p->isa('Attean::Plan::Quad'));
41 0 0         $quads++ if ($p->isa('AtteanX::Plan::LDF::Triple'));
42 0 0         $quads++ if ($p->isa('AtteanX::Plan::SPARQLBGP'));
43             }
44            
45 0 0         if ($quads >= 2) {
46 0           $self->log->debug("Allowing rotation for $quads quads.");
47 0           return 1;
48             } else {
49 0           $self->log->debug("Disallowing rotation, just $quads quad.");
50 0           return 0;
51             }
52             }
53              
54              
55             1;