| 1 | # RDF::Query::Plan::Sequence | ||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | RDF::Query::Plan::Sequence - Executable query plan for a sequence of operations. | ||||||||||
| 7 | |||||||||||
| 8 | =head1 VERSION | ||||||||||
| 9 | |||||||||||
| 10 | This document describes RDF::Query::Plan::Sequence 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::Sequence; | ||||||||||
| 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::Trine::Statement; | ||||||||
|
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 ( @plans ) >> | ||||||||||
| 40 | |||||||||||
| 41 | =cut | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 44 | 0 | my $class = shift; | |||||||||
| 45 | 0 | my @plans = @_; | |||||||||
| 46 | 0 | my $self = $class->SUPER::new( \@plans ); | |||||||||
| 47 | 0 | return $self; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | =item C<< execute ( $execution_context ) >> | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub execute ($) { | ||||||||
|
Subroutine
execute: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 55 | 0 | my $self = shift; | |||||||||
| 56 | 0 | my $context = shift; | |||||||||
| 57 | 0 | $self->[0]{delegate} = $context->delegate; | |||||||||
| 58 | 0 | ▶ | if ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | throw RDF::Query::Error::ExecutionError -text => "SEQUENCE plan can't be executed twice"; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.plan.sequence"); | |||||||||
| 63 | 0 | $l->trace( "executing RDF::Query::Plan::Sequence" ); | |||||||||
| 64 | |||||||||||
| 65 | 0 | my @plans = @{ $self->[1] }; | |||||||||
| 66 | 0 | ▶ | while (scalar(@plans) > 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | my $p = shift(@plans); | |||||||||
| 68 | 0 | $p->execute( $context ); | |||||||||
| 69 | 0 | ▶ | 1 while ($p->next); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | } | ||||||||||
| 71 | 0 | my $iter = $plans[0]->execute( $context ); | |||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | if (blessed($iter)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 0 | $self->[0]{iter} = $iter; | |||||||||
| 75 | 0 | $self->state( $self->OPEN ); | |||||||||
| 76 | } else { | ||||||||||
| 77 | 0 | warn "no iterator in execute()"; | |||||||||
| 78 | } | ||||||||||
| 79 | 0 | $self; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | =item C<< next >> | ||||||||||
| 83 | |||||||||||
| 84 | =cut | ||||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 87 | 0 | my $self = shift; | |||||||||
| 88 | 0 | ▶ | unless ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open SEQUENCE"; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 0 | my $iter = $self->[0]{iter}; | |||||||||
| 93 | 0 | my $row = $iter->next; | |||||||||
| 94 | 0 | ▶ | if (my $d = $self->delegate) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 0 | $d->log_result( $self, $row ); | |||||||||
| 96 | } | ||||||||||
| 97 | 0 | return $row; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | =item C<< close >> | ||||||||||
| 101 | |||||||||||
| 102 | =cut | ||||||||||
| 103 | |||||||||||
| 104 | 0 | ▶ | sub close { | ||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 105 | 0 | my $self = shift; | |||||||||
| 106 | 0 | ▶ | unless ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | 0 | throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open SEQUENCE"; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 0 | delete $self->[0]{iter}; | |||||||||
| 111 | 0 | $self->SUPER::close(); | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | =item C<< distinct >> | ||||||||||
| 115 | |||||||||||
| 116 | Returns true if the pattern is guaranteed to return distinct results. | ||||||||||
| 117 | |||||||||||
| 118 | =cut | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub distinct { | ||||||||
|
Subroutine
distinct: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 121 | 0 | my $self = shift; | |||||||||
| 122 | 0 | my @plans = @{ $self->[1] }; | |||||||||
| 123 | 0 | return $plans[ $#plans ]->distinct; | |||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | =item C<< ordered >> | ||||||||||
| 127 | |||||||||||
| 128 | Returns true if the pattern is guaranteed to return ordered results. | ||||||||||
| 129 | |||||||||||
| 130 | =cut | ||||||||||
| 131 | |||||||||||
| 132 | 0 | ▶ | sub ordered { | ||||||||
|
Subroutine
ordered: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 133 | 0 | my $self = shift; | |||||||||
| 134 | 0 | my @plans = @{ $self->[1] }; | |||||||||
| 135 | 0 | return $plans[ $#plans ]->ordered; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | =item C<< plan_node_name >> | ||||||||||
| 139 | |||||||||||
| 140 | Returns the string name of this plan node, suitable for use in serialization. | ||||||||||
| 141 | |||||||||||
| 142 | =cut | ||||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | sub plan_node_name { | ||||||||
|
Subroutine
plan_node_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 145 | 0 | return 'sequence'; | |||||||||
| 146 | } | ||||||||||
| 147 | |||||||||||
| 148 | =item C<< plan_prototype >> | ||||||||||
| 149 | |||||||||||
| 150 | Returns a list of scalar identifiers for the type of the content (children) | ||||||||||
| 151 | nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable | ||||||||||
| 152 | identifiers. | ||||||||||
| 153 | |||||||||||
| 154 | =cut | ||||||||||
| 155 | |||||||||||
| 156 | 0 | ▶ | sub plan_prototype { | ||||||||
|
Subroutine
plan_prototype: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 157 | 0 | my $self = shift; | |||||||||
| 158 | 0 | return qw(*P); | |||||||||
| 159 | } | ||||||||||
| 160 | |||||||||||
| 161 | =item C<< plan_node_data >> | ||||||||||
| 162 | |||||||||||
| 163 | Returns the data for this plan node that corresponds to the values described by | ||||||||||
| 164 | the signature returned by C<< plan_prototype >>. | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||
| 167 | |||||||||||
| 168 | 0 | ▶ | sub plan_node_data { | ||||||||
|
Subroutine
plan_node_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 169 | 0 | my $self = shift; | |||||||||
| 170 | 0 | my @triples = @{ $self->[1] }; | |||||||||
| 171 | 0 | return @triples; | |||||||||
| 172 | } | ||||||||||
| 173 | |||||||||||
| 174 | 35 | 1; | |||||||||
| 175 | |||||||||||
| 176 | __END__ | ||||||||||