| line | stmt | bran | cond | sub | pod | time | code | 
| 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.916. | 
| 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 |  |  | 35 |  | 188 | use strict; | 
|  | 35 |  |  |  |  | 82 |  | 
|  | 35 |  |  |  |  | 903 |  | 
| 24 | 35 |  |  | 35 |  | 185 | use warnings; | 
|  | 35 |  |  |  |  | 78 |  | 
|  | 35 |  |  |  |  | 1050 |  | 
| 25 | 35 |  |  | 35 |  | 197 | use base qw(RDF::Query::Plan); | 
|  | 35 |  |  |  |  | 78 |  | 
|  | 35 |  |  |  |  | 2787 |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 35 |  |  | 35 |  | 212 | use Log::Log4perl; | 
|  | 35 |  |  |  |  | 87 |  | 
|  | 35 |  |  |  |  | 275 |  | 
| 28 | 35 |  |  | 35 |  | 1646 | use Scalar::Util qw(blessed); | 
|  | 35 |  |  |  |  | 82 |  | 
|  | 35 |  |  |  |  | 1751 |  | 
| 29 | 35 |  |  | 35 |  | 192 | use Time::HiRes qw(gettimeofday tv_interval); | 
|  | 35 |  |  |  |  | 76 |  | 
|  | 35 |  |  |  |  | 258 |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 35 |  |  | 35 |  | 3788 | use RDF::Query::Error qw(:try); | 
|  | 35 |  |  |  |  | 76 |  | 
|  | 35 |  |  |  |  | 256 |  | 
| 32 | 35 |  |  | 35 |  | 4262 | use RDF::Query::ExecutionContext; | 
|  | 35 |  |  |  |  | 83 |  | 
|  | 35 |  |  |  |  | 798 |  | 
| 33 | 35 |  |  | 35 |  | 181 | use RDF::Query::VariableBindings; | 
|  | 35 |  |  |  |  | 72 |  | 
|  | 35 |  |  |  |  | 1466 |  | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | ###################################################################### | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | our ($VERSION); | 
| 38 |  |  |  |  |  |  | BEGIN { | 
| 39 | 35 |  |  | 35 |  | 31129 | $VERSION	= '2.916'; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | ###################################################################### | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =item C<< new ( $from, $to, $silent ) >> | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | =cut | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | sub new { | 
| 49 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub execute ($) { | 
| 62 | 0 |  |  | 0 | 1 |  | my $self	= shift; | 
| 63 | 0 |  |  |  |  |  | my $context	= shift; | 
| 64 | 0 |  |  |  |  |  | $self->[0]{delegate}	= $context->delegate; | 
| 65 | 0 | 0 |  |  |  |  | if ($self->state == $self->OPEN) { | 
| 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 |  |  |  |  |  |  | try { | 
| 77 | 0 | 0 |  | 0 |  |  | if ($from->equal( $to )) { | 
| 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) { | 
| 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 |  |  | 0 |  |  | } catch RDF::Trine::Error with {}; | 
| 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 |  |  |  |  |  |  | sub next { | 
| 102 | 0 |  |  | 0 | 1 |  | my $self	= shift; | 
| 103 | 0 | 0 |  |  |  |  | unless ($self->state == $self->OPEN) { | 
| 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 | 0 |  |  |  |  | if (my $d = $self->delegate) { | 
| 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 |  |  |  |  |  |  | sub close { | 
| 120 | 0 |  |  | 0 | 1 |  | my $self	= shift; | 
| 121 | 0 | 0 |  |  |  |  | unless ($self->state == $self->OPEN) { | 
| 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 |  |  |  |  |  |  | sub from { | 
| 136 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub to { | 
| 147 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub silent { | 
| 158 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub distinct { | 
| 169 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub ordered { | 
| 179 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub plan_node_name { | 
| 189 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub plan_prototype { | 
| 201 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub plan_node_data { | 
| 213 | 0 |  |  | 0 | 1 |  | my $self	= shift; | 
| 214 | 0 |  |  |  |  |  | return ($self->from, $self->to); | 
| 215 |  |  |  |  |  |  | } | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | =item C<< graph ( $g ) >> | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  | =cut | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  | sub graph { | 
| 222 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub is_update { | 
| 242 | 0 |  |  | 0 | 1 |  | return 1; | 
| 243 |  |  |  |  |  |  | } | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | 1; | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | __END__ | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | =back | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | =head1 AUTHOR | 
| 252 |  |  |  |  |  |  |  | 
| 253 |  |  |  |  |  |  | Gregory Todd Williams <gwilliams@cpan.org> | 
| 254 |  |  |  |  |  |  |  | 
| 255 |  |  |  |  |  |  | =cut |