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.916. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Expression::Alias; |
15
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
176
|
use strict; |
|
36
|
|
|
|
|
66
|
|
|
36
|
|
|
|
|
859
|
|
17
|
36
|
|
|
36
|
|
174
|
use warnings; |
|
36
|
|
|
|
|
63
|
|
|
36
|
|
|
|
|
888
|
|
18
|
36
|
|
|
36
|
|
171
|
no warnings 'redefine'; |
|
36
|
|
|
|
|
56
|
|
|
36
|
|
|
|
|
1130
|
|
19
|
36
|
|
|
36
|
|
261
|
use base qw(RDF::Query::Expression); |
|
36
|
|
|
|
|
71
|
|
|
36
|
|
|
|
|
2980
|
|
20
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
202
|
use Data::Dumper; |
|
36
|
|
|
|
|
573
|
|
|
36
|
|
|
|
|
1757
|
|
22
|
36
|
|
|
36
|
|
173
|
use Scalar::Util qw(blessed); |
|
36
|
|
|
|
|
56
|
|
|
36
|
|
|
|
|
1634
|
|
23
|
36
|
|
|
36
|
|
189
|
use Carp qw(carp croak confess); |
|
36
|
|
|
|
|
76
|
|
|
36
|
|
|
|
|
2960
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
###################################################################### |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our ($VERSION); |
28
|
|
|
|
|
|
|
BEGIN { |
29
|
36
|
|
|
36
|
|
12832
|
$VERSION = '2.916'; |
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
|
360
|
my $self = shift; |
51
|
254
|
|
|
|
|
597
|
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
|
379
|
my $self = shift; |
62
|
284
|
|
|
|
|
902
|
my ($alias) = $self->operands; |
63
|
284
|
|
|
|
|
1063
|
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
|
537
|
my $self = shift; |
74
|
148
|
|
|
|
|
429
|
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
|
149
|
my $self = shift; |
85
|
92
|
|
|
|
|
135
|
my $context = shift; |
86
|
|
|
|
|
|
|
|
87
|
92
|
|
|
|
|
213
|
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
|
3
|
my $self = shift; |
102
|
1
|
|
|
|
|
2
|
my $context = shift; |
103
|
1
|
|
|
|
|
1
|
my $indent = shift; |
104
|
1
|
|
|
|
|
4
|
my $alias = $self->alias; |
105
|
1
|
|
|
|
|
3
|
my $expr = $self->expression; |
106
|
1
|
|
|
|
|
5
|
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 |