File Coverage

blib/lib/KinoSearch1/Index/NormsReader.pm
Criterion Covered Total %
statement 22 22 100.0
branch 3 4 75.0
condition n/a
subroutine 9 9 100.0
pod 1 3 33.3
total 35 38 92.1


line stmt bran cond sub pod time code
1             package KinoSearch1::Index::NormsReader;
2 34     34   186 use strict;
  34         95  
  34         1147  
3 34     34   180 use warnings;
  34         62  
  34         931  
4 34     34   187 use KinoSearch1::Util::ToolSet;
  34         91  
  34         4670  
5 34     34   202 use base qw( KinoSearch1::Util::Class );
  34         76  
  34         3181  
6              
7             BEGIN {
8 34     34   352 __PACKAGE__->init_instance_vars(
9             # constructor params / members
10             instream => undef,
11             max_doc => undef,
12             bytes => undef,
13             );
14             }
15              
16             sub init_instance {
17 193     193 1 446 my $self = shift;
18 193 50       826 confess("Internal error: max_doc is required")
19             unless defined $self->{max_doc};
20             }
21              
22             # return a reference to a byte-array of norms
23             sub get_bytes {
24 505     505 0 831 my $self = shift;
25 505         1143 $self->_ensure_read;
26 505         3085 return \$self->{bytes};
27             }
28              
29             # Lazily read in the raw array of norms.
30             sub _ensure_read {
31 505     505   902 my $self = shift;
32 505 100       1785 if ( !defined $self->{bytes} ) {
33 108         2209 $self->{bytes} = $self->{instream}->lu_read( 'a' . $self->{max_doc} );
34             }
35             }
36              
37 52     52 0 171 sub close { shift->{instream}->close }
38              
39             1;
40              
41             __END__