This file is indexed.

/usr/lib/perl5/KinoSearch1/Index/SegInfos.pm is in libkinosearch1-perl 1.00-1build3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package KinoSearch1::Index::SegInfos;
use strict;
use warnings;
use KinoSearch1::Util::ToolSet;
use base qw( KinoSearch1::Util::Class );

use constant FORMAT => -1;

BEGIN {
    __PACKAGE__->init_instance_vars(
        # members
        infos   => undef,
        counter => 0,
        version => undef,
    );
    __PACKAGE__->ready_get_set(qw( counter ));
}

use Time::HiRes qw( time );

sub init_instance {
    my $self = shift;
    $self->{infos} = {};
    $self->{version} ||= int( time * 1000 );
}

# Add a SegInfo to the collection.
sub add_info {
    my ( $self, $info ) = @_;
    $self->{infos}{"$info->{seg_name}"} = $info;
}

# Remove the info corresponding to a segment;
sub delete_segment {
    my ( $self, $seg_name ) = @_;
    confess("no segment named '$seg_name'")
        unless exists $self->{infos}{$seg_name};
    delete $self->{infos}{$seg_name};
}

# Return number of segments in invindex.
sub size { scalar keys %{ $_[0]->{infos} } }

# Retrieve all infos.
sub infos {
    sort { $a->{seg_name} cmp $b->{seg_name} } values %{ $_[0]->{infos} };
}

# Decode "segments" file.
sub read_infos {
    my ( $self, $invindex ) = @_;
    my $instream = $invindex->open_instream('segments');

    # support only recent index formats
    my $format = $instream->lu_read('i');
    croak("unsupported format: '$format'")
        unless $format == FORMAT;

    # read header
    @{$self}{ 'version', 'counter' } = $instream->lu_read('Qi');
    my $num_segs = $instream->lu_read('i');

    # build one SegInfo object for each segment
    if ($num_segs) {
        my @file_contents = $instream->lu_read( 'Ti' x $num_segs );
        while (@file_contents) {
            my ( $seg_name, $doc_count ) = splice( @file_contents, 0, 2 );
            $self->{infos}{$seg_name} = KinoSearch1::Index::SegInfo->new(
                seg_name  => $seg_name,
                doc_count => $doc_count,
                invindex  => $invindex,
            );
        }
    }
}

# Write "segments" file
sub write_infos {
    my ( $self, $invindex ) = @_;
    my $num_segs = scalar keys %{ $self->{infos} };
    my $tempname = 'segments.new';
    $invindex->delete_file($tempname) if $invindex->file_exists($tempname);
    my $outstream = $invindex->open_outstream($tempname);

    # prepare header
    $self->{version}++;
    my @outstuff = ( FORMAT, $self->{version}, $self->{counter}, $num_segs );

    # prepare data
    push @outstuff, map {
        ( $self->{infos}{$_}{seg_name}, $self->{infos}{$_}{doc_count} )
        }
        sort keys %{ $self->{infos} };

    # write it all out
    my $template = 'iQii' . ( 'Ti' x $num_segs );
    $outstream->lu_write( $template, @outstuff );
    $outstream->close;

    # clobber the old segments file
    $invindex->rename_file( $tempname, "segments" );
}

package KinoSearch1::Index::SegInfo;
use strict;
use warnings;
use KinoSearch1::Util::ToolSet;
use base qw( KinoSearch1::Util::Class );

BEGIN {
    __PACKAGE__->init_instance_vars(
        # constructor params / members
        seg_name  => '',
        doc_count => 0,
        invindex  => undef,
    );
    __PACKAGE__->ready_get(qw( seg_name doc_count invindex ));
}

1;

__END__

=begin devdocs

=head1 NAME

KinoSearch1::Index::SegInfos - manage segment statistical data

=head1 DESCRIPTION

SegInfos ties together the segments which make up an invindex.  It stores a
little information about each, plus some unifying information such as the
counter used to name new segments.

=head1 COPYRIGHT

Copyright 2005-2010 Marvin Humphrey

=head1 LICENSE, DISCLAIMER, BUGS, etc.

See L<KinoSearch1> version 1.00.

=end devdocs
=cut