Query/Algebra/Offset.pm

filter: Statementstmt 86.1% 56 / 65 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 81.8% 18 / 22 Podpod 100% 12 / 12 totaltotal 84.6% 88 / 104 CC 3 SCAR 3.0
CC
3
Cov
84%
pattern
2.1
sse
2.0
as_hash
2.0
CRAP 1.3
« Query/Algebra/Optional.pm ↑ Summary Query/Algebra/SubSelect.pm »
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.919.
11  
12 =cut
13  
14 package RDF::Query::Algebra::Offset;
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, $offset ) >>
46  
47 Returns a new Sort structure.
48  
49 =cut
50  
51 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
52 4 my $class = shift;
53 4 my $pattern = shift;
54 4 my $offset = shift;
55 4 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 4 ▶sub construct_args {
Subroutine construct_args: called CC=1 SCAR=0.0
Pod documented
66 4 my $self = shift;
67 4 my $pattern = $self->pattern;
68 4 my $offset = $self->offset;
69 4 return ($pattern, $offset);
70 }
71  
72 =item C<< pattern >>
73  
74 Returns the pattern to be sorted.
75  
76 =cut
77  
78 13 ▶sub pattern {
Subroutine pattern: called CC=2 SCAR=7.6
Pod documented
79 13 my $self = shift;
80 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 13 13
81 0 $self->[0] = shift;
82 }
83 13 return $self->[0];
84 }
85  
86 =item C<< offset >>
87  
88 Returns the offset number of the pattern.
89  
90 =cut
91  
92 12 ▶sub offset {
Subroutine offset: called CC=1 SCAR=0.0
Pod documented
93 12 my $self = shift;
94 12 return $self->[1];
95 }
96  
97 =item C<< sse >>
98  
99 Returns the SSE string for this algebra expression.
100  
101 =cut
102  
103 3 ▶sub sse {
Subroutine sse: called CC=2 SCAR=7.0
Pod documented
104 3 my $self = shift;
105 3 my $context = shift;
106 3 ▶ my $prefix = shift || '';
Condition50%1/2
shift() || ''
l!l
03
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
107 3 my $indent = $context->{indent};
108
109 3 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 1 ▶sub as_sparql {
Subroutine as_sparql: called CC=1 SCAR=0.0
Pod documented
123 1 my $self = shift;
124 1 my $context = shift;
125 1 my $indent = shift;
126
127 1 my $string = sprintf(
128 "%s\nOFFSET %d",
129 $self->pattern->as_sparql( $context, $indent ),
130 $self->offset,
131 );
132 1 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 0 ▶sub as_hash {
Subroutine as_hash: not called CC=1 SCAR=6.9
Pod documented
142 0 my $self = shift;
143 0 my $context = shift;
144 return {
145 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 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
158 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 1 ▶sub referenced_variables {
Subroutine referenced_variables: called CC=1 SCAR=0.0
Pod documented
168 1 my $self = shift;
169 1 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 0 ▶sub potentially_bound {
Subroutine potentially_bound: not called CC=1 SCAR=6.9
Pod documented
180 0 my $self = shift;
181 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 0 ▶sub definite_variables {
Subroutine definite_variables: not called CC=1 SCAR=6.9
Pod documented
191 0 my $self = shift;
192 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 3 ▶sub is_solution_modifier {
Subroutine is_solution_modifier: called CC=1 SCAR=0.0
Pod documented
202 3 return 1;
203 }
204  
205  
206  
207 36 1;
208  
209 __END__
« Query/Algebra/Optional.pm ↑ Summary Query/Algebra/SubSelect.pm »