line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2015 - 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
|
|
524
|
use strict; |
|
59
|
|
|
|
|
143
|
|
|
59
|
|
|
|
|
1970
|
|
16
|
59
|
|
|
59
|
|
339
|
use warnings; |
|
59
|
|
|
|
|
157
|
|
|
59
|
|
|
|
|
2345
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_Count; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate code path for count commands |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
|
59
|
|
367
|
use version; |
|
59
|
|
|
|
|
188
|
|
|
59
|
|
|
|
|
446
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.1'; |
23
|
|
|
|
|
|
|
|
24
|
59
|
|
|
59
|
|
5197
|
use Moo; |
|
59
|
|
|
|
|
135
|
|
|
59
|
|
|
|
|
399
|
|
25
|
|
|
|
|
|
|
|
26
|
59
|
|
|
59
|
|
20692
|
use MongoDB::Op::_Command; |
|
59
|
|
|
|
|
205
|
|
|
59
|
|
|
|
|
1932
|
|
27
|
59
|
|
|
|
|
585
|
use Types::Standard qw( |
28
|
|
|
|
|
|
|
HashRef |
29
|
|
|
|
|
|
|
Maybe |
30
|
59
|
|
|
59
|
|
398
|
); |
|
59
|
|
|
|
|
141
|
|
31
|
|
|
|
|
|
|
|
32
|
59
|
|
|
59
|
|
40401
|
use namespace::clean; |
|
59
|
|
|
|
|
171
|
|
|
59
|
|
|
|
|
458
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has filter => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
isa => Maybe[HashRef], |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has options => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
isa => HashRef, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
with $_ for qw( |
47
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
48
|
|
|
|
|
|
|
MongoDB::Role::_CollectionOp |
49
|
|
|
|
|
|
|
MongoDB::Role::_ReadOp |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub execute { |
53
|
0
|
|
|
0
|
0
|
|
my ( $self, $link, $topology ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
if ( defined $self->options->{collation} and !$link->supports_collation ) { |
56
|
0
|
|
|
|
|
|
MongoDB::UsageError->throw( |
57
|
|
|
|
|
|
|
"MongoDB host '" . $link->address . "' doesn't support collation" ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $command = [ |
61
|
|
|
|
|
|
|
count => $self->coll_name, |
62
|
|
|
|
|
|
|
(defined $self->{filter} ? ( query => $self->{filter} ) : () ), |
63
|
|
|
|
|
|
|
($link->supports_read_concern ? |
64
|
0
|
|
|
|
|
|
@{ $self->read_concern->as_args( $self->session ) } : () ), |
65
|
0
|
0
|
|
|
|
|
%{ $self->options }, |
|
0
|
0
|
|
|
|
|
|
66
|
|
|
|
|
|
|
]; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $op = MongoDB::Op::_Command->_new( |
69
|
|
|
|
|
|
|
db_name => $self->db_name, |
70
|
|
|
|
|
|
|
query => $command, |
71
|
|
|
|
|
|
|
query_flags => {}, |
72
|
|
|
|
|
|
|
bson_codec => $self->bson_codec, |
73
|
|
|
|
|
|
|
read_preference => $self->read_preference, |
74
|
|
|
|
|
|
|
session => $self->session, |
75
|
|
|
|
|
|
|
monitoring_callback => $self->monitoring_callback, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $res = $op->execute( $link, $topology ); |
79
|
0
|
|
|
|
|
|
return $res->output; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |