| 1 | # RDF::Query::Plan::Move | ||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | RDF::Query::Plan::Move - Executable query plan for MOVE operations. | ||||||||||
| 7 | |||||||||||
| 8 | =head1 VERSION | ||||||||||
| 9 | |||||||||||
| 10 | This document describes RDF::Query::Plan::Move 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::Move; | ||||||||||
| 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 ( $from, $to, $silent ) >> | ||||||||||
| 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 $from = shift; | |||||||||
| 51 | 0 | my $to = shift; | |||||||||
| 52 | 0 | my $silent = shift; | |||||||||
| 53 | 0 | my $self = $class->SUPER::new( $from, $to, $silent ); | |||||||||
| 54 | 0 | return $self; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | =item C<< execute ( $execution_context ) >> | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub execute ($) { | ||||||||
|
Subroutine
execute: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | my $self = shift; | |||||||||
| 63 | 0 | my $context = shift; | |||||||||
| 64 | 0 | $self->[0]{delegate} = $context->delegate; | |||||||||
| 65 | 0 | ▶ | if ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | throw RDF::Query::Error::ExecutionError -text => "MOVE plan can't be executed while already open"; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.plan.move"); | |||||||||
| 70 | 0 | $l->trace( "executing RDF::Query::Plan::Move" ); | |||||||||
| 71 | |||||||||||
| 72 | 0 | my $from = $self->from; | |||||||||
| 73 | 0 | my $to = $self->to; | |||||||||
| 74 | # warn "Moving graph " . $from->as_string; | ||||||||||
| 75 | 0 | my $ok = 0; | |||||||||
| 76 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 77 | 0 | ▶ | if ($from->equal( $to )) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | # no-op | ||||||||||
| 79 | } else { | ||||||||||
| 80 | 0 | my $model = $context->model; | |||||||||
| 81 | 0 | $model->begin_bulk_ops(); | |||||||||
| 82 | 0 | $model->remove_statements( undef, undef, undef, $to ); | |||||||||
| 83 | 0 | my $iter = $model->get_statements( undef, undef, undef, $from ); | |||||||||
| 84 | 0 | ▶ | while (my $st = $iter->next) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | $model->add_statement( $st, $to ); | |||||||||
| 86 | } | ||||||||||
| 87 | 0 | $context->model->remove_statements( undef, undef, undef, $from ); | |||||||||
| 88 | 0 | $model->end_bulk_ops(); | |||||||||
| 89 | } | ||||||||||
| 90 | 0 | $ok = 1; | |||||||||
| 91 | 0 | ▶ | } catch RDF::Trine::Error with {}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 92 | 0 | $self->[0]{ok} = $ok; | |||||||||
| 93 | 0 | $self->state( $self->OPEN ); | |||||||||
| 94 | 0 | $self; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | =item C<< next >> | ||||||||||
| 98 | |||||||||||
| 99 | =cut | ||||||||||
| 100 | |||||||||||
| 101 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 102 | 0 | my $self = shift; | |||||||||
| 103 | 0 | ▶ | unless ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 0 | throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open MOVE"; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.plan.move"); | |||||||||
| 108 | 0 | $self->close(); | |||||||||
| 109 | 0 | ▶ | if (my $d = $self->delegate) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 0 | $d->log_result( $self, $self->[0]{ok} ); | |||||||||
| 111 | } | ||||||||||
| 112 | 0 | return $self->[0]{ok}; | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | =item C<< close >> | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | |||||||||||
| 119 | 0 | ▶ | sub close { | ||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 120 | 0 | my $self = shift; | |||||||||
| 121 | 0 | ▶ | unless ($self->state == $self->OPEN) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 122 | 0 | throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open MOVE"; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||
| 125 | 0 | delete $self->[0]{ok}; | |||||||||
| 126 | 0 | $self->SUPER::close(); | |||||||||
| 127 | } | ||||||||||
| 128 | |||||||||||
| 129 | =item C<< from >> | ||||||||||
| 130 | |||||||||||
| 131 | Returns the graph node which is to be copied. | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | 0 | ▶ | sub from { | ||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 136 | 0 | my $self = shift; | |||||||||
| 137 | 0 | return $self->[1]; | |||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | =item C<< to >> | ||||||||||
| 141 | |||||||||||
| 142 | Returns the graph node to which data is copied. | ||||||||||
| 143 | |||||||||||
| 144 | =cut | ||||||||||
| 145 | |||||||||||
| 146 | 0 | ▶ | sub to { | ||||||||
|
Subroutine
to: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 147 | 0 | my $self = shift; | |||||||||
| 148 | 0 | return $self->[2]; | |||||||||
| 149 | } | ||||||||||
| 150 | |||||||||||
| 151 | =item C<< silent >> | ||||||||||
| 152 | |||||||||||
| 153 | Returns the silent flag. | ||||||||||
| 154 | |||||||||||
| 155 | =cut | ||||||||||
| 156 | |||||||||||
| 157 | 0 | ▶ | sub silent { | ||||||||
|
Subroutine
silent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 158 | 0 | my $self = shift; | |||||||||
| 159 | 0 | return $self->[3]; | |||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | =item C<< distinct >> | ||||||||||
| 163 | |||||||||||
| 164 | Returns true if the pattern is guaranteed to return distinct results. | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||
| 167 | |||||||||||
| 168 | 0 | ▶ | sub distinct { | ||||||||
|
Subroutine
distinct: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 169 | 0 | return 1; | |||||||||
| 170 | } | ||||||||||
| 171 | |||||||||||
| 172 | =item C<< ordered >> | ||||||||||
| 173 | |||||||||||
| 174 | Returns true if the pattern is guaranteed to return ordered results. | ||||||||||
| 175 | |||||||||||
| 176 | =cut | ||||||||||
| 177 | |||||||||||
| 178 | 0 | ▶ | sub ordered { | ||||||||
|
Subroutine
ordered: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 179 | 0 | return []; | |||||||||
| 180 | } | ||||||||||
| 181 | |||||||||||
| 182 | =item C<< plan_node_name >> | ||||||||||
| 183 | |||||||||||
| 184 | Returns the string name of this plan node, suitable for use in serialization. | ||||||||||
| 185 | |||||||||||
| 186 | =cut | ||||||||||
| 187 | |||||||||||
| 188 | 0 | ▶ | sub plan_node_name { | ||||||||
|
Subroutine
plan_node_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 189 | 0 | return 'move'; | |||||||||
| 190 | } | ||||||||||
| 191 | |||||||||||
| 192 | =item C<< plan_prototype >> | ||||||||||
| 193 | |||||||||||
| 194 | Returns a list of scalar identifiers for the type of the content (children) | ||||||||||
| 195 | nodes of this plan node. See L<RDF::Query::Plan> for a list of the allowable | ||||||||||
| 196 | identifiers. | ||||||||||
| 197 | |||||||||||
| 198 | =cut | ||||||||||
| 199 | |||||||||||
| 200 | 0 | ▶ | sub plan_prototype { | ||||||||
|
Subroutine
plan_prototype: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 201 | 0 | my $self = shift; | |||||||||
| 202 | 0 | return qw(N N); | |||||||||
| 203 | } | ||||||||||
| 204 | |||||||||||
| 205 | =item C<< plan_node_data >> | ||||||||||
| 206 | |||||||||||
| 207 | Returns the data for this plan node that corresponds to the values described by | ||||||||||
| 208 | the signature returned by C<< plan_prototype >>. | ||||||||||
| 209 | |||||||||||
| 210 | =cut | ||||||||||
| 211 | |||||||||||
| 212 | 0 | ▶ | sub plan_node_data { | ||||||||
|
Subroutine
plan_node_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 213 | 0 | my $self = shift; | |||||||||
| 214 | 0 | return ($self->from, $self->to); | |||||||||
| 215 | } | ||||||||||
| 216 | |||||||||||
| 217 | =item C<< graph ( $g ) >> | ||||||||||
| 218 | |||||||||||
| 219 | =cut | ||||||||||
| 220 | |||||||||||
| 221 | 0 | ▶ | sub graph { | ||||||||
|
Subroutine
graph: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 222 | 0 | my $self = shift; | |||||||||
| 223 | 0 | my $g = shift; | |||||||||
| 224 | 0 | my $label = $self->graph_labels; | |||||||||
| 225 | 0 | my $furl = $self->from->uri_value; | |||||||||
| 226 | 0 | my $turl = $self->to->uri_value; | |||||||||
| 227 | 0 | $g->add_node( "$self", label => "Move" . $self->graph_labels ); | |||||||||
| 228 | 0 | $g->add_node( "${self}$furl", label => $furl ); | |||||||||
| 229 | 0 | $g->add_node( "${self}$turl", label => $turl ); | |||||||||
| 230 | 0 | $g->add_edge( "$self" => "${self}$furl", label => 'from' ); | |||||||||
| 231 | 0 | $g->add_edge( "$self" => "${self}$turl", label => 'to' ); | |||||||||
| 232 | 0 | return "$self"; | |||||||||
| 233 | } | ||||||||||
| 234 | |||||||||||
| 235 | =item C<< is_update >> | ||||||||||
| 236 | |||||||||||
| 237 | Returns true if the plan represents an update operation. | ||||||||||
| 238 | |||||||||||
| 239 | =cut | ||||||||||
| 240 | |||||||||||
| 241 | 0 | ▶ | sub is_update { | ||||||||
|
Subroutine
is_update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 242 | 0 | return 1; | |||||||||
| 243 | } | ||||||||||
| 244 | |||||||||||
| 245 | 35 | 1; | |||||||||
| 246 | |||||||||||
| 247 | __END__ | ||||||||||