| 1 | package Plucene::Index::SegmentTermPositions; | ||||||||||
| 2 | |||||||||||
| 3 | # final class SegmentTermPositions | ||||||||||
| 4 | # extends SegmentTermDocs implements TermPositions | ||||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | Plucene::Index::SegmentTermPositions - Segment term positions | ||||||||||
| 9 | |||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||
| 11 | |||||||||||
| 12 | # isa Plucene::Index::SegmentTermDocs | ||||||||||
| 13 | |||||||||||
| 14 | $seg_term_pos->skipping_doc; | ||||||||||
| 15 | |||||||||||
| 16 | my $next = $seg_term_pos->next_position; | ||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This is the segment term positions class. | ||||||||||
| 21 | |||||||||||
| 22 | =head1 METHODS | ||||||||||
| 23 | |||||||||||
| 24 | =cut | ||||||||||
| 25 | |||||||||||
| 26 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 18 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 18 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 18 | ▶ | use base 'Plucene::Index::SegmentTermDocs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | |||||||||||
| 33 | 18 | __PACKAGE__->mk_accessors(qw(_prox_stream _prox_count)); | |||||||||
| 34 | |||||||||||
| 35 | # private InputStream proxStream; | ||||||||||
| 36 | # private int proxCount; | ||||||||||
| 37 | # private int position; | ||||||||||
| 38 | |||||||||||
| 39 | =head2 new | ||||||||||
| 40 | |||||||||||
| 41 | my $seg_term_pos = Plucene::Index::SegmentTermPositions | ||||||||||
| 42 | ->new(Plucene::Index::SegmentReader $seg_reader); | ||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | # SegmentTermPositions(SegmentReader p) throws IOException { | ||||||||||
| 46 | # super(p); | ||||||||||
| 47 | # this.proxStream = (InputStream)parent.proxStream.clone(); | ||||||||||
| 48 | # } | ||||||||||
| 49 | |||||||||||
| 50 | 314 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | 314 | my $self = shift->SUPER::new(@_); | |||||||||
| 52 | 314 | $self->{_prox_stream} = $self->parent->prox_stream; | |||||||||
| 53 | 314 | $self->{_prox_ptr} = 0; | |||||||||
| 54 | 314 | $self->{_prox_count} = 0; | |||||||||
| 55 | 314 | return $self; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | # final void seek(TermInfo ti) throws IOException { | ||||||||||
| 59 | # super.seek(ti); | ||||||||||
| 60 | # if (ti != null) | ||||||||||
| 61 | # proxStream.seek(ti.proxPointer); | ||||||||||
| 62 | # else | ||||||||||
| 63 | # proxCount = 0; | ||||||||||
| 64 | # } | ||||||||||
| 65 | |||||||||||
| 66 | 33149 | ▶ | sub _seek { | ||||||||
|
Subroutine
_seek: called CC=2 SCAR=7.4
| |||||||||||
| 67 | 33149 | my ($self, $ti) = @_; | |||||||||
| 68 | 33149 | $self->SUPER::_seek($ti); | |||||||||
| 69 | 33149 | ▶ | if ($ti) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 33149 | $self->{_prox_ptr} = $ti->prox_pointer; | |||||||||
| 71 | } else { | ||||||||||
| 72 | 0 | $self->{_prox_count} = 0; | |||||||||
| 73 | } | ||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | =head2 close | ||||||||||
| 77 | |||||||||||
| 78 | $seg_term_pos->close; | ||||||||||
| 79 | |||||||||||
| 80 | =cut | ||||||||||
| 81 | |||||||||||
| 82 | # public final void close() throws IOException { | ||||||||||
| 83 | # super.close(); | ||||||||||
| 84 | # proxStream.close(); | ||||||||||
| 85 | # } | ||||||||||
| 86 | |||||||||||
| 87 | =head2 next_position | ||||||||||
| 88 | |||||||||||
| 89 | my $next = $seg_term_pos->next_position; | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | |||||||||||
| 93 | # public final int nextPosition() throws IOException { | ||||||||||
| 94 | # proxCount--; | ||||||||||
| 95 | # return position += proxStream.readVInt(); | ||||||||||
| 96 | # } | ||||||||||
| 97 | |||||||||||
| 98 | 144775 | ▶ | sub next_position { | ||||||||
|
Subroutine
next_position: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 99 | 144775 | my $self = shift; | |||||||||
| 100 | 144775 | $self->{_prox_count}--; | |||||||||
| 101 | 144775 | return $self->{position} += $self->{_prox_stream}->[ $self->{_prox_ptr}++ ]; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | =head2 skipping_doc | ||||||||||
| 105 | |||||||||||
| 106 | $seg_term_pos->skipping_doc; | ||||||||||
| 107 | |||||||||||
| 108 | =cut | ||||||||||
| 109 | |||||||||||
| 110 | # protected final void skippingDoc() throws IOException { | ||||||||||
| 111 | # for (int f = freq; f > 0; f--) // skip all positions | ||||||||||
| 112 | # proxStream.readVInt(); | ||||||||||
| 113 | # } | ||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | sub skipping_doc { | ||||||||
|
Subroutine
skipping_doc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 116 | 0 | my $self = shift; | |||||||||
| 117 | 0 | $self->{_prox_ptr} += $self->freq; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | # public final boolean next() throws IOException { | ||||||||||
| 121 | # for (int f = proxCount; f > 0; f--) // skip unread positions | ||||||||||
| 122 | # proxStream.readVInt(); | ||||||||||
| 123 | # | ||||||||||
| 124 | # if (super.next()) { // run super | ||||||||||
| 125 | # proxCount = freq; // note frequency | ||||||||||
| 126 | # position = 0; // reset position | ||||||||||
| 127 | # return true; | ||||||||||
| 128 | # } | ||||||||||
| 129 | # return false; | ||||||||||
| 130 | # } | ||||||||||
| 131 | |||||||||||
| 132 | 66590 | ▶ | sub next { | ||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 133 | 66590 | my $self = shift; | |||||||||
| 134 | 66590 | $self->{_prox_ptr} += $self->{_prox_count}; | |||||||||
| 135 | 66590 | ▶ | if ($self->SUPER::next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 136 | 33449 | $self->{_prox_count} = $self->freq; | |||||||||
| 137 | 33449 | $self->{position} = 0; | |||||||||
| 138 | 33449 | return 1; | |||||||||
| 139 | } | ||||||||||
| 140 | 33141 | return; | |||||||||
| 141 | } | ||||||||||
| 142 | |||||||||||
| 143 | =head2 read | ||||||||||
| 144 | |||||||||||
| 145 | This should not be called | ||||||||||
| 146 | |||||||||||
| 147 | =cut | ||||||||||
| 148 | |||||||||||
| 149 | # public final int read(final int[] docs, final int[] freqs) | ||||||||||
| 150 | # throws IOException { | ||||||||||
| 151 | # throw new RuntimeException(); | ||||||||||
| 152 | # } | ||||||||||
| 153 | |||||||||||
| 154 | 0 | ▶ | sub read { croak "'read' should not be called" } | ||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 155 | |||||||||||
| 156 | 18 | 1; | |||||||||