| 1 | package Plucene::Index::SegmentMergeInfo; | ||||||||||
| 2 | |||||||||||
| 3 | # final class SegmentMergeInfo | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Plucene::Index::SegmentMergeInfo - Segment Merge information | ||||||||||
| 8 | |||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||
| 10 | |||||||||||
| 11 | my $seg_merge_info | ||||||||||
| 12 | = Plucene::Index::SegmentMergeInfo->new($b, $te, $r); | ||||||||||
| 13 | |||||||||||
| 14 | $seg_merge_info->next; | ||||||||||
| 15 | |||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||
| 17 | |||||||||||
| 18 | This is the Plucene::Index::SegmentMergeInfo class. | ||||||||||
| 19 | |||||||||||
| 20 | =head1 METHODS | ||||||||||
| 21 | |||||||||||
| 22 | =cut | ||||||||||
| 23 | |||||||||||
| 24 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 18 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 18 | ▶ | use Plucene::Index::SegmentTermPositions; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 18 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 18 | __PACKAGE__->mk_accessors(qw( base reader term_enum term postings doc_map)); | |||||||||
| 32 | |||||||||||
| 33 | 18 | ▶ | use overload cmp => sub { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 34 | $_[0]->{term} cmp $_[1]->{term} | ||||||||||
| 35 | 18 | ▶ | || $_[0]->{base} <=> $_[1]->{base}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | }, | ||||||||||
| 37 | 18 | fallback => 1; | |||||||||
| 38 | |||||||||||
| 39 | =head2 new | ||||||||||
| 40 | |||||||||||
| 41 | my $seg_merge_info = Plucene::Index::SegmentMergeInfo | ||||||||||
| 42 | ->new($base, Plucene::Index::TermEnum $te, $reader); | ||||||||||
| 43 | |||||||||||
| 44 | This will create a new Plucene::Index::SegmentMergerInfo object. | ||||||||||
| 45 | |||||||||||
| 46 | =head2 base / reader / term_enum / term / postings / doc_map | ||||||||||
| 47 | |||||||||||
| 48 | Get / set these attributes. | ||||||||||
| 49 | |||||||||||
| 50 | =cut | ||||||||||
| 51 | |||||||||||
| 52 | # SegmentMergeInfo(int b, SegmentTermEnum te, SegmentReader r) | ||||||||||
| 53 | # throws IOException { | ||||||||||
| 54 | # base = b; | ||||||||||
| 55 | # reader = r; | ||||||||||
| 56 | # termEnum = te; | ||||||||||
| 57 | # term = te.term(); | ||||||||||
| 58 | # postings = new SegmentTermPositions(r); | ||||||||||
| 59 | # | ||||||||||
| 60 | # if (reader.deletedDocs != null) { | ||||||||||
| 61 | # // build array which maps document numbers around deletions | ||||||||||
| 62 | # BitVector deletedDocs = reader.deletedDocs; | ||||||||||
| 63 | # int maxDoc = reader.maxDoc(); | ||||||||||
| 64 | # docMap = new int[maxDoc]; | ||||||||||
| 65 | # int j = 0; | ||||||||||
| 66 | # for (int i = 0; i < maxDoc; i++) { | ||||||||||
| 67 | # if (deletedDocs.get(i)) | ||||||||||
| 68 | # docMap[i] = -1; | ||||||||||
| 69 | # else | ||||||||||
| 70 | # docMap[i] = j++; | ||||||||||
| 71 | # } | ||||||||||
| 72 | # } | ||||||||||
| 73 | # } | ||||||||||
| 74 | |||||||||||
| 75 | 283 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||
| 76 | 283 | my ($class, $b, $te, $r) = @_; | |||||||||
| 77 | 283 | my $self = $class->SUPER::new({ | |||||||||
| 78 | base => $b, | ||||||||||
| 79 | reader => $r, | ||||||||||
| 80 | term_enum => $te, | ||||||||||
| 81 | term => $te->term, | ||||||||||
| 82 | postings => Plucene::Index::SegmentTermPositions->new($r), | ||||||||||
| 83 | }); | ||||||||||
| 84 | |||||||||||
| 85 | 283 | ▶ | if (my $del = $r->deleted_docs) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | 0 | my $j; | |||||||||
| 87 | 0 | ▶ | $self->{doc_map} = [ map $del->get($_) ? -1 : $j++, 0 .. $r->max_doc ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | } | ||||||||||
| 89 | 283 | return $self; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | =head2 next | ||||||||||
| 93 | |||||||||||
| 94 | $seg_merge_info->next; | ||||||||||
| 95 | |||||||||||
| 96 | =cut | ||||||||||
| 97 | |||||||||||
| 98 | # final boolean next() throws IOException { | ||||||||||
| 99 | # if (termEnum.next()) { | ||||||||||
| 100 | # term = termEnum.term(); | ||||||||||
| 101 | # return true; | ||||||||||
| 102 | # } else { | ||||||||||
| 103 | # term = null; | ||||||||||
| 104 | # return false; | ||||||||||
| 105 | # } | ||||||||||
| 106 | # } | ||||||||||
| 107 | |||||||||||
| 108 | 33401 | ▶ | sub next { | ||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 109 | 33401 | my $self = shift; | |||||||||
| 110 | 33401 | ▶ | if ($self->{term_enum}->next) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | 33127 | $self->{term} = $self->{term_enum}->term; | |||||||||
| 112 | 33127 | return 1; | |||||||||
| 113 | } else { | ||||||||||
| 114 | 274 | undef $self->{term}; | |||||||||
| 115 | 274 | return; | |||||||||
| 116 | } | ||||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | =head2 close | ||||||||||
| 120 | |||||||||||
| 121 | $seg_merge_info->close; | ||||||||||
| 122 | |||||||||||
| 123 | =cut | ||||||||||
| 124 | |||||||||||
| 125 | # final void close() throws IOException { | ||||||||||
| 126 | # termEnum.close(); | ||||||||||
| 127 | # postings.close(); | ||||||||||
| 128 | # } | ||||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | sub close { | ||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 131 | 0 | my $self = shift; | |||||||||
| 132 | 0 | $self->term_enum->close; | |||||||||
| 133 | 0 | $self->postings->close; | |||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | 18 | 1; | |||||||||