| 1 | # RDF::Query::Algebra::Union | ||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||
| 3 | |||||||||||||
| 4 | =head1 NAME | ||||||||||||
| 5 | |||||||||||||
| 6 | RDF::Query::Algebra::Union - Algebra class for Union patterns | ||||||||||||
| 7 | |||||||||||||
| 8 | =head1 VERSION | ||||||||||||
| 9 | |||||||||||||
| 10 | This document describes RDF::Query::Algebra::Union version 2.919. | ||||||||||||
| 11 | |||||||||||||
| 12 | =cut | ||||||||||||
| 13 | |||||||||||||
| 14 | package RDF::Query::Algebra::Union; | ||||||||||||
| 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 Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 36 | ▶ | use Set::Scalar; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 36 | ▶ | use Log::Log4perl; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 36 | ▶ | use Scalar::Util qw(blessed); | ||||||||||
|
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 | |||||||||||||
| 27 | ###################################################################### | ||||||||||||
| 28 | |||||||||||||
| 29 | 36 | our ($VERSION); | |||||||||||
| 30 | 36 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | 36 | $VERSION = '2.919'; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | ###################################################################### | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 METHODS | ||||||||||||
| 37 | |||||||||||||
| 38 | Beyond the methods documented below, this class inherits methods from the | ||||||||||||
| 39 | L<RDF::Query::Algebra> class. | ||||||||||||
| 40 | |||||||||||||
| 41 | =over 4 | ||||||||||||
| 42 | |||||||||||||
| 43 | =cut | ||||||||||||
| 44 | |||||||||||||
| 45 | =item C<new ( $left, $right )> | ||||||||||||
| 46 | |||||||||||||
| 47 | Returns a new Union structure. | ||||||||||||
| 48 | |||||||||||||
| 49 | =cut | ||||||||||||
| 50 | |||||||||||||
| 51 | 8 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 52 | 8 | my $class = shift; | |||||||||||
| 53 | 8 | my $left = shift; | |||||||||||
| 54 | 8 | my $right = shift; | |||||||||||
| 55 | 8 | return bless( [ 'UNION', $left, $right ], $class ); | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =item C<< construct_args >> | ||||||||||||
| 59 | |||||||||||||
| 60 | Returns a list of arguments that, passed to this class' constructor, | ||||||||||||
| 61 | will produce a clone of this algebra pattern. | ||||||||||||
| 62 | |||||||||||||
| 63 | =cut | ||||||||||||
| 64 | |||||||||||||
| 65 | 23 | ▶ | sub construct_args { | ||||||||||
|
Subroutine
construct_args: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 66 | 23 | my $self = shift; | |||||||||||
| 67 | 23 | return ($self->first, $self->second); | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | =item C<< first >> | ||||||||||||
| 71 | |||||||||||||
| 72 | Returns the first pattern (LHS) of the union. | ||||||||||||
| 73 | |||||||||||||
| 74 | =cut | ||||||||||||
| 75 | |||||||||||||
| 76 | 45 | ▶ | sub first { | ||||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 77 | 45 | my $self = shift; | |||||||||||
| 78 | 45 | return $self->[1]; | |||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | =item C<< second >> | ||||||||||||
| 82 | |||||||||||||
| 83 | Returns the second pattern (RHS) of the union. | ||||||||||||
| 84 | |||||||||||||
| 85 | =cut | ||||||||||||
| 86 | |||||||||||||
| 87 | |||||||||||||
| 88 | =item C<< patterns >> | ||||||||||||
| 89 | |||||||||||||
| 90 | Returns the two patterns belonging to the UNION pattern. | ||||||||||||
| 91 | |||||||||||||
| 92 | =cut | ||||||||||||
| 93 | |||||||||||||
| 94 | 2 | ▶ | sub patterns { | ||||||||||
|
Subroutine
patterns: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 95 | 2 | my $self = shift; | |||||||||||
| 96 | 2 | return ($self->first, $self->second); | |||||||||||
| 97 | } | ||||||||||||
| 98 | |||||||||||||
| 99 | 45 | ▶ | sub second { | ||||||||||
|
Subroutine
second: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 100 | 45 | my $self = shift; | |||||||||||
| 101 | 45 | return $self->[2]; | |||||||||||
| 102 | } | ||||||||||||
| 103 | |||||||||||||
| 104 | =item C<< sse >> | ||||||||||||
| 105 | |||||||||||||
| 106 | Returns the SSE string for this algebra expression. | ||||||||||||
| 107 | |||||||||||||
| 108 | =cut | ||||||||||||
| 109 | |||||||||||||
| 110 | 9 | ▶ | sub sse { | ||||||||||
|
Subroutine
sse: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 111 | 9 | my $self = shift; | |||||||||||
| 112 | 9 | my $context = shift; | |||||||||||
| 113 | 9 | ▶ | my $prefix = shift || ''; | ||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 114 | 9 | ▶ | my $indent = $context->{indent} || ' '; | ||||||||||
|
Condition50%1/2
$context->{'indent'} || ' '
MC/DC0%0/1
$context->{'indent'} || ' '
$context->{'indent'}
Truth table50%1/2
A
A= $context->{'indent'}
| |||||||||||||
| 115 | |||||||||||||
| 116 | 9 | return sprintf( | |||||||||||
| 117 | "(union\n${prefix}${indent}%s\n${prefix}${indent}%s)", | ||||||||||||
| 118 | $self->first->sse( $context, "${prefix}${indent}" ), | ||||||||||||
| 119 | $self->second->sse( $context, "${prefix}${indent}" ) | ||||||||||||
| 120 | ); | ||||||||||||
| 121 | } | ||||||||||||
| 122 | |||||||||||||
| 123 | =item C<< as_sparql >> | ||||||||||||
| 124 | |||||||||||||
| 125 | Returns the SPARQL string for this algebra expression. | ||||||||||||
| 126 | |||||||||||||
| 127 | =cut | ||||||||||||
| 128 | |||||||||||||
| 129 | 2 | ▶ | sub as_sparql { | ||||||||||
|
Subroutine
as_sparql: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 130 | 2 | my $self = shift; | |||||||||||
| 131 | 2 | my $context = shift; | |||||||||||
| 132 | 2 | my $indent = shift; | |||||||||||
| 133 | 2 | my $string = sprintf( | |||||||||||
| 134 | "%s\n${indent}UNION\n${indent}%s", | ||||||||||||
| 135 | $self->first->as_sparql( { %$context, force_ggp_braces => 1 }, $indent ), | ||||||||||||
| 136 | $self->second->as_sparql( { %$context, force_ggp_braces => 1 }, $indent ), | ||||||||||||
| 137 | ); | ||||||||||||
| 138 | 2 | return $string; | |||||||||||
| 139 | } | ||||||||||||
| 140 | |||||||||||||
| 141 | =item C<< as_hash >> | ||||||||||||
| 142 | |||||||||||||
| 143 | Returns the query as a nested set of plain data structures (no objects). | ||||||||||||
| 144 | |||||||||||||
| 145 | =cut | ||||||||||||
| 146 | |||||||||||||
| 147 | 0 | ▶ | sub as_hash { | ||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 148 | 0 | my $self = shift; | |||||||||||
| 149 | 0 | my $context = shift; | |||||||||||
| 150 | return { | ||||||||||||
| 151 | type => lc($self->type), | ||||||||||||
| 152 | 0 | patterns => [ map { $_->as_hash } $self->patterns ], | |||||||||||
| 153 | }; | ||||||||||||
| 154 | } | ||||||||||||
| 155 | |||||||||||||
| 156 | =item C<< type >> | ||||||||||||
| 157 | |||||||||||||
| 158 | Returns the type of this algebra expression. | ||||||||||||
| 159 | |||||||||||||
| 160 | =cut | ||||||||||||
| 161 | |||||||||||||
| 162 | 0 | ▶ | sub type { | ||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 163 | 0 | return 'UNION'; | |||||||||||
| 164 | } | ||||||||||||
| 165 | |||||||||||||
| 166 | =item C<< referenced_variables >> | ||||||||||||
| 167 | |||||||||||||
| 168 | Returns a list of the variable names used in this algebra expression. | ||||||||||||
| 169 | |||||||||||||
| 170 | =cut | ||||||||||||
| 171 | |||||||||||||
| 172 | 5 | ▶ | sub referenced_variables { | ||||||||||
|
Subroutine
referenced_variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 173 | 5 | my $self = shift; | |||||||||||
| 174 | 5 | return RDF::Query::_uniq($self->first->referenced_variables, $self->second->referenced_variables); | |||||||||||
| 175 | } | ||||||||||||
| 176 | |||||||||||||
| 177 | =item C<< potentially_bound >> | ||||||||||||
| 178 | |||||||||||||
| 179 | Returns a list of the variable names used in this algebra expression that will | ||||||||||||
| 180 | bind values during execution. | ||||||||||||
| 181 | |||||||||||||
| 182 | =cut | ||||||||||||
| 183 | |||||||||||||
| 184 | 3 | ▶ | sub potentially_bound { | ||||||||||
|
Subroutine
potentially_bound: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 185 | 3 | my $self = shift; | |||||||||||
| 186 | 3 | return RDF::Query::_uniq($self->first->potentially_bound, $self->second->potentially_bound); | |||||||||||
| 187 | } | ||||||||||||
| 188 | |||||||||||||
| 189 | =item C<< definite_variables >> | ||||||||||||
| 190 | |||||||||||||
| 191 | Returns a list of the variable names that will be bound after evaluating this algebra expression. | ||||||||||||
| 192 | |||||||||||||
| 193 | =cut | ||||||||||||
| 194 | |||||||||||||
| 195 | 1 | ▶ | sub definite_variables { | ||||||||||
|
Subroutine
definite_variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 196 | 1 | my $self = shift; | |||||||||||
| 197 | 1 | my $seta = Set::Scalar->new( $self->first->definite_variables ); | |||||||||||
| 198 | 1 | my $setb = Set::Scalar->new( $self->second->definite_variables ); | |||||||||||
| 199 | 1 | return $seta->intersection( $setb )->members; | |||||||||||
| 200 | } | ||||||||||||
| 201 | |||||||||||||
| 202 | 36 | 1; | |||||||||||
| 203 | |||||||||||||
| 204 | __END__ | ||||||||||||