| 1 | # RDF::Query::Plan::Load | ||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | RDF::Query::Plan::Load - Executable query plan for LOAD operations. | ||||||||||
| 7 | |||||||||||
| 8 | =head1 VERSION | ||||||||||
| 9 | |||||||||||
| 10 | This document describes RDF::Query::Plan::Load 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::Load; | ||||||||||
| 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 Log::Log4perl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 35 | ▶ | use Scalar::Util qw(blessed); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 35 | ▶ | use Time::HiRes qw(gettimeofday tv_interval); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 35 | ▶ | use RDF::Query::Error qw(:try); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 35 | ▶ | use RDF::Query::ExecutionContext; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 35 | ▶ | use RDF::Query::VariableBindings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | |||||||||||
| 35 | ###################################################################### | ||||||||||
| 36 | |||||||||||
| 37 | 35 | our ($VERSION); | |||||||||
| 38 | 35 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 35 | $VERSION = '2.919'; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | ###################################################################### | ||||||||||
| 43 | |||||||||||
| 44 | =item C<< new ( $url, $graph ) >> | ||||||||||
| 45 | |||||||||||
| 46 | =cut | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 49 | 0 | my $class = shift; | |||||||||
| 50 | 0 | my $url = shift; | |||||||||
| 51 | 0 | my $graph = shift; | |||||||||
| 52 | 0 | my $self = $class->SUPER::new( $url, $graph ); | |||||||||
| 53 | 0 | return $self; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | =item C<< execute ( $execution_context ) >> | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub execute ($) { | ||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 61 | 0 | my $self = shift; | |||||||||
| 62 | 0 | my $context = shift; | |||||||||
| 63 | 0 | $self->[0]{delegate} = $context->delegate; | |||||||||
| 64 | 0 | ▶ | if ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | throw RDF::Query::Error::ExecutionError -text => "LOAD plan can't be executed while already open"; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); | |||||||||
| 69 | 0 | $l->trace( "executing RDF::Query::Plan::Load" ); | |||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | my %args = ($self->namedgraph) ? (context => $self->namedgraph) : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | my $ok = 0; | |||||||||
| 73 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 74 | 0 | RDF::Trine::Parser->parse_url_into_model( $self->url->uri_value, $context->model, %args ); | |||||||||
| 75 | 0 | $ok = 1; | |||||||||
| 76 | 0 | ▶ | } catch RDF::Trine::Error with {}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 77 | 0 | $self->[0]{ok} = $ok; | |||||||||
| 78 | 0 | $self->state( $self->OPEN ); | |||||||||
| 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 LOAD"; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); | |||||||||
| 93 | 0 | $self->close(); | |||||||||
| 94 | 0 | ▶ | if (my $d = $self->delegate) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 0 | $d->log_result( $self, $self->[0]{ok} ); | |||||||||
| 96 | } | ||||||||||
| 97 | 0 | return $self->[0]{ok}; | |||||||||
| 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 LOAD"; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 0 | delete $self->[0]{ok}; | |||||||||
| 111 | 0 | $self->SUPER::close(); | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | =item C<< url >> | ||||||||||
| 115 | |||||||||||
| 116 | Returns the URL to load data from. | ||||||||||
| 117 | |||||||||||
| 118 | =cut | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub url { | ||||||||
|
Subroutine
url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 121 | 0 | my $self = shift; | |||||||||
| 122 | 0 | return $self->[1]; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||
| 125 | =item C<< namedgraph >> | ||||||||||
| 126 | |||||||||||
| 127 | Returns the optional graph name to load the data with. | ||||||||||
| 128 | |||||||||||
| 129 | =cut | ||||||||||
| 130 | |||||||||||
| 131 | 0 | ▶ | sub namedgraph { | ||||||||
|
Subroutine
namedgraph: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 132 | 0 | my $self = shift; | |||||||||
| 133 | 0 | return $self->[2]; | |||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | =item C<< distinct >> | ||||||||||
| 137 | |||||||||||
| 138 | Returns true if the pattern is guaranteed to return distinct results. | ||||||||||
| 139 | |||||||||||
| 140 | =cut | ||||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub distinct { | ||||||||
|
Subroutine
distinct: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 143 | 0 | return 1; | |||||||||
| 144 | } | ||||||||||
| 145 | |||||||||||
| 146 | =item C<< ordered >> | ||||||||||
| 147 | |||||||||||
| 148 | Returns true if the pattern is guaranteed to return ordered results. | ||||||||||
| 149 | |||||||||||
| 150 | =cut | ||||||||||
| 151 | |||||||||||
| 152 | 0 | ▶ | sub ordered { | ||||||||
|
Subroutine
ordered: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 153 | 0 | return []; | |||||||||
| 154 | } | ||||||||||
| 155 | |||||||||||
| 156 | =item C<< plan_node_name >> | ||||||||||
| 157 | |||||||||||
| 158 | Returns the string name of this plan node, suitable for use in serialization. | ||||||||||
| 159 | |||||||||||
| 160 | =cut | ||||||||||
| 161 | |||||||||||
| 162 | 0 | ▶ | sub plan_node_name { | ||||||||
|
Subroutine
plan_node_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 163 | 0 | return 'load'; | |||||||||
| 164 | } | ||||||||||
| 165 | |||||||||||
| 166 | =item C<< plan_prototype >> | ||||||||||
| 167 | |||||||||||
| 168 | Returns a list of scalar identifiers for the type of the content (children) | ||||||||||
| 169 | nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable | ||||||||||
| 170 | identifiers. | ||||||||||
| 171 | |||||||||||
| 172 | =cut | ||||||||||
| 173 | |||||||||||
| 174 | 0 | ▶ | sub plan_prototype { | ||||||||
|
Subroutine
plan_prototype: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 175 | 0 | my $self = shift; | |||||||||
| 176 | 0 | return qw(N N); | |||||||||
| 177 | } | ||||||||||
| 178 | |||||||||||
| 179 | =item C<< plan_node_data >> | ||||||||||
| 180 | |||||||||||
| 181 | Returns the data for this plan node that corresponds to the values described by | ||||||||||
| 182 | the signature returned by C<< plan_prototype >>. | ||||||||||
| 183 | |||||||||||
| 184 | =cut | ||||||||||
| 185 | |||||||||||
| 186 | 0 | ▶ | sub plan_node_data { | ||||||||
|
Subroutine
plan_node_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 187 | 0 | my $self = shift; | |||||||||
| 188 | 0 | return ($self->url, $self->namedgraph); | |||||||||
| 189 | } | ||||||||||
| 190 | |||||||||||
| 191 | =item C<< graph ( $g ) >> | ||||||||||
| 192 | |||||||||||
| 193 | =cut | ||||||||||
| 194 | |||||||||||
| 195 | 0 | ▶ | sub graph { | ||||||||
|
Subroutine
graph: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 196 | 0 | my $self = shift; | |||||||||
| 197 | 0 | my $g = shift; | |||||||||
| 198 | 0 | my $label = $self->graph_labels; | |||||||||
| 199 | 0 | my $url = $self->url->uri_value; | |||||||||
| 200 | 0 | $g->add_node( "$self", label => "Load" . $self->graph_labels ); | |||||||||
| 201 | 0 | $g->add_node( "${self}$url", label => $url ); | |||||||||
| 202 | 0 | $g->add_edge( "$self" => "${self}$url", label => 'url' ); | |||||||||
| 203 | 0 | return "$self"; | |||||||||
| 204 | } | ||||||||||
| 205 | |||||||||||
| 206 | =item C<< is_update >> | ||||||||||
| 207 | |||||||||||
| 208 | Returns true if the plan represents an update operation. | ||||||||||
| 209 | |||||||||||
| 210 | =cut | ||||||||||
| 211 | |||||||||||
| 212 | 0 | ▶ | sub is_update { | ||||||||
|
Subroutine
is_update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 213 | 0 | return 1; | |||||||||
| 214 | } | ||||||||||
| 215 | |||||||||||
| 216 | |||||||||||
| 217 | 35 | 1; | |||||||||
| 218 | |||||||||||
| 219 | __END__ | ||||||||||