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