| RDF-Query documentation | Contained in the RDF-Query distribution. |
RDF::Query::Plan::SubSelect - Executable query plan for sub-select queries.
This document describes RDF::Query::Plan::SubSelect version 2.907.
Beyond the methods documented below, this class inherits methods from the RDF::Query::Plan class.
new ( $query, [ \%logging_keys ] )Returns a new SubSelect query plan object. <$query> is a RDF:Query object
representing a SELECT query.
execute ( $execution_context )nextclosequeryReturns the sub-select query object.
planReturns the sub-select query plan object.
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 )Gregory Todd Williams <gwilliams@cpan.org>
| RDF-Query documentation | Contained in the RDF-Query distribution. |
# RDF::Query::Plan::SubSelect # -----------------------------------------------------------------------------
package RDF::Query::Plan::SubSelect; use strict; use warnings; use base qw(RDF::Query::Plan); use Data::Dumper; use Scalar::Util qw(blessed); use Storable qw(store_fd fd_retrieve); use URI::Escape; 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 $query = shift; my $plan = shift; unless (blessed($plan) and $plan->isa('RDF::Query::Plan')) { Carp::confess; } my $keys = {}; my $self = $class->SUPER::new( $query, $plan ); $self->[0]{referenced_variables} = [ $query->variables ]; $self->[0]{logging_keys} = $keys; return $self; }
sub execute ($) { my $self = shift; my $context = shift; if ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "SUBSELECT plan can't be executed while already open"; } my $l = Log::Log4perl->get_logger("rdf.query.plan.subselect"); $l->trace("executing subselect"); my $plan = $self->plan; $l->trace("subselect plan: " . $plan->sse); my $iter = $plan->execute( $context ); if ($iter) { $self->[0]{iter} = $iter; $self->[0]{'open'} = 1; $self->[0]{'count'} = 0; $self->[0]{logger} = $context->logger; $self->state( $self->OPEN ); } else { warn "no iterator in execute()"; } $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 SERVICE"; } my $l = Log::Log4perl->get_logger("rdf.query.plan.subselect"); return undef unless ($self->[0]{'open'}); my $iter = $self->[0]{iter}; my $result = $iter->next; return undef unless $result; $l->trace("- got subselect result $result"); $self->[0]{'count'}++; my $row = RDF::Query::VariableBindings->new( $result ); return $row; };
sub close { my $self = shift; unless ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open SERVICE"; } my $plan = $self->plan; $plan->close(); delete $self->[0]{iter}; delete $self->[0]{args}; delete $self->[0]{count}; $self->SUPER::close(); }
sub query { my $self = shift; return $self->[1]; }
sub plan { my $self = shift; return $self->[2]; }
sub distinct { my $self = shift; # XXX this could be set at construction time, if we want to trust the remote # XXX endpoint to return DISTINCT results (when appropriate). return 0; }
sub ordered { my $self = shift; # XXX this could be set at construction time, if we want to trust the remote # XXX endpoint to return ORDERED results (when appropriate). return 0; }
sub plan_node_name { return 'subselect'; }
sub plan_prototype { my $self = shift; return qw(P); }
sub plan_node_data { my $self = shift; return ($self->plan); }
sub graph { my $self = shift; my $g = shift; die "graph is unimplemented for sub-selects"; } 1; __END__