line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::NodeReader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
10383
|
use strict; |
|
21
|
|
|
|
|
30
|
|
|
21
|
|
|
|
|
590
|
|
4
|
21
|
|
|
21
|
|
70
|
use warnings; |
|
21
|
|
|
|
|
23
|
|
|
21
|
|
|
|
|
426
|
|
5
|
21
|
|
|
21
|
|
72
|
use namespace::autoclean; |
|
21
|
|
|
|
|
24
|
|
|
21
|
|
|
|
|
109
|
|
6
|
21
|
|
|
21
|
|
981
|
use autodie; |
|
21
|
|
|
|
|
29
|
|
|
21
|
|
|
|
|
110
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000013'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
64751
|
use MaxMind::DB::Types qw( Int ); |
|
21
|
|
|
|
|
29
|
|
|
21
|
|
|
|
|
897
|
|
11
|
|
|
|
|
|
|
|
12
|
21
|
|
|
21
|
|
76
|
use Moo::Role; |
|
21
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
106
|
|
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
|
14041
|
|
|
14041
|
|
10262
|
my $self = shift; |
35
|
14041
|
|
|
|
|
9599
|
my $node_num = shift; |
36
|
|
|
|
|
|
|
|
37
|
14041
|
|
|
|
|
10255
|
my $node = q{}; |
38
|
14041
|
|
|
|
|
22570
|
$self->_read( |
39
|
|
|
|
|
|
|
\$node, |
40
|
|
|
|
|
|
|
$node_num * $self->_node_byte_size(), |
41
|
|
|
|
|
|
|
$self->_node_byte_size(), |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
14041
|
|
|
|
|
22805
|
return $self->_split_node_into_records($node); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _split_node_into_records { |
48
|
14041
|
|
|
14041
|
|
11353
|
my $self = shift; |
49
|
14041
|
|
|
|
|
9524
|
my $node = shift; |
50
|
|
|
|
|
|
|
|
51
|
14041
|
100
|
|
|
|
21549
|
if ( $self->record_size() == 24 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
52
|
5047
|
|
|
|
|
178591
|
return unpack( NN => pack( 'xa*xa*' => unpack( a3a3 => $node ) ) ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ( $self->record_size() == 28 ) { |
55
|
4533
|
|
|
|
|
285910
|
my ( $left_bytes, $middle_byte, $right_bytes ) |
56
|
|
|
|
|
|
|
= unpack( a3Ca3 => $node ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return ( |
59
|
4533
|
|
|
|
|
17013
|
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
|
4461
|
|
|
|
|
414771
|
return unpack( NN => $node ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _build_node_byte_size { |
73
|
19
|
|
|
19
|
|
1728
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
19
|
|
|
|
|
49
|
return $self->record_size() * 2 / 8; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _build_search_tree_size { |
79
|
17
|
|
|
17
|
|
2379
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
17
|
|
|
|
|
47
|
return $self->node_count() * $self->_node_byte_size(); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |