/usr/share/perl5/Plucene/Index/FieldsReader.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 | package Plucene::Index::FieldsReader;
=head1 NAME
Plucene::Index::FieldsReader - read Fields in a Document
=head1 SYNOPSIS
my $reader = Plucene::Index::FieldsReader->new(
$dir_name, $segment, $field_infos);
my Plucene::Document $doc = $reader->doc($offset);
my $size = $reader->size;
=head1 DESCRIPTION
This class gives access to documents within the index.
=head1 METHODS
=cut
use strict;
use warnings;
use Plucene::Document;
use Plucene::Document::Field;
use Plucene::Store::InputStream;
=head2 new
my $reader = Plucene::Index::FieldsReader->new(
$dir_name, $segment, $field_infos);
This will create a new Plucene::Index::FieldsReader with the passed in
directory name, segment and field infos.
=cut
sub new {
my ($class, $dir, $seg, $fn) = @_;
bless {
field_infos => $fn,
fields => Plucene::Store::InputStream->new("$dir/$seg.fdt"),
index => Plucene::Store::InputStream->new("$dir/$seg.fdx"),
size => ((-s "$dir/$seg.fdx") / 8) }, $class;
}
=head2 size
my $size = $reader->size;
This returns the size.
=cut
sub size { $_[0]->{size} }
=head2 doc
my Plucene::Document $doc = $reader->doc($offset);
This will return the Plucene::Document object found at the passed in
position.
=cut
sub doc {
my ($self, $n) = @_;
$self->{index}->seek($n * 8, 0);
my $pos = $self->{index}->read_long;
$self->{fields}->seek($pos, 0);
my $doc = Plucene::Document->new();
for (1 .. $self->{fields}->read_vint) {
my $fi = $self->{field_infos}->{bynumber}->[ $self->{fields}->read_vint ];
my $bits = $self->{fields}->read_byte;
$doc->add(
bless {
name => $fi->name,
string => $self->{fields}->read_string,
is_stored => 1,
is_indexed => $fi->is_indexed,
is_tokenized => (($bits & 1) != 0) # No, really
} => 'Plucene::Document::Field'
);
}
return $doc;
}
1;
|