This file is indexed.

/usr/share/perl5/RDF/Query/Algebra.pm is in librdf-query-perl 2.918-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# RDF::Query::Algebra
# -----------------------------------------------------------------------------

=head1 NAME

RDF::Query::Algebra - Base class for Algebra expressions

=head1 VERSION

This document describes RDF::Query::Algebra version 2.918.

=head1 METHODS

=over 4

=cut

package RDF::Query::Algebra;

our (@ISA, @EXPORT_OK);
BEGIN {
	our $VERSION	= '2.918';
	
	require Exporter;
	@ISA		= qw(Exporter);
	@EXPORT_OK	= qw(triple bgp ggp);
}

use strict;
use warnings;
no warnings 'redefine';

use Set::Scalar;
use Scalar::Util qw(blessed);
use Data::Dumper;

use RDF::Query::Expression;
use RDF::Query::Expression::Alias;
use RDF::Query::Expression::Nary;
use RDF::Query::Expression::Binary;
use RDF::Query::Expression::Unary;
use RDF::Query::Expression::Function;

use RDF::Query::Algebra::BasicGraphPattern;
use RDF::Query::Algebra::Construct;
use RDF::Query::Algebra::Filter;
use RDF::Query::Algebra::GroupGraphPattern;
use RDF::Query::Algebra::Optional;
use RDF::Query::Algebra::Triple;
use RDF::Query::Algebra::Quad;
use RDF::Query::Algebra::Union;
use RDF::Query::Algebra::NamedGraph;
use RDF::Query::Algebra::Service;
use RDF::Query::Algebra::TimeGraph;
use RDF::Query::Algebra::Aggregate;
use RDF::Query::Algebra::Sort;
use RDF::Query::Algebra::Limit;
use RDF::Query::Algebra::Offset;
use RDF::Query::Algebra::Distinct;
use RDF::Query::Algebra::Path;
use RDF::Query::Algebra::Project;
use RDF::Query::Algebra::Extend;
use RDF::Query::Algebra::SubSelect;
use RDF::Query::Algebra::Load;
use RDF::Query::Algebra::Clear;
use RDF::Query::Algebra::Update;
use RDF::Query::Algebra::Minus;
use RDF::Query::Algebra::Sequence;
use RDF::Query::Algebra::Create;
use RDF::Query::Algebra::Copy;
use RDF::Query::Algebra::Move;
use RDF::Query::Algebra::Table;

use constant SSE_TAGS	=> {
	'BGP'					=> 'RDF::Query::Algebra::BasicGraphPattern',
	'constant'				=> 'RDF::Query::Algebra::Constant',
	'construct'				=> 'RDF::Query::Algebra::Construct',
	'distinct'				=> 'RDF::Query::Algebra::Distinct',
	'filter'				=> 'RDF::Query::Algebra::Filter',
	'limit'					=> 'RDF::Query::Algebra::Limit',
	'namedgraph'			=> 'RDF::Query::Algebra::NamedGraph',
	'offset'				=> 'RDF::Query::Algebra::Offset',
	'project'				=> 'RDF::Query::Algebra::Project',
	'quad'					=> 'RDF::Query::Algebra::Quad',
	'service'				=> 'RDF::Query::Algebra::Service',
	'sort'					=> 'RDF::Query::Algebra::Sort',
	'triple'				=> 'RDF::Query::Algebra::Triple',
	'union'					=> 'RDF::Query::Algebra::Union',
	'join'					=> 'RDF::Query::Algebra::GroupGraphPattern',
	'leftjoin'				=> 'RDF::Query::Algebra::Optional',
};

=item C<< potentially_bound >>

Returns a list of the variable names used in this algebra expression that will
bind values during execution.

=cut

sub potentially_bound {
	my $self	= shift;
	return $self->referenced_variables;
}

=item C<< referenced_blanks >>

Returns a list of the blank node names used in this algebra expression.

=cut

sub referenced_blanks {
	my $self	= shift;
	my @list;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			my @blanks	= $arg->referenced_blanks;
			push(@list, @blanks);
		}
	}
	return RDF::Query::_uniq(@list);
}

=item C<< referenced_functions >>

Returns a list of the Function URIs used in this algebra expression.

=cut

sub referenced_functions {
	my $self	= shift;
	my @list;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg)) {
			if ($arg->isa('RDF::Query::Expression::Function')) {
				push(@list, $arg->uri);
			} elsif ($arg->isa('RDF::Query::Algebra')) {
				my @funcs	= $arg->referenced_functions;
				push(@list, @funcs);
			}
		}
	}
	return RDF::Query::_uniq(@list);
}

=item C<< check_duplicate_blanks >>

Returns true if blank nodes respect the SPARQL rule of no blank-label re-use
across BGPs, otherwise throws a RDF::Query::Error::QueryPatternError exception.

=cut

sub check_duplicate_blanks {
	my $self	= shift;
	my @data;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			$arg->check_duplicate_blanks();
		}
	}
	
	return 1;
}

sub _referenced_blanks {
	my $self	= shift;
	my @data;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			push( @data, $arg->_referenced_blanks );
		}
	}
	return @data;
}

=item C<< qualify_uris ( \%namespaces, $base_uri ) >>

Returns a new algebra pattern where all referenced Resource nodes representing
QNames (ns:local) are qualified using the supplied %namespaces.

=cut

sub qualify_uris {
	my $self	= shift;
	my $class	= ref($self);
	my $ns		= shift;
	my $base_uri	= shift;
	my @args;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			push(@args, $arg->qualify_uris( $ns, $base_uri ));
		} elsif (blessed($arg) and $arg->isa('RDF::Query::Node::Resource')) {
			my $uri	= $arg->uri_value;
			if (ref($uri)) {
				$uri	= join('', $ns->{ $uri->[0] }, $uri->[1]);
				$arg	= RDF::Query::Node::Resource->new( $uri );
			}
			push(@args, $arg);
		} else {
			push(@args, $arg);
		}
	}
	return $class->new( @args );
}

=item C<< bind_variables ( \%bound ) >>

Returns a new algebra pattern with variables named in %bound replaced by their corresponding bound values.

=cut

sub bind_variables {
	my $self	= shift;
	my $class	= ref($self);
	my $bound	= shift;
	my @args;
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			push(@args, $arg->bind_variables( $bound ));
		} elsif (blessed($arg) and $arg->isa('RDF::Trine::Node::Variable') and exists($bound->{ $arg->name })) {
			push(@args, $bound->{ $arg->name });
		} else {
			push(@args, $arg);
		}
	}
	return $class->new( @args );
}

=item C<< is_solution_modifier >>

Returns true if this node is a solution modifier.

=cut

sub is_solution_modifier {
	return 0;
}

=item C<< subpatterns_of_type ( $type [, $block] ) >>

Returns a list of Algebra patterns matching C<< $type >> (tested with C<< isa >>).
If C<< $block >> is given, then matching stops descending a subtree if the current
node is of type C<< $block >>, continuing matching on other subtrees.
This list includes the current algebra object if it matches C<< $type >>, and is
generated in infix order.

=cut

sub subpatterns_of_type {
	my $self	= shift;
	my $type	= shift;
	my $block	= shift;
	
	return if ($block and $self->isa($block));
	
	my @patterns;
	push(@patterns, $self) if ($self->isa($type));
	foreach my $arg ($self->construct_args) {
		if (blessed($arg) and $arg->isa('RDF::Query::Algebra')) {
			push(@patterns, $arg->subpatterns_of_type($type, $block));
		} elsif (blessed($arg) and $arg->isa('RDF::Query')) {
			my $pattern = $arg->pattern;
			push(@patterns, $pattern->subpatterns_of_type($type, $block));
		}
	}
	return @patterns;
}

=item C<< from_sse ( $sse, \%context ) >>

Given an SSE serialization, returns the corresponding algebra expression.

=cut

sub from_sse {
	my $class	= shift;
	my $context	= $_[1];
	if (substr($_[0], 0, 1) eq '(') {
		for ($_[0]) {
			if (my ($tag) = m/^[(](\w+)/) {
				if ($tag eq 'prefix') {
					s/^[(]prefix\s*[(]\s*//;
					my $c	= { %{ $context || {} } };
					while (my ($ns, $iri) = m/^[(](\S+):\s*<([^>]+)>[)]/) {
						s/^[(](\S+):\s*<([^>]+)>[)]\s*//;
						$c->{namespaces}{ $ns }	= $iri;
						$context	= $c;
					}
					s/^[)]\s*//;
					my $alg	= $class->from_sse( $_, $c );
					s/^[)]\s*//;
					return $alg;
				}
				
				if (my $class = SSE_TAGS->{ $tag }) {
					if ($class->can('_from_sse')) {
						return $class->_from_sse( $_, $context );
					} else {
						s/^[(](\w+)\s*//;
						my @nodes;
						while (my $alg = $class->from_sse( $_, $context )) {
							push(@nodes, $alg);
						}
						return $class->new( @nodes );
					}
				} else {
					throw RDF::Query::Error -text => "Unknown SSE tag '$tag' in SSE string: >>$_<<";
				}
			} else {
				throw RDF::Trine::Error -text => "Cannot parse pattern from SSE string: >>$_<<";
			}
		}
	} else {
		return;
	}
}

=back

=head1 FUNCTIONS

=over 4

=item C<< triple ( $subj, $pred, $obj ) >>

Returns a RDF::Query::Algebra::Triple object with the supplied node objects.

=cut

sub triple {
	my @nodes	= @_[0..2];
	return RDF::Query::Algebra::Triple->new( @nodes );
}

=item C<< bgp ( @triples ) >>

Returns a RDF::Query::Algebra::BasicGraphPattern object with the supplied triples.

=cut

sub bgp {
	my @triples	= @_;
	return RDF::Query::Algebra::BasicGraphPattern->new( @triples );
}

=item C<< ggp ( @patterns ) >>

Returns a RDF::Query::Algebra::GroupGraphPattern object with the supplied algebra patterns.

=cut

sub ggp {
	my @patterns	= @_;
	return RDF::Query::Algebra::GroupGraphPattern->new( @patterns );
}



1;

__END__

=back

=head1 AUTHOR

 Gregory Todd Williams <gwilliams@cpan.org>

=cut