Query/Plan/Join.pm

filter: Statementstmt 68.4% 52 / 76 Branchbran 8.3% 1 / 12 Conditioncond 25.0% 2 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 93.7% 15 / 16 Podpod 100% 10 / 10 totaltotal 62.9% 80 / 127 CC 14 SCAR 36.7
CC
14
Cov
57%
bf
110.0
join_classes
4.2
new
2.0
CRAP 39.1
« Query/Algebra/Path.pm ↑ Summary Query/Functions/Xpath.pm »
1 # RDF::Query::Plan::Join
2 # -----------------------------------------------------------------------------
3  
4 =head1 NAME
5  
6 RDF::Query::Plan::Join - Join query plan base class.
7  
8 =head1 VERSION
9  
10 This document describes RDF::Query::Plan::Join version 2.919.
11  
12 =head1 METHODS
13  
14 Beyond the methods documented below, this class inherits methods from the
15 L<RDF::Query::Plan> class.
16  
17 =over 4
18  
19 =cut
20  
21 package RDF::Query::Plan::Join;
22  
23 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 35 ▶use base qw(RDF::Query::Plan);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 35 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 35 ▶use RDF::Query::ExecutionContext;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 ######################################################################
31  
32 35 our ($VERSION);
33 35 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
34 35 $VERSION = '2.919';
35 }
36  
37 ######################################################################
38  
39 =item C<< new ( $lhs, $rhs, $optional ) >>
40  
41 =cut
42  
43 50 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
44 50 my $class = shift;
45 50 my $lhs = shift;
46 50 my $rhs = shift;
47 50 my $opt = shift;
48 50 my $self = $class->SUPER::new( $lhs, $rhs, $opt, @_ );
49
50 50 my %vars;
51 50 my @lhs_rv = $lhs->referenced_variables;
52 50 my @rhs_rv = $rhs->referenced_variables;
53 50 foreach my $v (@lhs_rv, @rhs_rv) {
54 168 $vars{ $v }++;
55 }
56 50 $self->[0]{referenced_variables} = [ keys %vars ];
57 50 return $self;
58 }
59  
60 =item C<< lhs >>
61  
62 Returns the left-hand-side plan to the join.
63  
64 =cut
65  
66 254 ▶sub lhs {
Subroutine lhs: called CC=1 SCAR=0.0
Pod documented
67 254 my $self = shift;
68 254 return $self->[1];
69 }
70  
71 =item C<< rhs >>
72  
73 Returns the right-hand-side plan to the join.
74  
75 =cut
76  
77 134 ▶sub rhs {
Subroutine rhs: called CC=1 SCAR=0.0
Pod documented
78 134 my $self = shift;
79 134 return $self->[2];
80 }
81  
82 =item C<< optional >>
83  
84 =cut
85  
86 8 ▶sub optional {
Subroutine optional: called CC=1 SCAR=0.0
Pod documented
87 8 my $self = shift;
88 8 return $self->[3];
89 }
90  
91 =item C<< bf () >>
92  
93 Returns a string representing the state of the nodes of the triple (bound or free).
94  
95 =cut
96  
97 0 ▶sub bf {
Subroutine bf: not called CC=10 SCAR=47.0
Pod documented
98 0 my $self = shift;
99 0 my $context = shift;
100 0 my @bf;
101 my %var_to_num;
102 0 my %use_count;
103 0 my $counter = 1;
104 0 foreach my $t ($self->lhs, $self->rhs) {
105 0 ▶ unless ($t->can('bf')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t->can("bf")) 0 0 0
106 0 throw RDF::Query::Error::ExecutionError -text => "Cannot compute bf for $t during join";
107 }
108 0 my $bf = $t->bf( $context );
109 0 ▶ if ($bf =~ /f/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bf =~ /f/) 0 0 0
110 0 $bf = '';
111 0 foreach my $n ($t->nodes) {
112 0 ▶ if ($n->isa('RDF::Trine::Node::Variable')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n->isa('RDF::Trine::Node::Variable')) { } 0 0 0
113 0 my $name = $n->name;
114 0 ▶ my $num = ($var_to_num{ $name } ||= $counter++);
Condition0%0/3
$var_to_num{$name} ||= $counter++
l!l&&r!l&&!r
000
MC/DC0%0/2
$var_to_num{$name} ||= $counter++
$var_to_num{$name} $counter++
Truth table0%0/3
A ||= B
A= $var_to_num{$name}B= $counter++
ABresult
1X1
011
000
115 0 $use_count{ $name }++;
116 0 $bf .= "{${num}}";
117 } else {
118 0 $bf .= 'b';
119 }
120 }
121 }
122 0 push(@bf, $bf);
123 }
124 0 ▶ if ($counter <= 10) {
Branch: 1 branch
BranchTrueFalseTotal
if ($counter <= 10) 0 0 0
125 0 for (@bf) {
126 0 s/[{}]//g;
127 }
128 }
129 0 my $bf = join(',',@bf);
130 0 ▶ return wantarray ? @bf : $bf;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
131 }
132  
133 =item C<< join_classes >>
134  
135 Returns the class names of all available join algorithms.
136  
137 =cut
138  
139 44 ▶sub join_classes {
Subroutine join_classes: called CC=4 SCAR=14.5
Pod documented
140 44 my $class = shift;
141 44 ▶ my $config = shift || {};
Condition50%1/2
shift() || {}
l!l
440
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
142 44 our %JOIN_CLASSES;
143 44 my @classes = reverse sort keys %JOIN_CLASSES;
144 my @ok = grep {
145 44 my $name = lc($_);
146 88 $name =~ s/::/./g;
147 88 ▶ (exists $config->{ $name } and not($config->{ $name }))
Branch: 1 branch
BranchTrueFalseTotal
exists $config->{$name} && !$config->{$name} ? : 0 88 88
Condition33%1/3
exists $config->{$name} and not $config->{$name}
!ll&&!rl&&r
8800
MC/DC0%0/2
exists $config->{$name} and not $config->{$name}
exists $config->{$name} not $config->{$name}
Truth table33%1/3
A and not(B)
A= exists $config->{$name}B= not $config->{$name}
ABresult
0X0
100
111
148 ? 0
149 : 1
150 } @classes;
151 44 return @ok;
152 }
153  
154 =item C<< distinct >>
155  
156 Returns true if the pattern is guaranteed to return distinct results.
157  
158 =cut
159  
160 25 ▶sub distinct {
Subroutine distinct: called CC=1 SCAR=0.0
Pod documented
161 25 return 0;
162 }
163  
164 =item C<< ordered >>
165  
166 Returns true if the pattern is guaranteed to return ordered results.
167  
168 =cut
169  
170 25 ▶sub ordered {
Subroutine ordered: called CC=1 SCAR=0.0
Pod documented
171 25 return 0;
172 }
173  
174 =item C<< plan_prototype >>
175  
176 Returns a list of scalar identifiers for the type of the content (children)
177 nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable
178 identifiers.
179  
180 =cut
181  
182 7 ▶sub plan_prototype {
Subroutine plan_prototype: called CC=1 SCAR=0.0
Pod documented
183 7 my $self = shift;
184 7 return qw(P P);
185 }
186  
187 =item C<< plan_node_data >>
188  
189 Returns the data for this plan node that corresponds to the values described by
190 the signature returned by C<< plan_prototype >>.
191  
192 =cut
193  
194 10 ▶sub plan_node_data {
Subroutine plan_node_data: called CC=1 SCAR=0.0
Pod documented
195 10 my $self = shift;
196 10 my $expr = $self->[2];
197 10 return ($self->lhs, $self->rhs);
198 }
199  
200  
201 35 1;
202  
203 __END__
« Query/Algebra/Path.pm ↑ Summary Query/Functions/Xpath.pm »