| RDF-Query documentation | Contained in the RDF-Query distribution. |
RDF::Query::Plan::Constant - Executable query plan for Constants.
This document describes RDF::Query::Plan::Constant version 2.907.
Beyond the methods documented below, this class inherits methods from the RDF::Query::Plan class.
new ( @variable_bindings )execute ( $execution_context )bindingsReturns a list of the variable bindings for this constant result set.
is_unitReturns true if this constant result set is comprised of a single, empty variable binding.
nextclosesizedistinctReturns 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.
Gregory Todd Williams <gwilliams@cpan.org>
| RDF-Query documentation | Contained in the RDF-Query distribution. |
# RDF::Query::Plan::Constant # -----------------------------------------------------------------------------
package RDF::Query::Plan::Constant; use strict; use warnings; use base qw(RDF::Query::Plan); ###################################################################### our ($VERSION); BEGIN { $VERSION = '2.907'; } ######################################################################
sub new { my $class = shift; my @binds = @_; my $self = $class->SUPER::new( \@binds ); $self->[0]{referenced_variables} = [ keys %{ $binds[0] } ]; return $self; }
sub execute ($) { my $self = shift; my $context = shift; if ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "CONSTANT plan can't be executed while already open"; } $self->[0]{'index'} = 0; $self->state( $self->OPEN ); $self; }
sub bindings { my $self = shift; my $binds = $self->[1] || []; return @$binds; }
sub is_unit { my $self = shift; my @binds = $self->bindings; return 0 unless scalar(@binds) == 1; my @keys = keys %{ $binds[0] }; return not(scalar(@keys)); }
sub next { my $self = shift; unless ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "next() cannot be called on an un-open CONSTANT"; } my $binds = $self->[1]; if ($self->[0]{'index'} > $#{ $binds }) { return; } my $row = $binds->[ $self->[0]{'index'}++ ]; if ($row) { return RDF::Query::VariableBindings->new( $row ); } else { return; } }
sub close { my $self = shift; unless ($self->state == $self->OPEN) { throw RDF::Query::Error::ExecutionError -text => "close() cannot be called on an un-open CONSTANT"; } delete $self->[0]{'index'}; $self->SUPER::close(); }
sub size { my $self = shift; return scalar( @{ $self->[1] } ); }
sub distinct { # XXX could check constant data to determine if it's unique return 0; }
sub ordered { # XXX could check constant data to determine if it's ordered return []; }
sub plan_node_name { return 'table'; }
sub plan_prototype { my $self = shift; return qw(*V); }
sub plan_node_data { my $self = shift; my $binds = $self->[1]; return @$binds; } 1; __END__