| 1 | # RDF::Query::Algebra::GroupGraphPattern | ||||||||||||||||||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | RDF::Query::Algebra::GroupGraphPattern - Algebra class for GroupGraphPattern patterns | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This document describes RDF::Query::Algebra::GroupGraphPattern version 2.919. | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | package RDF::Query::Algebra::GroupGraphPattern; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 36 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 36 | ▶ | use base qw(RDF::Query::Algebra); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 36 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 36 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 36 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 36 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 36 | ▶ | use Carp qw(carp croak confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 36 | ▶ | use RDF::Query::Error qw(:try); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 36 | ▶ | use Time::HiRes qw(gettimeofday tv_interval); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 36 | ▶ | use RDF::Trine::Iterator qw(sgrep smap swatch); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | ###################################################################### | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 36 | our ($VERSION, $debug); | |||||||||||||||||||||||||||
| 33 | 36 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 36 | $debug = 0; | |||||||||||||||||||||||||||
| 35 | 36 | $VERSION = '2.919'; | |||||||||||||||||||||||||||
| 36 | 36 | our %SERVICE_BLOOM_IGNORE = ('http://dbpedia.org/sparql' => 1); # by default, assume dbpedia doesn't implement k:bloom(). | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | ###################################################################### | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 METHODS | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Beyond the methods documented below, this class inherits methods from the | ||||||||||||||||||||||||||||
| 44 | L<RDF::Query::Algebra> class. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =over 4 | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =item C<new ( @graph_patterns )> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Returns a new GroupGraphPattern structure. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 356 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 356 | my $class = shift; | |||||||||||||||||||||||||||
| 58 | 356 | my @patterns = @_; | |||||||||||||||||||||||||||
| 59 | 356 | my $self = bless( \@patterns, $class ); | |||||||||||||||||||||||||||
| 60 | 356 | foreach my $p (@patterns) { | |||||||||||||||||||||||||||
| 61 | 393 | ▶ | unless (blessed($p)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | Carp::cluck; | |||||||||||||||||||||||||||
| 63 | 0 | throw RDF::Query::Error::MethodInvocationError -text => "GroupGraphPattern constructor called with unblessed value"; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 356 | return $self; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =item C<< construct_args >> | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Returns a list of arguments that, passed to this class' constructor, | ||||||||||||||||||||||||||||
| 72 | will produce a clone of this algebra pattern. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1064 | ▶ | sub construct_args { | ||||||||||||||||||||||||||
|
Subroutine
construct_args: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 1064 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | 1064 | return ($self->patterns); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =item C<< patterns >> | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Returns a list of the graph patterns in this GGP. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 2143 | ▶ | sub patterns { | ||||||||||||||||||||||||||
|
Subroutine
patterns: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 2143 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | 2143 | return @{ $self }; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item C<< add_pattern >> | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Appends a new child pattern to the GGP. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub add_pattern { | ||||||||||||||||||||||||||
|
Subroutine
add_pattern: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 100 | 0 | my $pattern = shift; | |||||||||||||||||||||||||||
| 101 | 0 | push( @{ $self }, $pattern ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =item C<< quads >> | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Returns a list of the quads belonging to this GGP. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 12 | ▶ | sub quads { | ||||||||||||||||||||||||||
|
Subroutine
quads: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 112 | 12 | my @quads; | |||||||||||||||||||||||||||
| 113 | my %bgps; | ||||||||||||||||||||||||||||
| 114 | 12 | foreach my $p ($self->subpatterns_of_type('RDF::Query::Algebra::NamedGraph')) { | |||||||||||||||||||||||||||
| 115 | 4 | push(@quads, $p->quads); | |||||||||||||||||||||||||||
| 116 | 4 | foreach my $bgp ($p->subpatterns_of_type('RDF::Query::Algebra::BasicGraphPattern')) { | |||||||||||||||||||||||||||
| 117 | 4 | $bgps{ refaddr($bgp) }++; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 12 | foreach my $p ($self->subpatterns_of_type('RDF::Query::Algebra::BasicGraphPattern')) { | |||||||||||||||||||||||||||
| 121 | 14 | ▶ | next if ($bgps{ refaddr($p) }); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 10 | push(@quads, $p->quads); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 12 | return @quads; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =item C<< sse >> | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | Returns the SSE string for this algebra expression. | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =cut | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 637 | ▶ | sub sse { | ||||||||||||||||||||||||||
|
Subroutine
sse: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 637 | my $self = shift; | |||||||||||||||||||||||||||
| 135 | 637 | my $context = shift; | |||||||||||||||||||||||||||
| 136 | 637 | ▶ | my $prefix = shift || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 137 | 637 | ▶ | my $indent = ($context->{indent} ||= "\t"); | ||||||||||||||||||||||||||
|
Condition50%1/2
$context->{"indent"} ||= "\t"
MC/DC0%0/1
$context->{"indent"} ||= "\t"
$context->{"indent"}
Truth table50%1/2
A
A= $context->{"indent"}
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 637 | my @patterns = $self->patterns; | |||||||||||||||||||||||||||
| 140 | 637 | ▶ | if (scalar(@patterns) == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 563 | return $patterns[0]->sse( $context, $prefix ); | |||||||||||||||||||||||||||
| 142 | } else { | ||||||||||||||||||||||||||||
| 143 | return sprintf( | ||||||||||||||||||||||||||||
| 144 | "(join\n${prefix}${indent}%s)", | ||||||||||||||||||||||||||||
| 145 | 74 | join("\n${prefix}${indent}", map { $_->sse( $context, "${prefix}${indent}" ) } @patterns) | |||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =item C<< explain >> | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | Returns a string serialization of the algebra appropriate for display on the | ||||||||||||||||||||||||||||
| 153 | command line. | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub explain { | ||||||||||||||||||||||||||
|
Subroutine
explain: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | 0 | my $s = shift; | |||||||||||||||||||||||||||
| 160 | 0 | my $count = shift; | |||||||||||||||||||||||||||
| 161 | 0 | my $indent = $s x $count; | |||||||||||||||||||||||||||
| 162 | 0 | my $string = "${indent}group graph pattern\n"; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | my @patterns = $self->patterns; | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | if (scalar(@patterns) == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | $string .= $patterns[0]->explain( $s, $count+1 ); | |||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||
| 168 | 0 | foreach my $p (@patterns) { | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($p->can('explain')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | $string .= $p->explain( $s, $count+1 ); | |||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||
| 172 | 0 | my $str = $p->sse; | |||||||||||||||||||||||||||
| 173 | 0 | ▶ | $str .= "\n" unless (substr($str,-1) eq "\n"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 0 | $string .= $str; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 0 | return $string; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =item C<< as_sparql >> | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | Returns the SPARQL string for this algebra expression. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 80 | ▶ | sub as_sparql { | ||||||||||||||||||||||||||
|
Subroutine
as_sparql: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 188 | 80 | my $self = shift; | |||||||||||||||||||||||||||
| 189 | 80 | ▶ | my $context = shift || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 190 | 80 | ▶ | my $indent = shift || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 191 | 80 | my $force = $context->{force_ggp_braces}; | |||||||||||||||||||||||||||
| 192 | 80 | ▶ | $force = 0 unless (defined($force)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 80 | ▶ | if ($force) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 49 | $context->{force_ggp_braces}--; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 80 | my @patterns; | |||||||||||||||||||||||||||
| 198 | 80 | my @p = $self->patterns; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 80 | ▶ | if (scalar(@p) == 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 201 | 0 | return "{}"; | |||||||||||||||||||||||||||
| 202 | ▶ | } elsif (scalar(@p) == 1 and not($force)) { | |||||||||||||||||||||||||||
|
Condition100%3/3
scalar @p == 1 and not $force
MC/DC100%2/2
scalar @p == 1 and not $force
scalar @p == 1
not $force
Truth table100%3/3
A and not(B)
A= scalar @p == 1B= not $force
| |||||||||||||||||||||||||||||
| 203 | 3 | return $p[0]->as_sparql($context, $indent); | |||||||||||||||||||||||||||
| 204 | } else { | ||||||||||||||||||||||||||||
| 205 | 77 | foreach my $p (@p) { | |||||||||||||||||||||||||||
| 206 | 107 | push(@patterns, $p->as_sparql( $context, "$indent\t" )); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 77 | my $patterns = join("\n${indent}\t", @patterns); | |||||||||||||||||||||||||||
| 209 | 77 | my $string = sprintf("{\n${indent}\t%s\n${indent}}", $patterns); | |||||||||||||||||||||||||||
| 210 | 77 | return $string; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =item C<< as_hash >> | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | Returns the query as a nested set of plain data structures (no objects). | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =cut | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub as_hash { | ||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 222 | 0 | my $context = shift; | |||||||||||||||||||||||||||
| 223 | return { | ||||||||||||||||||||||||||||
| 224 | type => lc($self->type), | ||||||||||||||||||||||||||||
| 225 | 0 | patterns => [ map { $_->as_hash } $self->patterns ], | |||||||||||||||||||||||||||
| 226 | }; | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =item C<< as_spin ( $model ) >> | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | Adds statements to the given model to represent this algebra object in the | ||||||||||||||||||||||||||||
| 232 | SPARQL Inferencing Notation (L<http://www.spinrdf.org/>). | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | =cut | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub as_spin { | ||||||||||||||||||||||||||
|
Subroutine
as_spin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 237 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 238 | 0 | my $model = shift; | |||||||||||||||||||||||||||
| 239 | 0 | return map { $_->as_spin($model) } $self->patterns; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =item C<< type >> | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Returns the type of this algebra expression. | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 0 | return 'GGP'; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =item C<< referenced_variables >> | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | Returns a list of the variable names used in this algebra expression. | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =cut | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 88 | ▶ | sub referenced_variables { | ||||||||||||||||||||||||||
|
Subroutine
referenced_variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 260 | 88 | my $self = shift; | |||||||||||||||||||||||||||
| 261 | 88 | return RDF::Query::_uniq(map { $_->referenced_variables } $self->patterns); | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =item C<< potentially_bound >> | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Returns a list of the variable names used in this algebra expression that will | ||||||||||||||||||||||||||||
| 267 | bind values during execution. | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =cut | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 51 | ▶ | sub potentially_bound { | ||||||||||||||||||||||||||
|
Subroutine
potentially_bound: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 272 | 51 | my $self = shift; | |||||||||||||||||||||||||||
| 273 | 51 | return RDF::Query::_uniq(map { $_->potentially_bound } $self->patterns); | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =item C<< definite_variables >> | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | Returns a list of the variable names that will be bound after evaluating this algebra expression. | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 7 | ▶ | sub definite_variables { | ||||||||||||||||||||||||||
|
Subroutine
definite_variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 284 | 7 | return RDF::Query::_uniq(map { $_->definite_variables } $self->patterns); | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | =item C<< check_duplicate_blanks >> | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | Returns true if blank nodes respect the SPARQL rule of no blank-label re-use | ||||||||||||||||||||||||||||
| 290 | across BGPs, otherwise throws a RDF::Query::Error::QueryPatternError exception. | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 180 | ▶ | sub check_duplicate_blanks { | ||||||||||||||||||||||||||
|
Subroutine
check_duplicate_blanks: called CC=7 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 180 | my $self = shift; | |||||||||||||||||||||||||||
| 296 | 180 | my @data; | |||||||||||||||||||||||||||
| 297 | 180 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||
| 298 | 174 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC0%0/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table33%1/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||
| 299 | 174 | push(@data, $arg->_referenced_blanks()); | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 180 | my %seen; | |||||||||||||||||||||||||||
| 304 | 180 | foreach my $d (@data) { | |||||||||||||||||||||||||||
| 305 | 193 | foreach my $b (@$d) { | |||||||||||||||||||||||||||
| 306 | 30 | ▶ | if ($seen{ $b }++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 0 | throw RDF::Query::Error::QueryPatternError -text => "Same blank node identifier ($b) used in more than one BasicGraphPattern."; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 180 | return 1; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 36 | 1; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | __END__ | ||||||||||||||||||||||||||||