| RDF-Query documentation | Contained in the RDF-Query distribution. |
RDF::Query::Plan::Load - Executable query plan for LOAD operations.
This document describes RDF::Query::Plan::Load version 2.907.
Beyond the methods documented below, this class inherits methods from the RDF::Query::Plan class.
new ( $url, $graph )execute ( $execution_context )nextcloseurlReturns the URL to load data from.
namedgraphReturns the optional graph name to load the data with.
distinctReturns true if the pattern is guaranteed to return distinct results.
orderedReturns true if the pattern is guaranteed to return ordered results.
plan_node_nameReturns the string name of this plan node, suitable for use in serialization.
plan_prototypeReturns a list of scalar identifiers for the type of the content (children) nodes of this plan node. See RDF::Query::Plan for a list of the allowable identifiers.
plan_node_dataReturns the data for this plan node that corresponds to the values described by
the signature returned by plan_prototype.
graph ( $g )is_updateReturns true if the plan represents an update operation.
Gregory Todd Williams <gwilliams@cpan.org>
| RDF-Query documentation | Contained in the RDF-Query distribution. |
# RDF::Query::Plan::Load # -----------------------------------------------------------------------------
package RDF::Query::Plan::Load; use strict; use warnings; use base qw(RDF::Query::Plan); use Log::Log4perl; use Scalar::Util qw(blessed); use Time::HiRes qw(gettimeofday tv_interval); use RDF::Query::Error qw(:try); use RDF::Query::ExecutionContext; use RDF::Query::VariableBindings; ###################################################################### our ($VERSION); BEGIN { $VERSION = '2.907'; } ######################################################################
sub new { my $class = shift; my $url = shift; my $graph = shift; my $self = $class->SUPER::new( $url, $graph ); return $self; }
sub execute ($) { my $self = shift; my $context = shift; if ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "LOAD plan can't be executed while already open"; } my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); $l->trace( "executing RDF::Query::Plan::Load" ); my %args = ($self->namedgraph) ? (context => $self->namedgraph) : (); my $ok = 0; try { RDF::Trine::Parser->parse_url_into_model( $self->url->uri_value, $context->model, %args ); $ok = 1; } catch RDF::Trine::Error with {}; $self->[0]{ok} = $ok; $self->state( $self->OPEN ); $self; }
sub next { my $self = shift; unless ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open LOAD"; } my $l = Log::Log4perl->get_logger("rdf.query.plan.load"); $self->close(); return $self->[0]{ok}; }
sub close { my $self = shift; unless ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open LOAD"; } delete $self->[0]{ok}; $self->SUPER::close(); }
sub url { my $self = shift; return $self->[1]; }
sub namedgraph { my $self = shift; return $self->[2]; }
sub distinct { return 1; }
sub ordered { return []; }
sub plan_node_name { return 'load'; }
sub plan_prototype { my $self = shift; return qw(N N); }
sub plan_node_data { my $self = shift; return ($self->url, $self->namedgraph); }
sub graph { my $self = shift; my $g = shift; my $label = $self->graph_labels; my $url = $self->url->uri_value; $g->add_node( "$self", label => "Load" . $self->graph_labels ); $g->add_node( "${self}$url", label => $url ); $g->add_edge( "$self" => "${self}$url", label => 'url' ); return "$self"; }
sub is_update { return 1; } 1; __END__