line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::Expression::Alias |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Expression::Alias - Class for aliasing expressions with variable names |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Expression::Alias version 2.918. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Expression::Alias; |
15
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
142
|
use strict; |
|
36
|
|
|
|
|
44
|
|
|
36
|
|
|
|
|
846
|
|
17
|
36
|
|
|
36
|
|
120
|
use warnings; |
|
36
|
|
|
|
|
48
|
|
|
36
|
|
|
|
|
716
|
|
18
|
36
|
|
|
36
|
|
119
|
no warnings 'redefine'; |
|
36
|
|
|
|
|
38
|
|
|
36
|
|
|
|
|
900
|
|
19
|
36
|
|
|
36
|
|
146
|
use base qw(RDF::Query::Expression); |
|
36
|
|
|
|
|
58
|
|
|
36
|
|
|
|
|
2416
|
|
20
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
140
|
use Data::Dumper; |
|
36
|
|
|
|
|
442
|
|
|
36
|
|
|
|
|
1440
|
|
22
|
36
|
|
|
36
|
|
214
|
use Scalar::Util qw(blessed); |
|
36
|
|
|
|
|
50
|
|
|
36
|
|
|
|
|
1372
|
|
23
|
36
|
|
|
36
|
|
143
|
use Carp qw(carp croak confess); |
|
36
|
|
|
|
|
41
|
|
|
36
|
|
|
|
|
2331
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
###################################################################### |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our ($VERSION); |
28
|
|
|
|
|
|
|
BEGIN { |
29
|
36
|
|
|
36
|
|
8756
|
$VERSION = '2.918'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
###################################################################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
37
|
|
|
|
|
|
|
L<RDF::Query::Expression> class. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over 4 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item C<< name >> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns the variable name of the aliased expression. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub name { |
50
|
254
|
|
|
254
|
1
|
281
|
my $self = shift; |
51
|
254
|
|
|
|
|
404
|
return $self->alias->name; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item C<< alias >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns the variable object of the aliased expression. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub alias { |
61
|
284
|
|
|
284
|
1
|
283
|
my $self = shift; |
62
|
284
|
|
|
|
|
790
|
my ($alias) = $self->operands; |
63
|
284
|
|
|
|
|
779
|
return $alias; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item C<< expression >> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns the expression object of the aliased expression. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub expression { |
73
|
148
|
|
|
148
|
1
|
396
|
my $self = shift; |
74
|
148
|
|
|
|
|
308
|
return ($self->operands)[1]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item C<< sse >> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the SSE string for this algebra expression. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub sse { |
84
|
92
|
|
|
92
|
1
|
92
|
my $self = shift; |
85
|
92
|
|
|
|
|
99
|
my $context = shift; |
86
|
|
|
|
|
|
|
|
87
|
92
|
|
|
|
|
144
|
return sprintf( |
88
|
|
|
|
|
|
|
'(alias ?%s %s)', |
89
|
|
|
|
|
|
|
$self->name, |
90
|
|
|
|
|
|
|
$self->expression->sse( $context ), |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item C<< as_sparql >> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the SPARQL string for this algebra expression. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub as_sparql { |
101
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
102
|
1
|
|
|
|
|
1
|
my $context = shift; |
103
|
1
|
|
|
|
|
2
|
my $indent = shift; |
104
|
1
|
|
|
|
|
3
|
my $alias = $self->alias; |
105
|
1
|
|
|
|
|
3
|
my $expr = $self->expression; |
106
|
1
|
|
|
|
|
6
|
return sprintf("(%s AS %s)", $expr->as_sparql, $alias->as_sparql); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item C<< evaluate ( $query, \%bound, $context ) >> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Evaluates the expression using the supplied bound variables. |
112
|
|
|
|
|
|
|
Will return a RDF::Query::Node object. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub evaluate { |
117
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
118
|
0
|
|
|
|
|
|
my $query = shift; |
119
|
0
|
|
|
|
|
|
my $bound = shift; |
120
|
0
|
|
|
|
|
|
my $ctx = shift; |
121
|
0
|
|
|
|
|
|
my $expr = $self->expression; |
122
|
0
|
|
|
|
|
|
my $value = $query->var_or_expr_value( $bound, $expr, $ctx ); |
123
|
0
|
|
|
|
|
|
return $value; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item C<< as_hash >> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the alias as a nested set of plain data structures (no objects). |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub as_hash { |
133
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
134
|
0
|
|
|
|
|
|
my $context = shift; |
135
|
|
|
|
|
|
|
return { |
136
|
0
|
|
|
|
|
|
type => 'alias', |
137
|
|
|
|
|
|
|
alias => $self->alias->as_hash, |
138
|
|
|
|
|
|
|
expression => $self->expression->as_hash, |
139
|
|
|
|
|
|
|
}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |