| 1 | package WARC::Record::Logical; # -*- CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | require WARC::Record::FromVolume; | |||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | our @ISA = qw(WARC::Record::FromVolume); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use WARC; *WARC::Record::Logical::VERSION = \$WARC::VERSION; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Math::BigInt; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Scalar::Util qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Symbol 'geniosym'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | require WARC::Fields; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | require WARC::Record::Logical::Block; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | require WARC::Record::Logical::Heuristics; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # inherit _set | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # inherit compareTo | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # This implementation uses a hash as the underlying structure. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | # Keys inherited from WARC::Record base class (via WARC::Record::FromVolume): | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # fields | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # Keys inherited from WARC::Record::FromVolume base class: | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # collection (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # Parent WARC::Collection object, if available | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # Keys defined by this class: | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # segments | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # Array, each element is array of: | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # SEG_REC: WARC::Record::FromVolume | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # SEG_BASE: integer, logical offset of first octet in segment block | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # SEG_LENGTH: integer, number of octets in segment data block | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use constant {SEG_REC => 0, SEG_LENGTH => 1, SEG_BASE => 2}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | use constant SEGMENT_INDEX => qw/SEG_REC SEG_LENGTH SEG_BASE/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | sub DESTROY { our $_total_destroyed; $_total_destroyed++ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | sub _dbg_dump { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbg_dump: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | my $out = 'WARC logical record [' | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | .(scalar @{$self->{segments}})." segments] containing:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 53 | my @out = | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | map {s/^/ /gm; $_} map {$_->[SEG_REC]->_dbg_dump} @{$self->{segments}}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | $out .= join("\n", @out); | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # inherit new | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | sub _read { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 17 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: called CC=31 SCAR=34.3
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 17 | my $member = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 17 | my %ob = (); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 17 | ▶ | $ob{collection} = $member->{collection} if defined $member->{collection}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 17 | my $member_segment_number = $member->field('WARC-Segment-Number'); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 17 | ▶ | croak "attempting to load logical record for non-segmented record" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | unless $member_segment_number; | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # find the first segment | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 16 | my $first_segment = undef; my @clues = (); | |||||||||||||||||||||||||||||||||||||||||
| 75 | SEGMENT: { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 16 | ▶ | if ($member_segment_number == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | $first_segment = $member; # <-- that was easy... | |||||||||||||||||||||||||||||||||||||||||
| 78 | } else { # ... less easy: go find the first segment... | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 8 | my $segment_origin_id = $member->field('WARC-Segment-Origin-ID'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | ▶ | croak "record segment lacks required 'WARC-Segment-Origin-ID' field" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | unless $segment_origin_id; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | ▶ | if (defined $member->{collection} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $member->{"collection"} and $member->{"collection"}->searchable("record_id")
MC/DC100%2/2
defined $member->{"collection"} and $member->{"collection"}->searchable("record_id")
defined $member->{"collection"}
$member->{"collection"}->searchable("record_id")
Truth table100%3/3
A and B
A= defined $member->{"collection"}B= $member->{"collection"}->searchable("record_id")
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | && $member->{collection}->searchable('record_id')) { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | $first_segment = $member->{collection}->search | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | (record_id => $segment_origin_id); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | ▶ | next SEGMENT if defined $first_segment; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | carp "index failed to locate first segment by Record-ID"; | |||||||||||||||||||||||||||||||||||||||||
| 88 | # ... and onwards to heuristics ... | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | ($first_segment, @clues) = | |||||||||||||||||||||||||||||||||||||||||
| 91 | WARC::Record::Logical::Heuristics::find_first_segment ($member); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 15 | ▶ | croak "failed to locate first segment of logical record" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | unless defined $first_segment; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # find the other segments | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 12 | my @pool = (); | |||||||||||||||||||||||||||||||||||||||||
| 99 | SEGMENT: { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 12 | ▶ | if (defined $member->{collection} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $member->{"collection"} and $member->{"collection"}->searchable("segment_origin_id")
MC/DC100%2/2
defined $member->{"collection"} and $member->{"collection"}->searchable("segment_origin_id")
defined $member->{"collection"}
$member->{"collection"}->searchable("segment_origin_id")
Truth table100%3/3
A and B
A= defined $member->{"collection"}B= $member->{"collection"}->searchable("segment_origin_id")
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | && $member->{collection}->searchable('segment_origin_id')) { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | @pool = $member->{collection}->search | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | (segment_origin_id => $first_segment->id); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 20 | @pool = map {$_->[0]} sort {$a->[1] <=> $b->[1]} | |||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | map {[$_, $_->field('WARC-Segment-Number')]} @pool; | |||||||||||||||||||||||||||||||||||||||||
| 106 | last SEGMENT if # we have all of the segments | ||||||||||||||||||||||||||||||||||||||||||
| 107 | (@pool | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | && ($pool[-1]->field('WARC-Segment-Number') == (1+@pool)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@pool and $pool[-1]->field("WARC-Segment-Number") == 1 + @pool and $pool[-1]->field("WARC-Segment-Total-Length")
@pool and $pool[-1]->field("WARC-Segment-Number") == 1 + @pool
MC/DC100%3/3
@pool and $pool[-1]->field("WARC-Segment-Number") == 1 + @pool and $pool[-1]->field("WARC-Segment-Total-Length")
@pool
$pool[-1]->field("WARC-Segment-Number") == 1 + @pool
$pool[-1]->field("WARC-Segment-Total-Length")
Truth table100%4/4
A and B and C
A= @poolB= $pool[-1]->field("WARC-Segment-Number") == 1 + @poolC= $pool[-1]->field("WARC-Segment-Total-Length")
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | && ($pool[-1]->field('WARC-Segment-Total-Length'))); | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | carp "index failed to locate all segments by Origin-ID"; | |||||||||||||||||||||||||||||||||||||||||
| 111 | # ... and onwards to heuristics ... | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 9 | push @pool, (WARC::Record::Logical::Heuristics::find_continuation | |||||||||||||||||||||||||||||||||||||||||
| 114 | ($first_segment, @pool, @clues)); | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # sort again in case heuristics added more records | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 13 | @pool = map {$_->[0]} sort {$a->[1] <=> $b->[1]} | |||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | map {[$_, $_->field('WARC-Segment-Number')]} @pool; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | ▶ | croak "failed to locate any continuation segments for logical record" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | unless scalar @pool > 0; | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # assemble logical record segments | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | my @record = ($first_segment); | |||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | ▶ | while ($i < @pool) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 24 | my $segment_number = $pool[$i]->field('WARC-Segment-Number'); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 24 | push @record, $pool[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 24 | ▶ | $i++ # skip duplicate segments heuristics may have found | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i < @pool and $segment_number == $pool[$i]->field("WARC-Segment-Number")
MC/DC100%2/2
$i < @pool and $segment_number == $pool[$i]->field("WARC-Segment-Number")
$i < @pool
$segment_number == $pool[$i]->field("WARC-Segment-Number")
Truth table100%3/3
A and B
A= $i < @poolB= $segment_number == $pool[$i]->field("WARC-Segment-Number")
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | while $i < @pool | ||||||||||||||||||||||||||||||||||||||||||
| 131 | && $segment_number == $pool[$i]->field('WARC-Segment-Number'); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # verify logical record | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 9 | ▶ | for (my $i = 0; $i < @record; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 33 | ▶ | croak "logical record segment missing or out-of-place" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | unless $record[$i]->field('WARC-Segment-Number') == (1+$i); | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 32 | ▶ | croak "logical record segment not part of record (corrupted index?)" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$i == 0 or $record[$i]->field("WARC-Segment-Origin-ID") eq $record[0]->id
MC/DC100%2/2
$i == 0 or $record[$i]->field("WARC-Segment-Origin-ID") eq $record[0]->id
$i == 0
$record[$i]->field("WARC-Segment-Origin-ID") eq $record[0]->id
Truth table100%3/3
A or B
A= $i == 0B= $record[$i]->field("WARC-Segment-Origin-ID") eq $record[0]->id
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | unless $i == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 141 | || $record[$i]->field('WARC-Segment-Origin-ID') eq $record[0]->id; | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | croak "final segment lacks required 'WARC-Segment-Total-Length' header" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | unless $record[-1]->field('WARC-Segment-Total-Length'); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | # assemble logical record header | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 6 | my $fields = $record[0]->fields->clone; | |||||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # Set "Content-Length" to the total length | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | $fields->field('Content-Length', | |||||||||||||||||||||||||||||||||||||||||
| 151 | $record[-1]->field('WARC-Segment-Total-Length')); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # Transfer any other non-segment-related headers that appear on the | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # last segment and are not present at the first segment. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 6 | foreach my $key (grep !m/^WARC-Segment-/, keys %{$record[-1]->fields}) { | |||||||||||||||||||||||||||||||||||||||||
| 155 | 22 | ▶ | $fields->field($key, $record[-1]->field($key)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | unless defined $fields->field($key); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # Delete the block digest header, since it is from a segment. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | $fields->field('WARC-Block-Digest' => []); | |||||||||||||||||||||||||||||||||||||||||
| 160 | # Delete all segment-related headers | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 6 | my %fields; tie %fields, ref $fields, $fields; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | my @segment_headers = grep m/^WARC-Segment/, keys %fields; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | $fields->field($_ => []) for @segment_headers; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | untie %fields; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | $fields->set_readonly; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | $ob{fields} = $fields; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # assemble logical record data | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 6 | my @segments = (); | |||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | my $running_base = 0; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | ▶ | for (my $i = 0; $i < @record; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 27 | my @row = (); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 27 | $row[SEG_REC] = $record[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 27 | $row[SEG_LENGTH] = 0+$record[$i]->field('Content-Length'); | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 27 | ▶ | $running_base = Math::BigInt->new($running_base) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $running_base and $running_base + $row[1] < $running_base
MC/DC100%2/2
not ref $running_base and $running_base + $row[1] < $running_base
not ref $running_base
$running_base + $row[1] < $running_base
Truth table100%3/3
not(A) and B
A= not ref $running_baseB= $running_base + $row[1] < $running_base
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | if ((not ref $running_base) | ||||||||||||||||||||||||||||||||||||||||||
| 182 | && (($running_base + $row[SEG_LENGTH]) < $running_base)); | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 27 | $row[SEG_BASE] = $running_base; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 27 | $segments[$i] = \@row; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 27 | $running_base += $row[SEG_LENGTH]; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | $ob{segments} = \@segments; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | { our $_total_read; $_total_read++ } | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | my $self = bless \%ob, $class; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | $_->[SEG_REC]->{logical} = $self for @{$self->{segments}}; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 6 | Scalar::Util::weaken $_->[SEG_REC]->{logical} for @{$self->{segments}}; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | sub protocol { (shift)->{segments}[0][SEG_REC]->protocol } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 20 | ▶ | sub volume { (shift)->{segments}[0][SEG_REC]->volume } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
volume: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 14 | ▶ | sub offset { (shift)->{segments}[0][SEG_REC]->offset } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | sub logical { shift } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logical: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | sub segments { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 13 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
segments: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 10 | return map {$_->[SEG_REC]} @{(shift)->{segments}} | |||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | return scalar @{(shift)->{segments}} | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | sub next { (shift)->{segments}[-1][SEG_REC]->next } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | sub open_block { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_block: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | my $xhandle = Symbol::geniosym; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | tie *$xhandle, 'WARC::Record::Logical::Block', $self; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | return $xhandle; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | ▶ | sub open_continued { (shift)->open_block } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_continued: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # inherit replay | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # inherit open_payload | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||||||||||||||||||||||