| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||