blib/lib/KinoSearch1/Index/NormsReader.pm

filter: Statementstmt 100% 23 / 23 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 33.3% 1 / 3 totaltotal 92.3% 36 / 39 CC 3 SCAR 3.2
CC
3
Cov
96%
init_instance
2.1
_ensure_read
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/KinoSearch1/Document/Doc.pm ↑ Summary blib/lib/KinoSearch1/Search/Weight.pm »
1 package KinoSearch1::Index::NormsReader;
2 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use KinoSearch1::Util::ToolSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use base qw( KinoSearch1::Util::Class );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 34 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 34 __PACKAGE__->init_instance_vars(
9 # constructor params / members
10 instream => undef,
11 max_doc => undef,
12 bytes => undef,
13 );
14 }
15  
16 193 ▶sub init_instance {
Subroutine init_instance: called CC=2 SCAR=7.2
Pod documented
17 193 my $self = shift;
18 confess("Internal error: max_doc is required")
19 193 ▶ unless defined $self->{max_doc};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"max_doc"} 0 193 193
20 }
21  
22 # return a reference to a byte-array of norms
23 498 ▶sub get_bytes {
Subroutine get_bytes: called CC=1 SCAR=0.0
Pod undocumented
24 498 my $self = shift;
25 498 $self->_ensure_read;
26 498 return \$self->{bytes};
27 }
28  
29 # Lazily read in the raw array of norms.
30 498 ▶sub _ensure_read {
Subroutine _ensure_read: called CC=2 SCAR=6.9
31 498 my $self = shift;
32 498 ▶ if ( !defined $self->{bytes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"bytes"}) 108 390 498
33 108 $self->{bytes} = $self->{instream}->lu_read( 'a' . $self->{max_doc} );
34 }
35 }
36  
37 52 ▶sub close { shift->{instream}->close }
Subroutine close: called CC=1 SCAR=0.0
Pod undocumented
38  
39 34 1;
40  
41 __END__
« blib/lib/KinoSearch1/Document/Doc.pm ↑ Summary blib/lib/KinoSearch1/Search/Weight.pm »