line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Index::Term; |
2
|
35
|
|
|
35
|
|
26806
|
use strict; |
|
35
|
|
|
|
|
71
|
|
|
35
|
|
|
|
|
1151
|
|
3
|
35
|
|
|
35
|
|
167
|
use warnings; |
|
35
|
|
|
|
|
68
|
|
|
35
|
|
|
|
|
764
|
|
4
|
35
|
|
|
35
|
|
737
|
use KinoSearch1::Util::ToolSet; |
|
35
|
|
|
|
|
69
|
|
|
35
|
|
|
|
|
4613
|
|
5
|
35
|
|
|
35
|
|
185
|
use base qw( KinoSearch1::Util::Class ); |
|
35
|
|
|
|
|
76
|
|
|
35
|
|
|
|
|
3724
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
35
|
|
|
35
|
|
288
|
__PACKAGE__->init_instance_vars( |
9
|
|
|
|
|
|
|
field => undef, |
10
|
|
|
|
|
|
|
text => undef, |
11
|
|
|
|
|
|
|
); |
12
|
35
|
|
|
|
|
629
|
__PACKAGE__->ready_get_set(qw( field text )); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
648
|
50
|
|
648
|
1
|
2581
|
croak("usage: KinoSearch1::Index::Term->new( field, text )") |
17
|
|
|
|
|
|
|
unless @_ == 3; |
18
|
648
|
|
|
|
|
4255
|
return bless { |
19
|
|
|
|
|
|
|
field => $_[1], |
20
|
|
|
|
|
|
|
text => $_[2], |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
__PACKAGE__; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Alternate, internal constructor. |
26
|
|
|
|
|
|
|
sub new_from_string { |
27
|
10
|
|
|
10
|
0
|
120
|
my ( $class, $termstring, $finfos ) = @_; |
28
|
10
|
|
|
|
|
20
|
my $field_num = unpack( 'n', bytes::substr( $termstring, 0, 2, '' ) ); |
29
|
10
|
|
|
|
|
70
|
my $field_name = $finfos->field_name($field_num); |
30
|
10
|
|
|
|
|
22
|
return __PACKAGE__->new( $field_name, $termstring ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Return an encoded termstring. Requires a FieldInfos to discover fieldnum. |
34
|
|
|
|
|
|
|
sub get_termstring { |
35
|
2068
|
50
|
|
2068
|
0
|
4943
|
confess('usage: $term->get_termstring($finfos)') |
36
|
|
|
|
|
|
|
unless @_ == 2; |
37
|
2068
|
|
|
|
|
2457
|
my ( $self, $finfos ) = @_; |
38
|
2068
|
|
|
|
|
6897
|
my $field_num = $finfos->get_field_num( $self->{field} ); |
39
|
2068
|
100
|
|
|
|
4462
|
return unless defined $field_num; |
40
|
2022
|
|
|
|
|
9892
|
return pack( 'n', $field_num ) . $self->{text}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub to_string { |
44
|
12
|
|
|
12
|
1
|
19
|
my $self = shift; |
45
|
12
|
|
|
|
|
67
|
return "$self->{field}:$self->{text}"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |