MongoDB/Op/_GetMore.pm

filter: Statementstmt 65.2% 30 / 46 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 8 / 12 Podpod 0.0% 0 / 1 totaltotal 53.5% 38 / 71 CC 6 SCAR 17.1
CC
6
Cov
54%
_command_get_more
12.0
_as_command
12.0
execute
6.0
CRAP 5.5
« MongoDB/Op/_ListCollections.pm ↑ Summary MongoDB/_ServerSession.pm »
1 # Copyright 2014 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 package MongoDB::Op::_GetMore;
19  
20 # Encapsulate a cursor fetch operation; returns raw results object
21 # (after inflation from BSON)
22  
23 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 59 our $VERSION = 'v2.2.2';
25  
26 59 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 59 ▶use MongoDB::_Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 59 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
30 Maybe
31 Any
32 59 );
33 59 ▶use MongoDB::_Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
34 Numish
35 59 );
36  
37 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 59 has cursor_id => (
40 is => 'ro',
41 required => 1,
42 isa => Any,
43 );
44  
45 59 has batch_size => (
46 is => 'ro',
47 required => 1,
48 isa => Numish,
49 );
50  
51 59 has max_time_ms => (
52 is => 'ro',
53 isa => Numish,
54 );
55  
56 59 with $_ for qw(
57 MongoDB::Role::_PrivateConstructor
58 MongoDB::Role::_CollectionOp
59 MongoDB::Role::_OpReplyParser
60 MongoDB::Role::_DatabaseOp
61 );
62  
63 0 ▶sub execute {
Subroutine execute: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my ( $self, $link ) = @_;
65  
66 0 ▶ my $res =
Branch: 1 branch
BranchTrueFalseTotal
$link->supports_query_commands ? : 0 0 0
67 $link->supports_query_commands
68 ? $self->_command_get_more($link)
69 : $self->_legacy_get_more($link);
70  
71 0 return $res;
72 }
73  
74 0 ▶sub _command_get_more {
Subroutine _command_get_more: not called CC=3 SCAR=24.8
75 0 my ( $self, $link ) = @_;
76  
77 0 my $op = MongoDB::Op::_Command->_new(
78 db_name => $self->db_name,
79 query => $self->_as_command,
80 query_flags => {},
81 bson_codec => $self->bson_codec,
82 session => $self->session,
83 monitoring_callback => $self->monitoring_callback,
84 );
85  
86 0 my $c = $op->execute($link)->output->{cursor};
87 0 ▶ my $batch = $c->{nextBatch} || [];
Condition0%0/2
$c->{'nextBatch'} || []
l!l
00
MC/DC0%0/1
$c->{'nextBatch'} || []
$c->{'nextBatch'}
Truth table0%0/2
A
A= $c->{'nextBatch'}
Aresult
11
00
88  
89 return {
90 0 ▶ cursor_id => $c->{id} || 0,
Condition0%0/2
$c->{'id'} || 0
l!l
00
MC/DC0%0/1
$c->{'id'} || 0
$c->{'id'}
Truth table0%0/2
A
A= $c->{'id'}
Aresult
11
00
91 flags => {},
92 starting_from => 0,
93 number_returned => scalar @$batch,
94 docs => $batch,
95 };
96 }
97  
98 0 ▶sub _as_command {
Subroutine _as_command: not called CC=3 SCAR=24.8
99 0 my ($self) = @_;
100 return [
101 0 ▶ getMore => $self->cursor_id,
Branch: 2 branches
BranchTrueFalseTotal
$self->batch_size > 0 ? : 0 0 0
$self->max_time_ms ? : 0 0 0
102 collection => $self->coll_name,
103 ( $self->batch_size > 0 ? ( batchSize => $self->batch_size ) : () ),
104 ( $self->max_time_ms ? ( maxTimeMS => $self->max_time_ms ) : () ),
105 ];
106 }
107  
108 0 ▶sub _legacy_get_more {
Subroutine _legacy_get_more: not called CC=1 SCAR=6.9
109 0 my ( $self, $link ) = @_;
110  
111 0 my ( $op_bson, $request_id ) = MongoDB::_Protocol::write_get_more( map { $self->$_ }
112 qw/full_name cursor_id batch_size/ );
113  
114 0 my $result =
115 $self->_query_and_receive( $link, $op_bson, $request_id, $self->bson_codec );
116  
117 0 $result->{address} = $link->address;
118  
119 0 return $result;
120 }
121  
122 59 1;
« MongoDB/Op/_ListCollections.pm ↑ Summary MongoDB/_ServerSession.pm »