Query/Algebra/Limit.pm

filter: Statementstmt 89.8% 62 / 69 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 86.3% 19 / 22 Podpod 100% 12 / 12 totaltotal 86.7% 98 / 113 CC 5 SCAR 5.1
CC
5
Cov
87%
sse
4.0
pattern
2.1
as_hash
2.0
CRAP 1.7
« Query/Parser/RDQL.pm ↑ Summary Query/Algebra/Distinct.pm »
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.919.
11  
12 =cut
13  
14 package RDF::Query::Algebra::Limit;
15  
16 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 36 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 36 ▶use base qw(RDF::Query::Algebra);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 36 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 36 ▶use Set::Scalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 36 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 36 ▶use Carp qw(carp croak confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 36 ▶use RDF::Trine::Iterator qw(sgrep);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 ######################################################################
28  
29 36 our ($VERSION);
30 36 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
31 36 $VERSION = '2.919';
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 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
52 9 my $class = shift;
53 9 my $pattern = shift;
54 9 my $limit = shift;
55 9 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 19 ▶sub construct_args {
Subroutine construct_args: called CC=1 SCAR=0.0
Pod documented
66 19 my $self = shift;
67 19 my $pattern = $self->pattern;
68 19 my $limit = $self->limit;
69 19 return ($pattern, $limit);
70 }
71  
72 =item C<< pattern >>
73  
74 Returns the pattern to be sorted.
75  
76 =cut
77  
78 57 ▶sub pattern {
Subroutine pattern: called CC=2 SCAR=7.6
Pod documented
79 57 my $self = shift;
80 57 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 57 57
81 0 $self->[0] = shift;
82 }
83 57 return $self->[0];
84 }
85  
86 =item C<< limit >>
87  
88 Returns the limit number of the pattern.
89  
90 =cut
91  
92 41 ▶sub limit {
Subroutine limit: called CC=1 SCAR=0.0
Pod documented
93 41 my $self = shift;
94 41 return $self->[1];
95 }
96  
97 =item C<< sse >>
98  
99 Returns the SSE string for this algebra expression.
100  
101 =cut
102  
103 11 ▶sub sse {
Subroutine sse: called CC=4 SCAR=14.0
Pod documented
104 11 my $self = shift;
105 11 my $context = shift;
106 11 ▶ my $prefix = shift || '';
Condition50%1/2
shift() || ''
l!l
011
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
107 11 ▶ my $indent = $context->{indent} || ' ';
Condition50%1/2
$context->{'indent'} || ' '
l!l
110
MC/DC0%0/1
$context->{'indent'} || ' '
$context->{'indent'}
Truth table50%1/2
A
A= $context->{'indent'}
Aresult
11
00
108
109 11 ▶ if ($self->pattern->isa('RDF::Query::Algebra::Offset')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pattern->isa('RDF::Query::Algebra::Offset')) { } 1 10 11
110 1 my $l = $self->limit;
111 1 my $o = $self->pattern->offset;
112 1 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 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 3 ▶sub as_sparql {
Subroutine as_sparql: called CC=1 SCAR=0.0
Pod documented
133 3 my $self = shift;
134 3 my $context = shift;
135 3 my $indent = shift;
136
137 3 my $string = sprintf(
138 "%s\nLIMIT %d",
139 $self->pattern->as_sparql( $context, $indent ),
140 $self->limit,
141 );
142 3 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 0 ▶sub as_hash {
Subroutine as_hash: not called CC=1 SCAR=6.9
Pod documented
152 0 my $self = shift;
153 0 my $context = shift;
154 return {
155 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 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
168 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 3 ▶sub referenced_variables {
Subroutine referenced_variables: called CC=1 SCAR=0.0
Pod documented
178 3 my $self = shift;
179 3 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 1 ▶sub potentially_bound {
Subroutine potentially_bound: called CC=1 SCAR=0.0
Pod documented
190 1 my $self = shift;
191 1 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 0 ▶sub definite_variables {
Subroutine definite_variables: not called CC=1 SCAR=6.9
Pod documented
201 0 my $self = shift;
202 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 8 ▶sub is_solution_modifier {
Subroutine is_solution_modifier: called CC=1 SCAR=0.0
Pod documented
212 8 return 1;
213 }
214  
215  
216 36 1;
217  
218 __END__
« Query/Parser/RDQL.pm ↑ Summary Query/Algebra/Distinct.pm »