This file is indexed.

/usr/share/perl5/Plucene/Index/TermInfosReader.pm is in libplucene-perl 1.25-3.

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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package Plucene::Index::TermInfosReader;

=head1 NAME 

Plucene::Index::TermInfosReader - read the term infos file

=head1 SYNOPSIS

	my $reader = Plucene::Index::TermInfosReader->new(
			$dir_name, $segment, $fis);

	my Plucene::Index::TermInfo $term_info = 
		$reader->get(Plucene::Index::Term $term);
		
	my Plucene::Index::SegmentTermEnum $enum = 
		$reader->terms(Plucene::Index::Term $term);
	
=head1 DESCRIPTION

This reads a term infos file.

=head1 METHODS

=cut

use strict;
use warnings;

use Memoize;

use Carp qw/confess/;

use Plucene::Index::SegmentTermEnum;
use Plucene::Index::TermInfosWriter;
use Plucene::Store::InputStream;

=head2 new

	my $reader = Plucene::Index::TermInfosReader->new(
			$dir_name, $segment, $fis);

This will create a new Plucene::Index::TermInfosReader object with
the passed directory name, segment name and field infos.
			
=cut

sub new {
	my ($class, $dir, $seg, $fis) = @_;
	my $file = "$dir/$seg.tis";
	confess("$file is already open!") unless -s $file;

	my $self = bless {
		directory   => $dir,
		segment     => $seg,
		field_infos => $fis,
		enum        => Plucene::Index::SegmentTermEnum->new(
			Plucene::Store::InputStream->new($file),
			$fis, 0
		),
	}, $class;
	$self->{size} = $self->{enum}->size;
	$self->_read_index;
	return $self;
}

sub _read_index {
	my $self       = shift;
	my $index_enum = Plucene::Index::SegmentTermEnum->new(
		Plucene::Store::InputStream->new(
			"$self->{directory}/$self->{segment}.tii"),
		$self->{field_infos},
		1
	);
	my $size = $index_enum->size;
	$self->{index_terms}    = [];
	$self->{index_infos}    = [];
	$self->{index_pointers} = [];
	for (my $i = 0 ; $index_enum->next ; $i++) {
		$self->{index_terms}->[$i] = $index_enum->term;

		# Need to clone here.
		$self->{index_infos}->[$i] =
			Plucene::Index::TermInfo->new({ %{ $index_enum->term_info } });
		$self->{index_pointers}->[$i] = $index_enum->index_pointer;
	}
}

memoize('_get_index_offset');

sub _get_index_offset {
	my ($self, $term) = @_;
	my $lo = 0;
	my $hi = $#{ $self->{index_terms} };

	while ($hi >= $lo) {
		my $mid = ($lo + $hi) >> 1;

		# Terms are comparable, hooray
		my $delta = $term->_cmp($self->{index_terms}->[$mid]);
		if    ($delta < 0) { $hi = $mid - 1; }
		elsif ($delta > 0) { $lo = $mid + 1; }
		else { return $mid }
	}
	return $hi;
}

=head2 get

	my Plucene::Index::TermInfo $term_info = 
		$reader->get(Plucene::Index::Term $term);

=cut

sub get {
	my ($self, $term) = @_;
	return unless $self->{size};
	$self->_seek_enum($self->_get_index_offset($term));
	return $self->_scan_enum($term);
}

sub _seek_enum {
	my ($self, $offset) = @_;
	$self->{enum}->seek(
		$self->{index_pointers}->[$offset],
		$offset * Plucene::Index::TermInfosWriter::INDEX_INTERVAL() - 1,
		$self->{index_terms}->[$offset],
		$self->{index_infos}->[$offset]);
}

sub _scan_enum {
	my ($self, $term) = @_;
	1 while $term->gt($self->{enum}->term) && $self->{enum}->next;
	return $self->{enum}->term_info
		if $self->{enum}->term
		and $self->{enum}->term->eq($term);
	return;
}

=head2 get_int / get_position

These are never called.

=cut

sub get_int      { }
sub get_position { }

=head2 terms

	my Plucene::Index::SegmentTermEnum $enum = 
		$reader->terms(Plucene::Index::Term $term);

This will return the Plucene::Index::SegmentTermEnum for the passed-in
Plucene::Index::Term.
		
=cut

sub terms {
	my ($self, $term) = @_;
	$term ? $self->get($term) : $self->_seek_enum(0);
	$self->{enum}->clone;
}

1;