line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::NodeReader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
13026
|
use strict; |
|
21
|
|
|
|
|
63
|
|
|
21
|
|
|
|
|
701
|
|
4
|
21
|
|
|
21
|
|
121
|
use warnings; |
|
21
|
|
|
|
|
55
|
|
|
21
|
|
|
|
|
580
|
|
5
|
21
|
|
|
21
|
|
128
|
use namespace::autoclean; |
|
21
|
|
|
|
|
47
|
|
|
21
|
|
|
|
|
146
|
|
6
|
21
|
|
|
21
|
|
1467
|
use autodie; |
|
21
|
|
|
|
|
50
|
|
|
21
|
|
|
|
|
157
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000014'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
116373
|
use MaxMind::DB::Types qw( Int ); |
|
21
|
|
|
|
|
56
|
|
|
21
|
|
|
|
|
1198
|
|
11
|
|
|
|
|
|
|
|
12
|
21
|
|
|
21
|
|
149
|
use Moo::Role; |
|
21
|
|
|
|
|
55
|
|
|
21
|
|
|
|
|
149
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'MaxMind::DB::Reader::Role::HasMetadata'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has _node_byte_size => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => Int, |
19
|
|
|
|
|
|
|
init_arg => undef, |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
builder => '_build_node_byte_size', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has _search_tree_size => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => Int, |
27
|
|
|
|
|
|
|
init_arg => undef, |
28
|
|
|
|
|
|
|
lazy => 1, |
29
|
|
|
|
|
|
|
builder => '_build_search_tree_size', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
33
|
|
|
|
|
|
|
sub _read_node { |
34
|
14723
|
|
|
14723
|
|
22524
|
my $self = shift; |
35
|
14723
|
|
|
|
|
21403
|
my $node_num = shift; |
36
|
|
|
|
|
|
|
|
37
|
14723
|
|
|
|
|
22361
|
my $node = q{}; |
38
|
14723
|
|
|
|
|
241786
|
$self->_read( |
39
|
|
|
|
|
|
|
\$node, |
40
|
|
|
|
|
|
|
$node_num * $self->_node_byte_size, |
41
|
|
|
|
|
|
|
$self->_node_byte_size, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
14723
|
|
|
|
|
49233
|
return $self->_split_node_into_records($node); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _split_node_into_records { |
48
|
14723
|
|
|
14723
|
|
25309
|
my $self = shift; |
49
|
14723
|
|
|
|
|
25834
|
my $node = shift; |
50
|
|
|
|
|
|
|
|
51
|
14723
|
100
|
|
|
|
286480
|
if ( $self->record_size == 24 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
52
|
5683
|
|
|
|
|
189542
|
return unpack( NN => pack( 'xa*xa*' => unpack( a3a3 => $node ) ) ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ( $self->record_size == 28 ) { |
55
|
4556
|
|
|
|
|
308404
|
my ( $left_bytes, $middle_byte, $right_bytes ) |
56
|
|
|
|
|
|
|
= unpack( a3Ca3 => $node ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return ( |
59
|
4556
|
|
|
|
|
29005
|
unpack( |
60
|
|
|
|
|
|
|
N => pack( 'Ca*', ( $middle_byte & 0xf0 ) >> 4, $left_bytes ) |
61
|
|
|
|
|
|
|
), |
62
|
|
|
|
|
|
|
unpack( |
63
|
|
|
|
|
|
|
N => pack( 'Ca*', ( $middle_byte & 0x0f ), $right_bytes ) |
64
|
|
|
|
|
|
|
) |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif ( $self->record_size == 32 ) { |
68
|
4484
|
|
|
|
|
476102
|
return unpack( NN => $node ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _build_node_byte_size { |
73
|
19
|
|
|
19
|
|
253
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
19
|
|
|
|
|
324
|
return $self->record_size * 2 / 8; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _build_search_tree_size { |
79
|
17
|
|
|
17
|
|
924
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
17
|
|
|
|
|
279
|
return $self->node_count * $self->_node_byte_size; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |