| 1 | # RDF::Query::Algebra | ||||||||||||||||||||||||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | RDF::Query::Algebra - Base class for Algebra expressions | ||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | This document describes RDF::Query::Algebra version 2.919. | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | =head1 METHODS | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | =over 4 | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | package RDF::Query::Algebra; | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | 36 | our (@ISA, @EXPORT_OK); | |||||||||||||||||||||||||||||||||
| 21 | 36 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | 36 | our $VERSION = '2.919'; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 36 | require Exporter; | |||||||||||||||||||||||||||||||||
| 25 | 36 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||
| 26 | 36 | @EXPORT_OK = qw(triple bgp ggp); | |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 30 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 31 | 36 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 36 | ▶ | use Set::Scalar; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 34 | 36 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 35 | 36 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 36 | ▶ | use RDF::Query::Expression; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 38 | 36 | ▶ | use RDF::Query::Expression::Alias; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 39 | 36 | ▶ | use RDF::Query::Expression::Nary; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 40 | 36 | ▶ | use RDF::Query::Expression::Binary; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 41 | 36 | ▶ | use RDF::Query::Expression::Unary; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 42 | 36 | ▶ | use RDF::Query::Expression::Function; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 36 | ▶ | use RDF::Query::Algebra::BasicGraphPattern; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 45 | 36 | ▶ | use RDF::Query::Algebra::Construct; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 46 | 36 | ▶ | use RDF::Query::Algebra::Filter; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 47 | 36 | ▶ | use RDF::Query::Algebra::GroupGraphPattern; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 48 | 36 | ▶ | use RDF::Query::Algebra::Optional; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 49 | 36 | ▶ | use RDF::Query::Algebra::Triple; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 50 | 36 | ▶ | use RDF::Query::Algebra::Quad; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 51 | 36 | ▶ | use RDF::Query::Algebra::Union; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 52 | 36 | ▶ | use RDF::Query::Algebra::NamedGraph; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 53 | 36 | ▶ | use RDF::Query::Algebra::Service; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 54 | 36 | ▶ | use RDF::Query::Algebra::TimeGraph; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 55 | 36 | ▶ | use RDF::Query::Algebra::Aggregate; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 56 | 36 | ▶ | use RDF::Query::Algebra::Sort; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 57 | 36 | ▶ | use RDF::Query::Algebra::Limit; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 58 | 36 | ▶ | use RDF::Query::Algebra::Offset; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 59 | 36 | ▶ | use RDF::Query::Algebra::Distinct; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 60 | 36 | ▶ | use RDF::Query::Algebra::Path; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 61 | 36 | ▶ | use RDF::Query::Algebra::Project; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 62 | 36 | ▶ | use RDF::Query::Algebra::Extend; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 63 | 36 | ▶ | use RDF::Query::Algebra::SubSelect; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 64 | 36 | ▶ | use RDF::Query::Algebra::Load; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 65 | 36 | ▶ | use RDF::Query::Algebra::Clear; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 66 | 36 | ▶ | use RDF::Query::Algebra::Update; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 67 | 36 | ▶ | use RDF::Query::Algebra::Minus; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 68 | 36 | ▶ | use RDF::Query::Algebra::Sequence; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 69 | 36 | ▶ | use RDF::Query::Algebra::Create; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 70 | 36 | ▶ | use RDF::Query::Algebra::Copy; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 71 | 36 | ▶ | use RDF::Query::Algebra::Move; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 72 | 36 | ▶ | use RDF::Query::Algebra::Table; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | 36 | ▶ | use constant SSE_TAGS => { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 75 | 'BGP' => 'RDF::Query::Algebra::BasicGraphPattern', | ||||||||||||||||||||||||||||||||||
| 76 | 'constant' => 'RDF::Query::Algebra::Constant', | ||||||||||||||||||||||||||||||||||
| 77 | 'construct' => 'RDF::Query::Algebra::Construct', | ||||||||||||||||||||||||||||||||||
| 78 | 'distinct' => 'RDF::Query::Algebra::Distinct', | ||||||||||||||||||||||||||||||||||
| 79 | 'filter' => 'RDF::Query::Algebra::Filter', | ||||||||||||||||||||||||||||||||||
| 80 | 'limit' => 'RDF::Query::Algebra::Limit', | ||||||||||||||||||||||||||||||||||
| 81 | 'namedgraph' => 'RDF::Query::Algebra::NamedGraph', | ||||||||||||||||||||||||||||||||||
| 82 | 'offset' => 'RDF::Query::Algebra::Offset', | ||||||||||||||||||||||||||||||||||
| 83 | 'project' => 'RDF::Query::Algebra::Project', | ||||||||||||||||||||||||||||||||||
| 84 | 'quad' => 'RDF::Query::Algebra::Quad', | ||||||||||||||||||||||||||||||||||
| 85 | 'service' => 'RDF::Query::Algebra::Service', | ||||||||||||||||||||||||||||||||||
| 86 | 'sort' => 'RDF::Query::Algebra::Sort', | ||||||||||||||||||||||||||||||||||
| 87 | 'triple' => 'RDF::Query::Algebra::Triple', | ||||||||||||||||||||||||||||||||||
| 88 | 'union' => 'RDF::Query::Algebra::Union', | ||||||||||||||||||||||||||||||||||
| 89 | 'join' => 'RDF::Query::Algebra::GroupGraphPattern', | ||||||||||||||||||||||||||||||||||
| 90 | 'leftjoin' => 'RDF::Query::Algebra::Optional', | ||||||||||||||||||||||||||||||||||
| 91 | 36 | }; | |||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | =item C<< potentially_bound >> | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | Returns a list of the variable names used in this algebra expression that will | ||||||||||||||||||||||||||||||||||
| 96 | bind values during execution. | ||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | =cut | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | 53 | ▶ | sub potentially_bound { | ||||||||||||||||||||||||||||||||
|
Subroutine
potentially_bound: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 101 | 53 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 102 | 53 | return $self->referenced_variables; | |||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | =item C<< referenced_blanks >> | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | Returns a list of the blank node names used in this algebra expression. | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | 21 | ▶ | sub referenced_blanks { | ||||||||||||||||||||||||||||||||
|
Subroutine
referenced_blanks: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 112 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 113 | 21 | my @list; | |||||||||||||||||||||||||||||||||
| 114 | 21 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 115 | 33 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC50%1/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table66%2/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 116 | 30 | my @blanks = $arg->referenced_blanks; | |||||||||||||||||||||||||||||||||
| 117 | 30 | push(@list, @blanks); | |||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||
| 120 | 21 | return RDF::Query::_uniq(@list); | |||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||
| 123 | =item C<< referenced_functions >> | ||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | Returns a list of the Function URIs used in this algebra expression. | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | 993 | ▶ | sub referenced_functions { | ||||||||||||||||||||||||||||||||
|
Subroutine
referenced_functions: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 130 | 993 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 131 | 993 | my @list; | |||||||||||||||||||||||||||||||||
| 132 | 993 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 133 | 2153 | ▶ | if (blessed($arg)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 134 | 1905 | ▶ | if ($arg->isa('RDF::Query::Expression::Function')) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 135 | 33 | push(@list, $arg->uri); | |||||||||||||||||||||||||||||||||
| 136 | } elsif ($arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||||
| 137 | 836 | my @funcs = $arg->referenced_functions; | |||||||||||||||||||||||||||||||||
| 138 | 836 | push(@list, @funcs); | |||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||
| 142 | 993 | return RDF::Query::_uniq(@list); | |||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | =item C<< check_duplicate_blanks >> | ||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | Returns true if blank nodes respect the SPARQL rule of no blank-label re-use | ||||||||||||||||||||||||||||||||||
| 148 | across BGPs, otherwise throws a RDF::Query::Error::QueryPatternError exception. | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | 126 | ▶ | sub check_duplicate_blanks { | ||||||||||||||||||||||||||||||||
|
Subroutine
check_duplicate_blanks: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 153 | 126 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 154 | 126 | my @data; | |||||||||||||||||||||||||||||||||
| 155 | 126 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 156 | 307 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC100%2/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table100%3/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 157 | 127 | $arg->check_duplicate_blanks(); | |||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 126 | return 1; | |||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | 108 | ▶ | sub _referenced_blanks { | ||||||||||||||||||||||||||||||||
|
Subroutine
_referenced_blanks: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 165 | 108 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 166 | 108 | my @data; | |||||||||||||||||||||||||||||||||
| 167 | 108 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 168 | 165 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC100%2/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table100%3/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 169 | 127 | push( @data, $arg->_referenced_blanks ); | |||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||
| 172 | 108 | return @data; | |||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | =item C<< qualify_uris ( \%namespaces, $base_uri ) >> | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | Returns a new algebra pattern where all referenced Resource nodes representing | ||||||||||||||||||||||||||||||||||
| 178 | QNames (ns:local) are qualified using the supplied %namespaces. | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | =cut | ||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||
| 182 | 42 | ▶ | sub qualify_uris { | ||||||||||||||||||||||||||||||||
|
Subroutine
qualify_uris: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 183 | 42 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 184 | 42 | my $class = ref($self); | |||||||||||||||||||||||||||||||||
| 185 | 42 | my $ns = shift; | |||||||||||||||||||||||||||||||||
| 186 | 42 | my $base_uri = shift; | |||||||||||||||||||||||||||||||||
| 187 | 42 | my @args; | |||||||||||||||||||||||||||||||||
| 188 | 42 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 189 | 100 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC50%1/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table66%2/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 190 | 25 | push(@args, $arg->qualify_uris( $ns, $base_uri )); | |||||||||||||||||||||||||||||||||
| 191 | ▶ | } elsif (blessed($arg) and $arg->isa('RDF::Query::Node::Resource')) { | |||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Node::Resource")
MC/DC50%1/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Node::Resource")
builtin::blessed($arg)
$arg->isa("RDF::Query::Node::Resource")
Truth table66%2/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Node::Resource")
| |||||||||||||||||||||||||||||||||||
| 192 | 34 | my $uri = $arg->uri_value; | |||||||||||||||||||||||||||||||||
| 193 | 34 | ▶ | if (ref($uri)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 194 | 0 | $uri = join('', $ns->{ $uri->[0] }, $uri->[1]); | |||||||||||||||||||||||||||||||||
| 195 | 0 | $arg = RDF::Query::Node::Resource->new( $uri ); | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | 34 | push(@args, $arg); | |||||||||||||||||||||||||||||||||
| 198 | } else { | ||||||||||||||||||||||||||||||||||
| 199 | 41 | push(@args, $arg); | |||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||
| 202 | 42 | return $class->new( @args ); | |||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | =item C<< bind_variables ( \%bound ) >> | ||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | Returns a new algebra pattern with variables named in %bound replaced by their corresponding bound values. | ||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||
| 209 | =cut | ||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub bind_variables { | ||||||||||||||||||||||||||||||||
|
Subroutine
bind_variables: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 213 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||||||||
| 214 | 0 | my $bound = shift; | |||||||||||||||||||||||||||||||||
| 215 | 0 | my @args; | |||||||||||||||||||||||||||||||||
| 216 | 0 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/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 table0%0/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 218 | 0 | push(@args, $arg->bind_variables( $bound )); | |||||||||||||||||||||||||||||||||
| 219 | ▶ | } elsif (blessed($arg) and $arg->isa('RDF::Trine::Node::Variable') and exists($bound->{ $arg->name })) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
builtin::blessed($arg) and $arg->isa("RDF::Trine::Node::Variable") and exists $$bound{$arg->name}
builtin::blessed($arg) and $arg->isa("RDF::Trine::Node::Variable")
MC/DC0%0/3
builtin::blessed($arg) and $arg->isa("RDF::Trine::Node::Variable") and exists $$bound{$arg->name}
builtin::blessed($arg)
$arg->isa("RDF::Trine::Node::Variable")
exists $$bound{$arg->name}
Truth table0%0/4
A and B and C
A= builtin::blessed($arg)B= $arg->isa("RDF::Trine::Node::Variable")C= exists $$bound{$arg->name}
| |||||||||||||||||||||||||||||||||||
| 220 | 0 | push(@args, $bound->{ $arg->name }); | |||||||||||||||||||||||||||||||||
| 221 | } else { | ||||||||||||||||||||||||||||||||||
| 222 | 0 | push(@args, $arg); | |||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||
| 225 | 0 | return $class->new( @args ); | |||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | =item C<< is_solution_modifier >> | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | Returns true if this node is a solution modifier. | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | 545 | ▶ | sub is_solution_modifier { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_solution_modifier: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 235 | 545 | return 0; | |||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | =item C<< subpatterns_of_type ( $type [, $block] ) >> | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | Returns a list of Algebra patterns matching C<< $type >> (tested with C<< isa >>). | ||||||||||||||||||||||||||||||||||
| 241 | If C<< $block >> is given, then matching stops descending a subtree if the current | ||||||||||||||||||||||||||||||||||
| 242 | node is of type C<< $block >>, continuing matching on other subtrees. | ||||||||||||||||||||||||||||||||||
| 243 | This list includes the current algebra object if it matches C<< $type >>, and is | ||||||||||||||||||||||||||||||||||
| 244 | generated in infix order. | ||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | =cut | ||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||
| 248 | 2701 | ▶ | sub subpatterns_of_type { | ||||||||||||||||||||||||||||||||
|
Subroutine
subpatterns_of_type: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 249 | 2701 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 250 | 2701 | my $type = shift; | |||||||||||||||||||||||||||||||||
| 251 | 2701 | my $block = shift; | |||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | 2701 | ▶ | return if ($block and $self->isa($block)); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$block and $self->isa($block)
MC/DC100%2/2
$block and $self->isa($block)
$block
$self->isa($block)
Truth table100%3/3
A and B
A= $blockB= $self->isa($block)
| |||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 2700 | my @patterns; | |||||||||||||||||||||||||||||||||
| 256 | 2700 | ▶ | push(@patterns, $self) if ($self->isa($type)); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 257 | 2700 | foreach my $arg ($self->construct_args) { | |||||||||||||||||||||||||||||||||
| 258 | 5897 | ▶ | if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
MC/DC100%2/2
builtin::blessed($arg) and $arg->isa("RDF::Query::Algebra")
builtin::blessed($arg)
$arg->isa("RDF::Query::Algebra")
Truth table100%3/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query::Algebra")
| |||||||||||||||||||||||||||||||||||
| 259 | 2270 | push(@patterns, $arg->subpatterns_of_type($type, $block)); | |||||||||||||||||||||||||||||||||
| 260 | ▶ | } elsif (blessed($arg) and $arg->isa('RDF::Query')) { | |||||||||||||||||||||||||||||||||
|
Condition100%3/3
builtin::blessed($arg) and $arg->isa("RDF::Query")
MC/DC100%2/2
builtin::blessed($arg) and $arg->isa("RDF::Query")
builtin::blessed($arg)
$arg->isa("RDF::Query")
Truth table100%3/3
A and B
A= builtin::blessed($arg)B= $arg->isa("RDF::Query")
| |||||||||||||||||||||||||||||||||||
| 261 | 5 | my $pattern = $arg->pattern; | |||||||||||||||||||||||||||||||||
| 262 | 5 | push(@patterns, $pattern->subpatterns_of_type($type, $block)); | |||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||
| 265 | 2700 | return @patterns; | |||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | =item C<< from_sse ( $sse, \%context ) >> | ||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | Given an SSE serialization, returns the corresponding algebra expression. | ||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | 4 | ▶ | sub from_sse { | ||||||||||||||||||||||||||||||||
|
Subroutine
from_sse: called CC=10 SCAR=29.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 275 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 276 | 4 | my $context = $_[1]; | |||||||||||||||||||||||||||||||||
| 277 | 4 | ▶ | if (substr($_[0], 0, 1) eq '(') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 278 | 3 | for ($_[0]) { | |||||||||||||||||||||||||||||||||
| 279 | 3 | ▶ | if (my ($tag) = m/^[(](\w+)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 280 | 3 | ▶ | if ($tag eq 'prefix') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 281 | 0 | s/^[(]prefix\s*[(]\s*//; | |||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | my $c = { %{ $context || {} } }; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$context || {}
MC/DC0%0/1
$context || {}
$context
Truth table0%0/2
A
A= $context
| |||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | while (my ($ns, $iri) = m/^[(](\S+):\s*<([^>]+)>[)]/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 284 | 0 | s/^[(](\S+):\s*<([^>]+)>[)]\s*//; | |||||||||||||||||||||||||||||||||
| 285 | 0 | $c->{namespaces}{ $ns } = $iri; | |||||||||||||||||||||||||||||||||
| 286 | 0 | $context = $c; | |||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||
| 288 | 0 | s/^[)]\s*//; | |||||||||||||||||||||||||||||||||
| 289 | 0 | my $alg = $class->from_sse( $_, $c ); | |||||||||||||||||||||||||||||||||
| 290 | 0 | s/^[)]\s*//; | |||||||||||||||||||||||||||||||||
| 291 | 0 | return $alg; | |||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||
| 294 | 3 | ▶ | if (my $class = SSE_TAGS->{ $tag }) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 295 | 3 | ▶ | if ($class->can('_from_sse')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 296 | 2 | return $class->_from_sse( $_, $context ); | |||||||||||||||||||||||||||||||||
| 297 | } else { | ||||||||||||||||||||||||||||||||||
| 298 | 1 | s/^[(](\w+)\s*//; | |||||||||||||||||||||||||||||||||
| 299 | 1 | my @nodes; | |||||||||||||||||||||||||||||||||
| 300 | 1 | ▶ | while (my $alg = $class->from_sse( $_, $context )) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 301 | 1 | push(@nodes, $alg); | |||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | 1 | return $class->new( @nodes ); | |||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||
| 306 | 0 | throw RDF::Query::Error -text => "Unknown SSE tag '$tag' in SSE string: >>$_<<"; | |||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||
| 308 | } else { | ||||||||||||||||||||||||||||||||||
| 309 | 0 | throw RDF::Trine::Error -text => "Cannot parse pattern from SSE string: >>$_<<"; | |||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||
| 313 | 1 | return; | |||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||
| 317 | =back | ||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||
| 319 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | =over 4 | ||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | =item C<< triple ( $subj, $pred, $obj ) >> | ||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||
| 325 | Returns a RDF::Query::Algebra::Triple object with the supplied node objects. | ||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||
| 327 | =cut | ||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub triple { | ||||||||||||||||||||||||||||||||
|
Subroutine
triple: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 330 | 0 | my @nodes = @_[0..2]; | |||||||||||||||||||||||||||||||||
| 331 | 0 | return RDF::Query::Algebra::Triple->new( @nodes ); | |||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | =item C<< bgp ( @triples ) >> | ||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | Returns a RDF::Query::Algebra::BasicGraphPattern object with the supplied triples. | ||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||
| 338 | =cut | ||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub bgp { | ||||||||||||||||||||||||||||||||
|
Subroutine
bgp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 341 | 0 | my @triples = @_; | |||||||||||||||||||||||||||||||||
| 342 | 0 | return RDF::Query::Algebra::BasicGraphPattern->new( @triples ); | |||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||
| 345 | =item C<< ggp ( @patterns ) >> | ||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||
| 347 | Returns a RDF::Query::Algebra::GroupGraphPattern object with the supplied algebra patterns. | ||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | sub ggp { | ||||||||||||||||||||||||||||||||
|
Subroutine
ggp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 352 | 0 | my @patterns = @_; | |||||||||||||||||||||||||||||||||
| 353 | 0 | return RDF::Query::Algebra::GroupGraphPattern->new( @patterns ); | |||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||
| 358 | 36 | 1; | |||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||
| 360 | __END__ | ||||||||||||||||||||||||||||||||||