line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::Algebra::Offset |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Algebra::Offset - Algebra class for offseting query results |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Algebra::Offset version 2.916. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Algebra::Offset; |
15
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
181
|
use strict; |
|
36
|
|
|
|
|
69
|
|
|
36
|
|
|
|
|
893
|
|
17
|
36
|
|
|
36
|
|
175
|
use warnings; |
|
36
|
|
|
|
|
69
|
|
|
36
|
|
|
|
|
949
|
|
18
|
36
|
|
|
36
|
|
179
|
no warnings 'redefine'; |
|
36
|
|
|
|
|
67
|
|
|
36
|
|
|
|
|
1189
|
|
19
|
36
|
|
|
36
|
|
180
|
use base qw(RDF::Query::Algebra); |
|
36
|
|
|
|
|
73
|
|
|
36
|
|
|
|
|
2584
|
|
20
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
213
|
use Data::Dumper; |
|
36
|
|
|
|
|
78
|
|
|
36
|
|
|
|
|
1708
|
|
22
|
36
|
|
|
36
|
|
200
|
use Set::Scalar; |
|
36
|
|
|
|
|
87
|
|
|
36
|
|
|
|
|
1367
|
|
23
|
36
|
|
|
36
|
|
177
|
use Scalar::Util qw(blessed); |
|
36
|
|
|
|
|
68
|
|
|
36
|
|
|
|
|
1784
|
|
24
|
36
|
|
|
36
|
|
189
|
use Carp qw(carp croak confess); |
|
36
|
|
|
|
|
77
|
|
|
36
|
|
|
|
|
1963
|
|
25
|
36
|
|
|
36
|
|
190
|
use RDF::Trine::Iterator qw(sgrep); |
|
36
|
|
|
|
|
73
|
|
|
36
|
|
|
|
|
2417
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
###################################################################### |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our ($VERSION); |
30
|
|
|
|
|
|
|
BEGIN { |
31
|
36
|
|
|
36
|
|
18539
|
$VERSION = '2.916'; |
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 ( $pattern, $offset ) >> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns a new Sort structure. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
52
|
4
|
|
|
4
|
1
|
8
|
my $class = shift; |
53
|
4
|
|
|
|
|
8
|
my $pattern = shift; |
54
|
4
|
|
|
|
|
9
|
my $offset = shift; |
55
|
4
|
|
|
|
|
19
|
return bless( [ $pattern, $offset ], $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
|
|
|
|
|
|
|
sub construct_args { |
66
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
67
|
4
|
|
|
|
|
11
|
my $pattern = $self->pattern; |
68
|
4
|
|
|
|
|
12
|
my $offset = $self->offset; |
69
|
4
|
|
|
|
|
15
|
return ($pattern, $offset); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C<< pattern >> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns the pattern to be sorted. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub pattern { |
79
|
13
|
|
|
13
|
1
|
18
|
my $self = shift; |
80
|
13
|
50
|
|
|
|
36
|
if (@_) { |
81
|
0
|
|
|
|
|
0
|
$self->[0] = shift; |
82
|
|
|
|
|
|
|
} |
83
|
13
|
|
|
|
|
59
|
return $self->[0]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C<< offset >> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the offset number of the pattern. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub offset { |
93
|
12
|
|
|
12
|
1
|
20
|
my $self = shift; |
94
|
12
|
|
|
|
|
57
|
return $self->[1]; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item C<< sse >> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the SSE string for this algebra expression. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub sse { |
104
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
105
|
3
|
|
|
|
|
7
|
my $context = shift; |
106
|
3
|
|
50
|
|
|
17
|
my $prefix = shift || ''; |
107
|
3
|
|
|
|
|
7
|
my $indent = $context->{indent}; |
108
|
|
|
|
|
|
|
|
109
|
3
|
|
|
|
|
14
|
return sprintf( |
110
|
|
|
|
|
|
|
"(offset %s\n${prefix}${indent}%s)", |
111
|
|
|
|
|
|
|
$self->offset, |
112
|
|
|
|
|
|
|
$self->pattern->sse( $context, "${prefix}${indent}" ), |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item C<< as_sparql >> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the SPARQL string for this algebra expression. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub as_sparql { |
123
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
124
|
1
|
|
|
|
|
4
|
my $context = shift; |
125
|
1
|
|
|
|
|
2
|
my $indent = shift; |
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
4
|
my $string = sprintf( |
128
|
|
|
|
|
|
|
"%s\nOFFSET %d", |
129
|
|
|
|
|
|
|
$self->pattern->as_sparql( $context, $indent ), |
130
|
|
|
|
|
|
|
$self->offset, |
131
|
|
|
|
|
|
|
); |
132
|
1
|
|
|
|
|
6
|
return $string; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item C<< as_hash >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns the query as a nested set of plain data structures (no objects). |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub as_hash { |
142
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
143
|
0
|
|
|
|
|
0
|
my $context = shift; |
144
|
|
|
|
|
|
|
return { |
145
|
0
|
|
|
|
|
0
|
type => lc($self->type), |
146
|
|
|
|
|
|
|
pattern => $self->pattern->as_hash, |
147
|
|
|
|
|
|
|
offset => $self->offset, |
148
|
|
|
|
|
|
|
}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item C<< type >> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns the type of this algebra expression. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub type { |
158
|
0
|
|
|
0
|
1
|
0
|
return 'LIMIT'; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item C<< referenced_variables >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub referenced_variables { |
168
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
169
|
1
|
|
|
|
|
3
|
return RDF::Query::_uniq($self->pattern->referenced_variables); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item C<< potentially_bound >> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns a list of the variable names used in this algebra expression that will |
175
|
|
|
|
|
|
|
bind values during execution. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub potentially_bound { |
180
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
181
|
0
|
|
|
|
|
0
|
return $self->pattern->potentially_bound; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item C<< definite_variables >> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Returns a list of the variable names that will be bound after evaluating this algebra expression. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub definite_variables { |
191
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
192
|
0
|
|
|
|
|
0
|
return $self->pattern->definite_variables; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item C<< is_solution_modifier >> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns true if this node is a solution modifier. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub is_solution_modifier { |
202
|
3
|
|
|
3
|
1
|
18
|
return 1; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
__END__ |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=back |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |