/usr/lib/perl5/KinoSearch1/Index/Term.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 | package KinoSearch1::Index::Term;
use strict;
use warnings;
use KinoSearch1::Util::ToolSet;
use base qw( KinoSearch1::Util::Class );
BEGIN {
__PACKAGE__->init_instance_vars(
field => undef,
text => undef,
);
__PACKAGE__->ready_get_set(qw( field text ));
}
sub new {
croak("usage: KinoSearch1::Index::Term->new( field, text )")
unless @_ == 3;
return bless {
field => $_[1],
text => $_[2],
},
__PACKAGE__;
}
# Alternate, internal constructor.
sub new_from_string {
my ( $class, $termstring, $finfos ) = @_;
my $field_num = unpack( 'n', bytes::substr( $termstring, 0, 2, '' ) );
my $field_name = $finfos->field_name($field_num);
return __PACKAGE__->new( $field_name, $termstring );
}
# Return an encoded termstring. Requires a FieldInfos to discover fieldnum.
sub get_termstring {
confess('usage: $term->get_termstring($finfos)')
unless @_ == 2;
my ( $self, $finfos ) = @_;
my $field_num = $finfos->get_field_num( $self->{field} );
return unless defined $field_num;
return pack( 'n', $field_num ) . $self->{text};
}
sub to_string {
my $self = shift;
return "$self->{field}:$self->{text}";
}
1;
__END__
__H__
#ifndef H_KINOSEARCH_INDEX_TERM
#define H_KINOSEARCH_INDEX_TERM 1
/* Field Number Length -- the number of bytes occupied by the field number at
* the top of a TermString.
*/
#define KINO_FIELD_NUM_LEN 2
#endif /* include guard */
__POD__
=head1 NAME
KinoSearch1::Index::Term - string of text associated with a field
=head1 SYNOPSIS
my $foo_term = KinoSearch1::Index::Term->new( 'content', 'foo' );
my $term_query = KinoSearch1::Search::TermQuery->new( term => $foo_term );
=head1 DESCRIPTION
The Term is the unit of search. It has two characteristics: a field name, and
term text.
=head1 METHODS
=head2 new
my $term = KinoSearch1::Index::Term->new( FIELD_NAME, TERM_TEXT );
Constructor.
=head2 set_text get_text set_field get_field
Getters and setters.
=head2 to_string
Returns a string representation of the Term object.
=head1 COPYRIGHT
Copyright 2005-2010 Marvin Humphrey
=head1 LICENSE, DISCLAIMER, BUGS, etc.
See L<KinoSearch1> version 1.00.
=cut
|