line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Reader::Role::NodeReader; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
13032
|
use strict; |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
683
|
|
4
|
21
|
|
|
21
|
|
88
|
use warnings; |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
562
|
|
5
|
21
|
|
|
21
|
|
85
|
use namespace::autoclean; |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
139
|
|
6
|
21
|
|
|
21
|
|
1194
|
use autodie; |
|
21
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
138
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000012'; |
9
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
75959
|
use MaxMind::DB::Types qw( Int ); |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
1232
|
|
11
|
|
|
|
|
|
|
|
12
|
21
|
|
|
21
|
|
103
|
use Moo::Role; |
|
21
|
|
|
|
|
23
|
|
|
21
|
|
|
|
|
168
|
|
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
|
|
|
|
|
|
|
sub _read_node { |
33
|
14041
|
|
|
14041
|
|
10781
|
my $self = shift; |
34
|
14041
|
|
|
|
|
10600
|
my $node_num = shift; |
35
|
|
|
|
|
|
|
|
36
|
14041
|
|
|
|
|
10011
|
my $node = q{}; |
37
|
14041
|
|
|
|
|
25144
|
$self->_read( |
38
|
|
|
|
|
|
|
\$node, |
39
|
|
|
|
|
|
|
$node_num * $self->_node_byte_size(), |
40
|
|
|
|
|
|
|
$self->_node_byte_size(), |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
14041
|
|
|
|
|
24834
|
return $self->_split_node_into_records($node); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _split_node_into_records { |
47
|
14041
|
|
|
14041
|
|
10539
|
my $self = shift; |
48
|
14041
|
|
|
|
|
10439
|
my $node = shift; |
49
|
|
|
|
|
|
|
|
50
|
14041
|
100
|
|
|
|
23949
|
if ( $self->record_size() == 24 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
51
|
5047
|
|
|
|
|
213045
|
return unpack( NN => pack( 'xa*xa*' => unpack( a3a3 => $node ) ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ( $self->record_size() == 28 ) { |
54
|
4533
|
|
|
|
|
303304
|
my ( $left_bytes, $middle_byte, $right_bytes ) |
55
|
|
|
|
|
|
|
= unpack( a3Ca3 => $node ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return ( |
58
|
4533
|
|
|
|
|
19088
|
unpack( |
59
|
|
|
|
|
|
|
N => pack( 'Ca*', ( $middle_byte & 0xf0 ) >> 4, $left_bytes ) |
60
|
|
|
|
|
|
|
), |
61
|
|
|
|
|
|
|
unpack( |
62
|
|
|
|
|
|
|
N => pack( 'Ca*', ( $middle_byte & 0x0f ), $right_bytes ) |
63
|
|
|
|
|
|
|
) |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif ( $self->record_size() == 32 ) { |
67
|
4461
|
|
|
|
|
442536
|
return unpack( NN => $node ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _build_node_byte_size { |
72
|
19
|
|
|
19
|
|
2215
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
19
|
|
|
|
|
63
|
return $self->record_size() * 2 / 8; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _build_search_tree_size { |
78
|
17
|
|
|
17
|
|
2954
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
17
|
|
|
|
|
55
|
return $self->node_count() * $self->_node_byte_size(); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |