line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
58
|
|
|
58
|
|
403
|
use strict; |
|
58
|
|
|
|
|
127
|
|
|
58
|
|
|
|
|
1690
|
|
16
|
58
|
|
|
58
|
|
319
|
use warnings; |
|
58
|
|
|
|
|
121
|
|
|
58
|
|
|
|
|
2022
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package MongoDB::Op::_GetMore; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Encapsulate a cursor fetch operation; returns raw results object |
21
|
|
|
|
|
|
|
# (after inflation from BSON) |
22
|
|
|
|
|
|
|
|
23
|
58
|
|
|
58
|
|
367
|
use version; |
|
58
|
|
|
|
|
157
|
|
|
58
|
|
|
|
|
321
|
|
24
|
|
|
|
|
|
|
our $VERSION = 'v2.2.0'; |
25
|
|
|
|
|
|
|
|
26
|
58
|
|
|
58
|
|
4904
|
use Moo; |
|
58
|
|
|
|
|
160
|
|
|
58
|
|
|
|
|
393
|
|
27
|
|
|
|
|
|
|
|
28
|
58
|
|
|
58
|
|
44675
|
use MongoDB::_Protocol; |
|
58
|
|
|
|
|
193
|
|
|
58
|
|
|
|
|
2653
|
|
29
|
58
|
|
|
|
|
1054
|
use Types::Standard qw( |
30
|
|
|
|
|
|
|
Maybe |
31
|
|
|
|
|
|
|
Any |
32
|
58
|
|
|
58
|
|
445
|
); |
|
58
|
|
|
|
|
138
|
|
33
|
58
|
|
|
|
|
457
|
use MongoDB::_Types qw( |
34
|
|
|
|
|
|
|
Numish |
35
|
58
|
|
|
58
|
|
58984
|
); |
|
58
|
|
|
|
|
146
|
|
36
|
|
|
|
|
|
|
|
37
|
58
|
|
|
58
|
|
55445
|
use namespace::clean; |
|
58
|
|
|
|
|
151
|
|
|
58
|
|
|
|
|
624
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has cursor_id => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
required => 1, |
42
|
|
|
|
|
|
|
isa => Any, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has batch_size => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
required => 1, |
48
|
|
|
|
|
|
|
isa => Numish, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has max_time_ms => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
isa => Numish, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
with $_ for qw( |
57
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
58
|
|
|
|
|
|
|
MongoDB::Role::_CollectionOp |
59
|
|
|
|
|
|
|
MongoDB::Role::_OpReplyParser |
60
|
|
|
|
|
|
|
MongoDB::Role::_DatabaseOp |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub execute { |
64
|
0
|
|
|
0
|
0
|
|
my ( $self, $link ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
my $res = |
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
|
|
|
|
|
|
|
sub _command_get_more { |
75
|
0
|
|
|
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
|
|
0
|
|
|
|
my $batch = $c->{nextBatch} || []; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return { |
90
|
0
|
|
0
|
|
|
|
cursor_id => $c->{id} || 0, |
91
|
|
|
|
|
|
|
flags => {}, |
92
|
|
|
|
|
|
|
starting_from => 0, |
93
|
|
|
|
|
|
|
number_returned => scalar @$batch, |
94
|
|
|
|
|
|
|
docs => $batch, |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _as_command { |
99
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
100
|
|
|
|
|
|
|
return [ |
101
|
0
|
0
|
|
|
|
|
getMore => $self->cursor_id, |
|
|
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
|
|
|
|
|
|
|
sub _legacy_get_more { |
109
|
0
|
|
|
0
|
|
|
my ( $self, $link ) = @_; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my ( $op_bson, $request_id ) = MongoDB::_Protocol::write_get_more( map { $self->$_ } |
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
1; |