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
|
58
|
|
|
58
|
|
441
|
use strict; |
|
58
|
|
|
|
|
147
|
|
|
58
|
|
|
|
|
2065
|
|
16
|
58
|
|
|
58
|
|
327
|
use warnings; |
|
58
|
|
|
|
|
131
|
|
|
58
|
|
|
|
|
2446
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_Count; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate code path for count commands |
20
|
|
|
|
|
|
|
|
21
|
58
|
|
|
58
|
|
345
|
use version; |
|
58
|
|
|
|
|
194
|
|
|
58
|
|
|
|
|
441
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.0'; |
23
|
|
|
|
|
|
|
|
24
|
58
|
|
|
58
|
|
5034
|
use Moo; |
|
58
|
|
|
|
|
163
|
|
|
58
|
|
|
|
|
430
|
|
25
|
|
|
|
|
|
|
|
26
|
58
|
|
|
58
|
|
20093
|
use MongoDB::Op::_Command; |
|
58
|
|
|
|
|
170
|
|
|
58
|
|
|
|
|
1994
|
|
27
|
58
|
|
|
|
|
576
|
use Types::Standard qw( |
28
|
|
|
|
|
|
|
HashRef |
29
|
|
|
|
|
|
|
Maybe |
30
|
58
|
|
|
58
|
|
401
|
); |
|
58
|
|
|
|
|
171
|
|
31
|
|
|
|
|
|
|
|
32
|
58
|
|
|
58
|
|
40696
|
use namespace::clean; |
|
58
|
|
|
|
|
160
|
|
|
58
|
|
|
|
|
480
|
|
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; |