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
|
59
|
|
|
59
|
|
387
|
use strict; |
|
59
|
|
|
|
|
135
|
|
|
59
|
|
|
|
|
1745
|
|
16
|
59
|
|
|
59
|
|
437
|
use warnings; |
|
59
|
|
|
|
|
139
|
|
|
59
|
|
|
|
|
2156
|
|
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
|
|
|
59
|
|
361
|
use version; |
|
59
|
|
|
|
|
135
|
|
|
59
|
|
|
|
|
334
|
|
24
|
|
|
|
|
|
|
our $VERSION = 'v2.2.1'; |
25
|
|
|
|
|
|
|
|
26
|
59
|
|
|
59
|
|
4972
|
use Moo; |
|
59
|
|
|
|
|
164
|
|
|
59
|
|
|
|
|
359
|
|
27
|
|
|
|
|
|
|
|
28
|
59
|
|
|
59
|
|
47023
|
use MongoDB::_Protocol; |
|
59
|
|
|
|
|
193
|
|
|
59
|
|
|
|
|
2819
|
|
29
|
59
|
|
|
|
|
684
|
use Types::Standard qw( |
30
|
|
|
|
|
|
|
Maybe |
31
|
|
|
|
|
|
|
Any |
32
|
59
|
|
|
59
|
|
441
|
); |
|
59
|
|
|
|
|
143
|
|
33
|
59
|
|
|
|
|
460
|
use MongoDB::_Types qw( |
34
|
|
|
|
|
|
|
Numish |
35
|
59
|
|
|
59
|
|
60260
|
); |
|
59
|
|
|
|
|
148
|
|
36
|
|
|
|
|
|
|
|
37
|
59
|
|
|
59
|
|
58433
|
use namespace::clean; |
|
59
|
|
|
|
|
154
|
|
|
59
|
|
|
|
|
607
|
|
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; |