| 1 | package File::Rsync::Mirror::Recentfile::Done; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use File::Rsync::Mirror::Recentfile::FakeBigFloat qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | File::Rsync::Mirror::Recentfile::Done - intervals of already rsynced timespans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use version; our $VERSION = qv('0.0.8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | my $done = File::Rsync::Mirror::Recentfile::Done->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | $done->register ( $recent_events, [3,4,5,9] ); # registers elements 3-5 and 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my $boolean = $done->covered ( $epoch ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | Keeping track of already rsynced timespans. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 EXPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | No exports. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 CONSTRUCTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =head2 my $obj = CLASS->new(%hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | Constructor. On every argument pair the key is a method name and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | value is an argument to that method name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 20 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 20 | my($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 20 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my($method,$arg) = splice @args, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->$method($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 20 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =head1 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | my @accessors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | @accessors = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | "__intervals", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | "_logfile", # undocced: a small yaml dump appended on every change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | "_rfinterval", # undocced: the interval of the holding rf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | my @pod_lines = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 12 | split /\n/, <<'=cut'; push @accessors, grep {s/^=item\s+//} @pod_lines; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =item verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Boolean to turn on a bit verbosity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | ▶ | use accessors @accessors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =head2 $boolean = $obj->covered ( $epoch1, $epoch2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =head2 $boolean = $obj->covered ( $epoch ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | The first form returns true if both timestamps $epoch1 and $epoch2 in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | floating point notation have been registered within one interval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | otherwise false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | The second form returns true if this timestamp has been registered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 104 | ▶ | sub _is_sorted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_sorted: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 104 | my($self,$ivs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 104 | my $Lup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 104 | my $is_sorted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 104 | for my $i (0..$#$ivs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 143 | ▶ | if (defined $Lup) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 39 | ▶ | if (_bigfloatge ($ivs->[$i][0],$Lup)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | warn "Warning (may be harmless): F:R:M:R:Done object contains unsorted internal data"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $DB::single++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 143 | $Lup = $ivs->[$i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 104 | return $is_sorted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 112 | ▶ | sub covered { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
covered: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 112 | my($self, $epoch_high, $epoch_low) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 112 | ▶ | die "Alert: covered() called without or with undefined first argument" unless defined $epoch_high; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 112 | my $intervals = $self->_intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 112 | ▶ | return unless @$intervals; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 104 | ▶ | if (defined $epoch_low) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 26 | ▶ | ($epoch_high,$epoch_low) = ($epoch_low,$epoch_high) if _bigfloatgt($epoch_low,$epoch_high); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 104 | my $is_sorted = $self->_is_sorted($intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 104 | for my $iv (@$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 139 | my($upper,$lower) = @$iv; # may be the same | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 139 | ▶ | if (defined $epoch_low) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 36 | my $goodbound = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 36 | for my $e ($epoch_high,$epoch_low) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 72 | ▶ | $goodbound++ if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$e eq $upper or $e eq $lower or &_bigfloatlt($e, $upper) and &_bigfloatgt($e, $lower)
$e eq $upper or $e eq $lower
&_bigfloatlt($e, $upper) and &_bigfloatgt($e, $lower)
MC/DC100%4/4
$e eq $upper or $e eq $lower or &_bigfloatlt($e, $upper) and &_bigfloatgt($e, $lower)
$e eq $upper
$e eq $lower
&_bigfloatlt($e, $upper)
&_bigfloatgt($e, $lower)
Truth table100%5/5
A or B or C and D
A= $e eq $upperB= $e eq $lowerC= &_bigfloatlt($e, $upper)D= &_bigfloatgt($e, $lower)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | $e eq $upper || $e eq $lower || (_bigfloatlt($e,$upper) && _bigfloatgt($e,$lower)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 36 | ▶ | return 1 if $goodbound > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 103 | ▶ | if ( _bigfloatle ( $epoch_high, $upper ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 65 | ▶ | if ( _bigfloatge ( $epoch_high, $lower )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | return 1; # "between" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } elsif ($is_sorted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 38 | return 0; # no chance anymore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 52 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | =head2 (void) $obj1->merge ( $obj2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | Integrates all intervals in $obj2 into $obj1. Overlapping intervals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | are conflated/folded/consolidated. Sort order is preserved as decreasing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 48 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 48 | my($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 48 | my $intervals = $self->_intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 48 | my $ointervals = $other->_intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 48 | OTHER: for my $oiv (@$ointervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 69 | my $splicepos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 69 | ▶ | if (@$intervals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 69 | SELF: for my $i (0..$#$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 113 | my $iv = $intervals->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 113 | ▶ | if ( _bigfloatlt ($oiv->[0],$iv->[1]) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # both oiv lower than iv => next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 78 | next SELF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 35 | ▶ | if ( _bigfloatgt ($oiv->[1],$iv->[0]) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # both oiv greater than iv => insert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 33 | $splicepos = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 33 | last SELF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # larger(left-iv,left-oiv) becomes left, smaller(right-iv,right-oiv) becomes right | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | $iv->[0] = _bigfloatmax ($oiv->[0],$iv->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | $iv->[1] = _bigfloatmin ($oiv->[1],$iv->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | next OTHER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 67 | ▶ | unless (defined $splicepos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 34 | ▶ | if ( _bigfloatlt ($oiv->[0], $intervals->[-1][1]) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 34 | $splicepos = @$intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | die "Panic: left-oiv[$oiv->[0]] should be smaller than smallest[$intervals->[-1][1]]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 67 | splice @$intervals, $splicepos, 0, [@$oiv]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $intervals->[0] = [@$oiv]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | =head2 (void) $obj->register ( $recent_events_arrayref, $register_arrayref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | =head2 (void) $obj->register ( $recent_events_arrayref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | The first arrayref is a list of hashes that contain a key called | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | C<epoch> which is a string looking like a number. The second arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | is a list if integers which point to elements in the first arrayref to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | be registered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | The second form registers all events in $recent_events_arrayref. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 25 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=9 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 25 | my($self, $re, $reg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 25 | my $intervals = $self->_intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 25 | ▶ | unless ($reg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $reg = [0..$#$re]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 25 | REGISTRANT: for my $i (@$reg) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 86 | my $logfile = $self->_logfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 86 | ▶ | if ($logfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | require YAML::Syck; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | open my $fh, ">>", $logfile or die "Could not open '$logfile': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | print $fh YAML::Syck::Dump({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | At => "before", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | Brfinterval => $self->_rfinterval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | Ci => $i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ($i>0 ? ("Dre-1" => $re->[$i-1]) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | "Dre-0" => $re->[$i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ($i<$#$re ? ("Dre+1" => $re->[$i+1]) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | Eintervals => $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | $self->_register_one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 86 | i => $i, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | re => $re, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | intervals => $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 86 | ▶ | if ($logfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | require YAML::Syck; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | open my $fh, ">>", $logfile or die "Could not open '$logfile': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | print $fh YAML::Syck::Dump({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | At => "after", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | intervals => $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 86 | ▶ | sub _register_one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_one: called CC=16 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 86 | my($self, $one) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 86 | my($i,$re,$intervals) = @{$one}{qw(i re intervals)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 86 | ▶ | die sprintf "Panic: illegal i[%d] larger than number of events[%d]", $i, $#$re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | if $i > $#$re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 86 | my $epoch = $re->[$i]{epoch}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 86 | ▶ | return if $self->covered ( $epoch ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 82 | ▶ | if (@$intervals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 74 | my $registered = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 74 | IV: for my $iv (@$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 99 | my($ivhi,$ivlo) = @$iv; # may be the same | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 99 | ▶ | if ($i > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$i > 0 and &_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo) and &_bigfloatle($$re[$i - 1]{"epoch"}, $ivhi) and &_bigfloatge($iv->[1], $epoch)
$i > 0 and &_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo) and &_bigfloatle($$re[$i - 1]{"epoch"}, $ivhi)
$i > 0 and &_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo)
MC/DC75%3/4
$i > 0 and &_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo) and &_bigfloatle($$re[$i - 1]{"epoch"}, $ivhi) and &_bigfloatge($iv->[1], $epoch)
$i > 0
&_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo)
&_bigfloatle($$re[$i - 1]{"epoch"}, $ivhi)
&_bigfloatge($iv->[1], $epoch)
Truth table80%4/5
A and B and C and D
A= $i > 0B= &_bigfloatge($$re[$i - 1]{"epoch"}, $ivlo)C= &_bigfloatle($$re[$i - 1]{"epoch"}, $ivhi)D= &_bigfloatge($iv->[1], $epoch)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | && _bigfloatge($re->[$i-1]{epoch}, $ivlo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | && _bigfloatle($re->[$i-1]{epoch}, $ivhi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | && _bigfloatge($iv->[1],$epoch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # if left neighbor in re belongs to this interval, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # then I belong to it too; let us lower the ivlo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 41 | $iv->[1] = $epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 41 | $registered++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 99 | ▶ | if ($i < $#$re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$i < $re->$#* and &_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi) and &_bigfloatge($$re[$i + 1]{"epoch"}, $ivlo) and &_bigfloatle($iv->[0], $epoch)
$i < $re->$#* and &_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi) and &_bigfloatge($$re[$i + 1]{"epoch"}, $ivlo)
$i < $re->$#* and &_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi)
MC/DC75%3/4
$i < $re->$#* and &_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi) and &_bigfloatge($$re[$i + 1]{"epoch"}, $ivlo) and &_bigfloatle($iv->[0], $epoch)
$i < $re->$#*
&_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi)
&_bigfloatge($$re[$i + 1]{"epoch"}, $ivlo)
&_bigfloatle($iv->[0], $epoch)
Truth table80%4/5
A and B and C and D
A= $i < $re->$#*B= &_bigfloatle($$re[$i + 1]{"epoch"}, $ivhi)C= &_bigfloatge($$re[$i + 1]{"epoch"}, $ivlo)D= &_bigfloatle($iv->[0], $epoch)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | && _bigfloatle($re->[$i+1]{epoch}, $ivhi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | && _bigfloatge($re->[$i+1]{epoch}, $ivlo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | && _bigfloatle($iv->[0],$epoch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # ditto for right neighbor; increase the ivhi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 33 | $iv->[0] = $epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 33 | $registered++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 99 | ▶ | last IV if $registered>=2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 74 | ▶ | if ($registered == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 13 | $self->_register_one_fold2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $epoch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } elsif ($registered == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 48 | $self->_register_one_fold1 ($intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 13 | $self->_register_one_fold0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | $epoch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | $intervals->[0] = [($epoch)x2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 13 | ▶ | sub _register_one_fold0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_one_fold0: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 13 | my($self, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | $epoch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 13 | my $splicepos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 13 | for my $i (0..$#$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 19 | ▶ | if (_bigfloatgt ($epoch, $intervals->[$i][0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | $splicepos = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 13 | ▶ | unless (defined $splicepos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | ▶ | if (_bigfloatlt ($epoch, $intervals->[-1][1])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | $splicepos = @$intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | die "Panic: epoch[$epoch] should be smaller than smallest[$intervals->[-1][1]]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 13 | splice @$intervals, $splicepos, 0, [($epoch)x2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # conflate: eliminate overlapping intervals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 48 | ▶ | sub _register_one_fold1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_one_fold1: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 48 | my($self,$intervals) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 48 | LOOP: while () { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 48 | my $splicepos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 48 | for my $i (0..$#$intervals-1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | if (_bigfloatle ($intervals->[$i][1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $intervals->[$i+1][0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $intervals->[$i+1][0] = $intervals->[$i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $splicepos = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 48 | ▶ | if (defined $splicepos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | splice @$intervals, $splicepos, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 48 | last LOOP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 25 | ▶ | sub _register_one_fold2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_one_fold2: called CC=12 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 25 | my($self, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $intervals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | $epoch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # we know we have hit twice, like in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # 40:[45,40], [40,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # 40:[45,40],[42,37],[40,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # 45:[45,40], [45,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # 45:[45,40],[42,37],[45,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # 35:[45,35], [40,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # 35:[45,35],[42,37],[40,35] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 25 | my($splicepos, $splicelen, %assert_between); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 25 | INTERVAL: for my $i (0..$#$intervals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 32 | ▶ | if ( $epoch eq $intervals->[$i][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$epoch eq $intervals->[$i][0] or $epoch eq $intervals->[$i][1]
MC/DC100%2/2
$epoch eq $intervals->[$i][0] or $epoch eq $intervals->[$i][1]
$epoch eq $intervals->[$i][0]
$epoch eq $intervals->[$i][1]
Truth table100%3/3
A or B
A= $epoch eq $intervals->[$i][0]B= $epoch eq $intervals->[$i][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | or $epoch eq $intervals->[$i][1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 25 | ▶ | for (my $j = 1; $i+$j <= $#$intervals; $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 34 | ▶ | if ( $epoch eq $intervals->[$i+$j][0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$epoch eq $$intervals[$i + $j][0] or $epoch eq $$intervals[$i + $j][1]
MC/DC100%2/2
$epoch eq $$intervals[$i + $j][0] or $epoch eq $$intervals[$i + $j][1]
$epoch eq $$intervals[$i + $j][0]
$epoch eq $$intervals[$i + $j][1]
Truth table100%3/3
A or B
A= $epoch eq $$intervals[$i + $j][0]B= $epoch eq $$intervals[$i + $j][1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | or $epoch eq $intervals->[$i+$j][1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 25 | $intervals->[$i+$j][0] = _bigfloatmax($intervals->[$i][0],$intervals->[$i+$j][0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 25 | $intervals->[$i+$j][1] = _bigfloatmin($intervals->[$i][1],$intervals->[$i+$j][1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 25 | $splicepos = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 25 | $splicelen = $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 25 | last INTERVAL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 9 | for my $k (0,1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 18 | $assert_between{$intervals->[$i+$j][$k]}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 25 | ▶ | if (defined $splicepos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 25 | for my $k (keys %assert_between) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 18 | ▶ | if (_bigfloatgt($k,$intervals->[$splicepos+$splicelen][0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&_bigfloatgt($k, $$intervals[$splicepos + $splicelen][0]) or &_bigfloatlt($k, $$intervals[$splicepos + $splicelen][1])
MC/DC0%0/2
&_bigfloatgt($k, $$intervals[$splicepos + $splicelen][0]) or &_bigfloatlt($k, $$intervals[$splicepos + $splicelen][1])
&_bigfloatgt($k, $$intervals[$splicepos + $splicelen][0])
&_bigfloatlt($k, $$intervals[$splicepos + $splicelen][1])
Truth table33%1/3
A or B
A= &_bigfloatgt($k, $$intervals[$splicepos + $splicelen][0])B= &_bigfloatlt($k, $$intervals[$splicepos + $splicelen][1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | or _bigfloatlt($k,$intervals->[$splicepos+$splicelen][1])){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $DB::single=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | die "Panic: broken intervals:".Data::Dumper::Dumper($intervals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 25 | splice @$intervals, $splicepos, $splicelen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $DB::single=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | die "Panic: Could not find an interval position to insert '$epoch'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | =head2 reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | Forgets everything ever done and gives way for a new round of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | mirroring. Usually called when the dirtymark on upstream has changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $self->_intervals(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | =head1 PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =head2 _intervals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 233 | ▶ | sub _intervals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_intervals: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 233 | my($self,$set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 233 | ▶ | if (@_ >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->__intervals($set); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 233 | my $x = $self->__intervals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 233 | ▶ | unless (defined $x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 8 | $x = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 8 | $self->__intervals ($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 233 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | Copyright 2008, 2009 Andreas König. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 12 | 1; # End of File::Rsync::Mirror::Recentfile | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # Local Variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # mode: cperl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # End: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||