Query/Plan/Iterator.pm

filter: Statementstmt 28.3% 15 / 53 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 35.7% 5 / 14 Podpod 100% 9 / 9 totaltotal 29.9% 29 / 97 CC 9 SCAR 26.7
CC
9
Cov
21%
execute
42.0
next
12.0
close
6.0
CRAP 14.4
« Query/Plan/Update.pm ↑ Summary Query/Algebra/NamedGraph.pm »
1 # RDF::Query::Plan::Iterator
2 # -----------------------------------------------------------------------------
3  
4 =head1 NAME
5  
6 RDF::Query::Plan::Iterator - Executable query plan for result-generating iterators.
7  
8 =head1 VERSION
9  
10 This document describes RDF::Query::Plan::Iterator 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::Iterator;
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 reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 ######################################################################
30  
31 35 our ($VERSION);
32 35 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
33 35 $VERSION = '2.919';
34 }
35  
36 ######################################################################
37  
38 =item C<< new ( $iter, \&execute_cb ) >>
39  
40 =item C<< new ( \&create_iterator_cb ) >>
41  
42 =cut
43  
44 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
45 0 my $class = shift;
46 0 my $iter = shift;
47 0 my $cb = shift;
48 0 my $self = $class->SUPER::new( $iter, $cb );
49 0 $self->[0]{referenced_variables} = [];
50 0 return $self;
51 }
52  
53 =item C<< execute ( $execution_context ) >>
54  
55 =cut
56  
57 0 ▶sub execute ($) {
Subroutine execute: not called CC=6 SCAR=37.4
Pod documented
58 0 my $self = shift;
59 0 my $context = shift;
60 0 $self->[0]{delegate} = $context->delegate;
61 0 ▶ if ($self->state == $self->OPEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state == $self->OPEN) 0 0 0
62 0 throw RDF::Query::Error::ExecutionError -text => "ITERATOR plan can't be executed while already open";
63 }
64
65 0 ▶ if (ref($self->[2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->[2]) 0 0 0
66 0 $self->[2]->( $context );
67 }
68
69 # if we don't have an actual iterator, but only a promise of one, construct it now
70 0 ▶ if (reftype($self->[1]) eq 'CODE' and not(blessed($self->[1]) and $self->[1]->isa('RDF::Trine::Iterator'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($self->[1]) eq "CODE" and not builtin::blessed($self->[1]) && $self->[1]->isa("RDF::Trine::Iterator")) 0 0 0
Condition0%0/6
builtin::reftype($self->[1]) eq "CODE" and not builtin::blessed($self->[1]) && $self->[1]->isa("RDF::Trine::Iterator")
!ll&&!rl&&r
000
builtin::blessed($self->[1]) && $self->[1]->isa('RDF::Trine::Iterator')
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::reftype($self->[1]) eq "CODE" and not builtin::blessed($self->[1]) && $self->[1]->isa("RDF::Trine::Iterator")
builtin::reftype($self->[1]) eq "CODE" builtin::blessed($self->[1]) $self->[1]->isa('RDF::Trine::Iterator')
Truth table0%0/4
A and not(B && C)
A= builtin::reftype($self->[1]) eq "CODE"B= builtin::blessed($self->[1])C= $self->[1]->isa('RDF::Trine::Iterator')
ABCresult
0XX0
1110
10X1
1101
71 0 $self->[1] = $self->[1]->( $context );
72 }
73
74 0 $self->state( $self->OPEN );
75 0 $self;
76 }
77  
78 =item C<< next >>
79  
80 =cut
81  
82 0 ▶sub next {
Subroutine next: not called CC=3 SCAR=24.8
Pod documented
83 0 my $self = shift;
84 0 ▶ unless ($self->state == $self->OPEN) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state == $self->OPEN) 0 0 0
85 0 throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open ITERATOR";
86 }
87 0 my $iter = $self->[1];
88 0 my $bindings = $iter->next;
89 0 ▶ if (my $d = $self->delegate) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $d = $self->delegate) 0 0 0
90 0 $d->log_result( $self, $bindings );
91 }
92 0 return $bindings;
93 }
94  
95 =item C<< close >>
96  
97 =cut
98  
99 0 ▶sub close {
Subroutine close: not called CC=2 SCAR=17.9
Pod documented
100 0 my $self = shift;
101 0 ▶ unless ($self->state == $self->OPEN) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state == $self->OPEN) 0 0 0
102 0 throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open ITERATOR";
103 }
104 0 my $iter = $self->[1];
105 0 $iter->close;
106 0 $self->SUPER::close();
107 }
108  
109 =item C<< distinct >>
110  
111 Returns true if the pattern is guaranteed to return distinct results.
112  
113 =cut
114  
115 0 ▶sub distinct {
Subroutine distinct: not called CC=1 SCAR=6.9
Pod documented
116 0 return 0;
117 }
118  
119 =item C<< ordered >>
120  
121 Returns true if the pattern is guaranteed to return ordered results.
122  
123 =cut
124  
125 0 ▶sub ordered {
Subroutine ordered: not called CC=1 SCAR=6.9
Pod documented
126 0 return [];
127 }
128  
129 =item C<< plan_node_name >>
130  
131 Returns the string name of this plan node, suitable for use in serialization.
132  
133 =cut
134  
135 0 ▶sub plan_node_name {
Subroutine plan_node_name: not called CC=1 SCAR=6.9
Pod documented
136 0 return 'optimized-iterator';
137 }
138  
139 =item C<< plan_prototype >>
140  
141 Returns a list of scalar identifiers for the type of the content (children)
142 nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable
143 identifiers.
144  
145 =cut
146  
147 0 ▶sub plan_prototype {
Subroutine plan_prototype: not called CC=1 SCAR=6.9
Pod documented
148 0 my $self = shift;
149 0 return qw();
150 }
151  
152 =item C<< plan_node_data >>
153  
154 Returns the data for this plan node that corresponds to the values described by
155 the signature returned by C<< plan_prototype >>.
156  
157 =cut
158  
159 0 ▶sub plan_node_data {
Subroutine plan_node_data: not called CC=1 SCAR=6.9
Pod documented
160 0 my $self = shift;
161 0 return;
162 }
163  
164 35 1;
165  
166 __END__
« Query/Plan/Update.pm ↑ Summary Query/Algebra/NamedGraph.pm »