| 1 | package Data::Shared::Composite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 39 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 39 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 39 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 39 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 39 | ▶ | use Fcntl qw(:flock O_RDWR O_APPEND O_CREAT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 39 | ▶ | use Errno (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 39 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 39 | our @CARP_NOT = qw(Data::Shared Data::Shared::Manifest Data::Shared::Storage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | Data::Shared::Composite); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub CLONE_SKIP { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 39 | my %PARENT_OK = map { $_ => 1 } qw(hashmap sortedset kdtree graph); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 157 | ▶ | sub _refuse_unknown_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse_unknown_keys: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 157 | my ($hash, $what, @allowed) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 157 | my %ok = map { $_ => 1 } @allowed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 157 | my @bad = sort grep { !$ok{$_} } keys %$hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 157 | ▶ | return unless @bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | Carp::croak("Data::Shared: unknown composite $what" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | . (@bad == 1 ? " '$bad[0]'" : "s '" . join("', '", @bad) . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | . '; expected ' . join(', ', @allowed)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4857 | ▶ | sub parse_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_node: called CC=35 SCAR=40.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4857 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4857 | ▶ | if (!ref $node) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | Carp::croak("Data::Shared: composite spec must be a string, arrayref, or hashref") unless defined $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $resolved = Data::Shared::Registry::resolve_spec($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | Carp::croak("Data::Shared: unknown mount spec '$node'") unless $resolved; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return { spec => $node, resolved => $resolved, args => [], child => undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | max_children => 10_000, cache_size => 32 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4857 | ▶ | if (ref $node eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 92 | ▶ | my $spec = $node->{spec} // $node->{type} // $node->{class} // $node->{key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
(($node->{"spec"} // $node->{"type"}) // $node->{"class"}) // $node->{"key"}
($node->{"spec"} // $node->{"type"}) // $node->{"class"}
$node->{"spec"} // $node->{"type"}
MC/DC0%0/4
(($node->{"spec"} // $node->{"type"}) // $node->{"class"}) // $node->{"key"}
$node->{"spec"}
$node->{"type"}
$node->{"class"}
$node->{"key"}
Truth table20%1/5
A // B // C // D
A= $node->{"spec"}B= $node->{"type"}C= $node->{"class"}D= $node->{"key"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 92 | ▶ | Carp::croak("Data::Shared: composite hashref spec needs spec/type/class/key") unless defined $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 92 | _refuse_unknown_keys($node, 'spec key', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | qw(spec type class key args ctor child max_children cache_size)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 91 | my $resolved = Data::Shared::Registry::resolve_spec($spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 91 | ▶ | Carp::croak("Data::Shared: unknown mount spec '$spec'") unless $resolved; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | Carp::croak('Data::Shared: constructor args must be an ARRAY reference') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 91 | ▶ | if exists $node->{args} && ref $node->{args} ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $node->{"args"} and ref $node->{"args"} ne "ARRAY"
MC/DC0%0/2
exists $node->{"args"} and ref $node->{"args"} ne "ARRAY"
exists $node->{"args"}
ref $node->{"args"} ne "ARRAY"
Truth table33%1/3
A and B
A= exists $node->{"args"}B= ref $node->{"args"} ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Carp::croak('Data::Shared: invalid constructor name') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 91 | ▶ | if exists $node->{ctor} && (!defined $node->{ctor} || ref $node->{ctor} || $node->{ctor} !~ /\A[A-Za-z_]\w*\z/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
exists $node->{"ctor"} and !defined($node->{"ctor"}) || ref $node->{"ctor"} || !($node->{"ctor"} =~ /\A[A-Za-z_]\w*\z/)
not defined $node->{"ctor"} or ref $node->{"ctor"} or not $node->{"ctor"} =~ /\A[A-Za-z_]\w*\z/
not defined $node->{"ctor"} or ref $node->{"ctor"}
MC/DC0%0/4
exists $node->{"ctor"} and !defined($node->{"ctor"}) || ref $node->{"ctor"} || !($node->{"ctor"} =~ /\A[A-Za-z_]\w*\z/)
exists $node->{"ctor"}
not defined $node->{"ctor"}
ref $node->{"ctor"}
not $node->{"ctor"} =~ /\A[A-Za-z_]\w*\z/
Truth table40%2/5
A and not(B) or C or not(D)
A= exists $node->{"ctor"}B= not defined $node->{"ctor"}C= ref $node->{"ctor"}D= not $node->{"ctor"} =~ /\A[A-Za-z_]\w*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # ctor_named marks a caller override; the registry sets its own ctor for some families. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | $resolved = { %$resolved, ctor => $node->{ctor}, ctor_named => 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 91 | ▶ | if defined $node->{ctor}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | my $out = { spec => $spec, resolved => $resolved, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 91 | ▶ | args => $node->{args} ? [ @{ $node->{args} } ] : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$node->{"max_children"} // 10000
$node->{"cache_size"} // 32
MC/DC100%1/1
$node->{"max_children"} // 10000
$node->{"max_children"}
MC/DC100%1/1
$node->{"cache_size"} // 32
$node->{"cache_size"}
Truth table100%2/2
A
A= $node->{"max_children"}
Truth table100%2/2
A
A= $node->{"cache_size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | child => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | max_children => $node->{max_children} // 10_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 91 | ▶ | cache_size => $node->{cache_size} // 32 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 91 | ▶ | $out->{child} = parse_node($node->{child}) if defined $node->{child}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 91 | _validate_node($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 91 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4765 | ▶ | if (ref $node eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4765 | my @elems = @$node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4765 | ▶ | Carp::croak("Data::Shared: composite arrayref spec is empty") unless @elems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4765 | my $spec = shift @elems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4765 | ▶ | Carp::croak("Data::Shared: composite arrayref spec must start with a spec string") if ref $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4765 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4765 | ▶ | if (@elems >= 2 && ref $elems[-1] eq 'HASH' && ref $elems[-2] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@elems >= 2 and ref $elems[-1] eq "HASH" and ref $elems[-2] eq "ARRAY"
@elems >= 2 and ref $elems[-1] eq "HASH"
MC/DC100%3/3
@elems >= 2 and ref $elems[-1] eq "HASH" and ref $elems[-2] eq "ARRAY"
@elems >= 2
ref $elems[-1] eq "HASH"
ref $elems[-2] eq "ARRAY"
Truth table100%4/4
A and B and C
A= @elems >= 2B= ref $elems[-1] eq "HASH"C= ref $elems[-2] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # A trailing child array and options hash must not fall through to constructor args. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 65 | _refuse_unknown_keys($elems[-1], 'option', qw(max_children cache_size)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 63 | %opts = %{ pop @elems }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4763 | ▶ | if (@elems && ref $elems[-1] eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@elems and ref $elems[-1] eq "HASH" and grep {exists $elems[-1]{$_};} "spec", "type", "class", "key", "child"
@elems and ref $elems[-1] eq "HASH"
MC/DC66%2/3
@elems and ref $elems[-1] eq "HASH" and grep {exists $elems[-1]{$_};} "spec", "type", "class", "key", "child"
@elems
ref $elems[-1] eq "HASH"
grep {exists $elems[-1]{$_};} "spec", "type", "class", "key", "child"
Truth table75%3/4
A and B and C
A= @elemsB= ref $elems[-1] eq "HASH"C= grep {exists $elems[-1]{$_};} "spec", "type", "class", "key", "child"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 90 | && grep { exists $elems[-1]{$_} } qw(spec type class key child)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | Carp::croak('Data::Shared: a child spec in an arrayref composite spec must be' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | . ' an arrayref; a trailing hashref is read as a constructor argument'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4762 | my $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4762 | ▶ | if (@elems && ref $elems[-1] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@elems and ref $elems[-1] eq "ARRAY"
MC/DC50%1/2
@elems and ref $elems[-1] eq "ARRAY"
@elems
ref $elems[-1] eq "ARRAY"
Truth table66%2/3
A and B
A= @elemsB= ref $elems[-1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2388 | $child = parse_node(pop @elems); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4758 | my $resolved = Data::Shared::Registry::resolve_spec($spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4758 | ▶ | Carp::croak("Data::Shared: unknown mount spec '$spec'") unless $resolved; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | my $out = { spec => $spec, resolved => $resolved, args => \@elems, child => $child, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | max_children => $opts{max_children} // 10_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4756 | ▶ | cache_size => $opts{cache_size} // 32 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$opts{"max_children"} // 10000
$opts{"cache_size"} // 32
MC/DC100%1/1
$opts{"max_children"} // 10000
$opts{"max_children"}
MC/DC100%1/1
$opts{"cache_size"} // 32
$opts{"cache_size"}
Truth table100%2/2
A
A= $opts{"max_children"}
Truth table100%2/2
A
A= $opts{"cache_size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4756 | _validate_node($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4736 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | Carp::croak("Data::Shared: composite spec must be a string, arrayref, or hashref"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # A leading undef or ':file' is the file placeholder, not an argument; every reader of args must strip it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 15191 | ▶ | sub _strip_placeholder { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_placeholder: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 15191 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 15191 | my @a = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 15191 | ▶ | my $placeholder = sub { @a && (!defined $a[0] || (!ref $a[0] && $a[0] eq ':file'))}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 1 branch
Condition100%9/9
@a && (!defined($a[0]) || !ref($a[0]) && $a[0] eq ':file')
not defined $a[0] or not ref $a[0] and $a[0] eq ":file"
not ref $a[0] and $a[0] eq ":file"
MC/DC100%4/4
@a && (!defined($a[0]) || !ref($a[0]) && $a[0] eq ':file')
@a
not defined $a[0]
not ref $a[0]
$a[0] eq ":file"
Truth table100%5/5
A && not(B) or not(C) and D
A= @aB= not defined $a[0]C= not ref $a[0]D= $a[0] eq ":file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 15191 | ▶ | shift @a if $placeholder->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 15191 | ▶ | Carp::croak("Data::Shared: a spec names the backing-path placeholder" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | . " (undef or ':file') more than once; the facade supplies one file") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | if $placeholder->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 15188 | return \@a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12766 | ▶ | sub _constructor_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_constructor_args: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12766 | my ($resolved, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 12766 | my $a = _strip_placeholder($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 12766 | ▶ | return $a if $resolved->{convention} ne 'leading'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 12734 | return [undef, @$a]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5542 | ▶ | sub construct_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
construct_node: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 5542 | my ($dir, $readonly, $resolved, $name, $args, $mode) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 5542 | ▶ | return Data::Shared::_construct_with($dir, $readonly, $resolved, $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$mode || {}
MC/DC0%0/1
$mode || {}
$mode
Truth table50%1/2
A
A= $mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | _constructor_args($resolved, $args), $mode || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4803 | ▶ | sub _preflight { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_preflight: called CC=13 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4803 | my ($root, $node, $dir, $opening, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # Reopening loads only this level, so an untouched child's backend cannot block the store. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 4803 | ▶ | for (my $current = $node; $current; $current = $current->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9405 | Data::Shared::Storage::_load($current->{resolved}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 9403 | ▶ | last if $opening; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # plan touches no filesystem: a malformed child spec is refused before anything is published. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4801 | ▶ | unless ($opening) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4571 | ▶ | my $as_child = bless { dir => defined $dir ? "$dir/child-0" : undef }, 'Data::Shared'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4571 | ▶ | for (my $c = $node->{child}; $c; $c = $c->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Data::Shared::Storage::plan($as_child, $c->{resolved}, 'child', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4600 | _constructor_args($c->{resolved}, $c->{args})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4796 | ▶ | if ($root->{strict_readonly}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 11 | ▶ | for (my $current = $node; $current; $current = $current->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 22 | Data::Shared::Storage::check_readonly($current->{resolved}, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4795 | ▶ | return unless $opening; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 229 | ▶ | Carp::croak("Data::Shared: missing composite directory '" . ($dir // '') . "'") unless defined $dir && -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $dir and -d $dir
$dir // ""
MC/DC0%0/2
defined $dir and -d $dir
defined $dir
-d $dir
MC/DC0%0/1
$dir // ""
$dir
Truth table33%1/3
A and B
A= defined $dirB= -d $dir
Truth table0%0/2
A
A= $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 229 | my $context = bless { dir => $dir }, 'Data::Shared'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | my $parent = Data::Shared::Storage::plan($context, $node->{resolved}, 'parent', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 229 | _constructor_args($node->{resolved}, $node->{args})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 229 | my $index = Data::Shared::Storage::plan($context, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | _index_spec(), 'index', _index_args($node)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 229 | Data::Shared::Storage::require_files($_) for ($parent, $index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4847 | ▶ | sub _validate_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_node: called CC=10 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4847 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4847 | ▶ | return unless $node->{child}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2432 | my $entry = $node->{resolved}{entry}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2432 | ▶ | my $key = $entry ? $entry->{key} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | Carp::croak("Data::Shared: '" . (defined $key ? $key : $node->{spec}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | . "' cannot be a composite parent (only hashmap, sortedset, kdtree, and graph can); use it as a leaf or a sidecar") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2432 | ▶ | unless defined $key && $PARENT_OK{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $key and $PARENT_OK{$key}
MC/DC50%1/2
defined $key and $PARENT_OK{$key}
defined $key
$PARENT_OK{$key}
Truth table66%2/3
A and B
A= defined $keyB= $PARENT_OK{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2428 | for my $option (qw(max_children cache_size)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | Carp::croak("Data::Shared: composite $option must be an integer >= 1") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | unless defined $node->{$option} && !ref $node->{$option} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4853 | ▶ | && $node->{$option} =~ /\A[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $node->{$option} and not ref $node->{$option} and $node->{$option} =~ /\A[1-9][0-9]*\z/
defined $node->{$option} and not ref $node->{$option}
MC/DC33%1/3
defined $node->{$option} and not ref $node->{$option} and $node->{$option} =~ /\A[1-9][0-9]*\z/
defined $node->{$option}
not ref $node->{$option}
$node->{$option} =~ /\A[1-9][0-9]*\z/
Truth table50%2/4
A and not(B) and C
A= defined $node->{$option}B= not ref $node->{$option}C= $node->{$option} =~ /\A[1-9][0-9]*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2425 | _refuse_shared_child_path($node->{child}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2425 | ▶ | sub _refuse_shared_child_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse_shared_child_path: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2425 | my ($child) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2425 | ▶ | my $args = _strip_placeholder($child->{args} || []); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$child->{'args'} || []
MC/DC0%0/1
$child->{'args'} || []
$child->{'args'}
Truth table50%1/2
A
A= $child->{'args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2422 | my $resolved = $child->{resolved}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2422 | my @named; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2422 | my $convention = $resolved->{convention}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2422 | ▶ | if ($convention eq 'options') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 18 | ▶ | my %opt = @$args == 1 && ref $args->[0] eq 'HASH' ? %{ $args->[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@$args == 1 and ref $args->[0] eq "HASH"
MC/DC50%1/2
@$args == 1 and ref $args->[0] eq "HASH"
@$args == 1
ref $args->[0] eq "HASH"
Truth table66%2/3
A and B
A= @$args == 1B= ref $args->[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | : @$args % 2 ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | : @$args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 18 | @named = grep { defined $opt{$_} } qw(set keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | elsif ($convention eq 'handle') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | @named = 'path' if @$args == 1 && ref $args->[0] eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | ▶ | && defined $args->[0]{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$args == 1 and ref $args->[0] eq "HASH" and defined $args->[0]{"path"}
@$args == 1 and ref $args->[0] eq "HASH"
MC/DC100%3/3
@$args == 1 and ref $args->[0] eq "HASH" and defined $args->[0]{"path"}
@$args == 1
ref $args->[0] eq "HASH"
defined $args->[0]{"path"}
Truth table100%4/4
A and B and C
A= @$args == 1B= ref $args->[0] eq "HASH"C= defined $args->[0]{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | ▶ | @named = 'path' if @$args && defined $args->[0] && !ref $args->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$args and defined $args->[0] and not ref $args->[0]
@$args and defined $args->[0]
MC/DC66%2/3
@$args and defined $args->[0] and not ref $args->[0]
@$args
defined $args->[0]
not ref $args->[0]
Truth table75%3/4
A and B and not(C)
A= @$argsB= defined $args->[0]C= not ref $args->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2422 | ▶ | Carp::croak("Data::Shared: a composite child cannot name its own backing path (" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | . join(', ', @named) . "): one spec serves every child, so they would" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | . " share one file. Leave it out and the facade derives one per child") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | if @named; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2412 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2408 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2408 | my ($class, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2408 | ▶ | my $node = $o{node} or Carp::croak('Data::Shared: Composite requires a node'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2408 | ▶ | my $self = bless { node => $node, dir => $o{dir}, path => [ @{ $o{path} || [] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition50%1/2
$o{'path'} || []
MC/DC0%0/1
$o{'path'} || []
$o{'path'}
Truth table50%1/2
A
A= $o{'path'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | name => $o{name}, readonly => $o{readonly} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | _cleanup => $o{cleanup} ? 1 : 0, _frozen_ok => $o{frozen_ok} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2408 | strict_readonly => $o{strict_readonly} ? 1 : 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | cache => {}, lru_prev => {}, lru_next => {} }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2408 | $self->{root_weak} = $o{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2408 | ▶ | weaken($self->{root_weak}) if $self->{root_weak}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2408 | _preflight($self, $node, $self->{dir}, $o{opening}, $self->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2408 | ▶ | if (defined $self->{dir} && !$o{opening}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"dir"} and not $o{"opening"}
MC/DC100%2/2
defined $self->{"dir"} and not $o{"opening"}
defined $self->{"dir"}
not $o{"opening"}
Truth table100%3/3
A and not(B)
A= defined $self->{"dir"}B= not $o{"opening"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 199 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 199 | File::Path::make_path($self->{dir}, { mode => 0700 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2408 | ▶ | $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=25 SCAR=32.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # sealed_ok permits nested children to reopen after sealing; top-level mounts refuse it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | my %mode = (opening => $o{opening}, strict_readonly => $self->{strict_readonly}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | pending_paths => $o{pending_paths}, cleanup => $self->{_cleanup}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2408 | ▶ | frozen_ok => ($self->{_frozen_ok} || $o{sealed_ok}) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_frozen_ok"} or $o{"sealed_ok"}
MC/DC100%2/2
$self->{"_frozen_ok"} or $o{"sealed_ok"}
$self->{"_frozen_ok"}
$o{"sealed_ok"}
Truth table100%3/3
A or B
A= $self->{"_frozen_ok"}B= $o{"sealed_ok"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2408 | my ($parent) = construct_node($self->{dir}, $self->{readonly}, $node->{resolved}, 'parent', $node->{args}, \%mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2407 | $self->{parent_handle} = $parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2407 | $self->{parent_record} = { handle => $parent, entry => $node->{resolved}{entry}, dt => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | my ($index) = Data::Shared::_construct_with($self->{dir}, $self->{readonly}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2407 | _index_spec(), 'index', _index_args($node), \%mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2407 | $self->{index} = $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 317 | @{$self}{qw(_index_dev _index_ino)} = (stat _index_file($self))[0, 1] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2407 | ▶ | if defined $self->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2407 | ▶ | Carp::croak('Data::Shared: composite instance was deleted') if $index->get('x:') && !$self->{_cleanup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$index->get("x:") and not $self->{"_cleanup"}
MC/DC0%0/2
$index->get("x:") and not $self->{"_cleanup"}
$index->get("x:")
not $self->{"_cleanup"}
Truth table66%2/3
A and not(B)
A= $index->get("x:")B= not $self->{"_cleanup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # 's:' is the child count; 'p:' marks an interrupted mutation that requires a recount. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # _index_frozen, not frozen: only the index's own writability matters here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2407 | ▶ | if (!$self->{readonly} && !$self->{_cleanup} && !$self->_index_frozen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%12/12
not $self->{"readonly"} || $self->{"_cleanup"} || $self->_index_frozen and $index->get("p:") || !defined($index->get("s:"))
$self->{'readonly'} || $self->{'_cleanup'} || $self->_index_frozen
$self->{"readonly"} or $self->{"_cleanup"}
$index->get("p:") or not defined $index->get("s:")
MC/DC100%5/5
not $self->{"readonly"} || $self->{"_cleanup"} || $self->_index_frozen and $index->get("p:") || !defined($index->get("s:"))
$self->{"readonly"}
$self->{"_cleanup"}
$self->_index_frozen
$index->get("p:")
not defined $index->get("s:")
Truth table100%6/6
not(A or B || C) and D or not(E)
A= $self->{"readonly"}B= $self->{"_cleanup"}C= $self->_index_frozenD= $index->get("p:")E= not defined $index->get("s:")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | && ($index->get('p:') || !defined $index->get('s:'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2292 | $self->_index_put('s:', $self->_count_addresses); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2292 | $self->_index_remove('p:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2407 | my $chain = _chain_signature($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2407 | my $recorded = $index->get('k:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2407 | ▶ | if (defined $recorded && length $recorded) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $recorded and length $recorded
MC/DC50%1/2
defined $recorded and length $recorded
defined $recorded
length $recorded
Truth table66%2/3
A and B
A= defined $recordedB= length $recorded
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 118 | ▶ | Carp::croak("Data::Shared: composite '$self->{name}' storage was created for" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | . " [$recorded], not [$chain]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | if $recorded ne $chain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ▶ | elsif (!$self->{readonly} && !$self->{_cleanup} && !$self->_index_frozen) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$self->{'readonly'} || $self->{'_cleanup'} || $self->_index_frozen
$self->{"readonly"} or $self->{"_cleanup"}
MC/DC0%0/3
$self->{'readonly'} || $self->{'_cleanup'} || $self->_index_frozen
$self->{"readonly"}
$self->{"_cleanup"}
$self->_index_frozen
Truth table25%1/4
A or B || C
A= $self->{"readonly"}B= $self->{"_cleanup"}C= $self->_index_frozen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2289 | $self->_index_put('k:', $chain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # 'b:' records the creation budget; the index's growing slot table cannot reveal it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2406 | my $budget = $index->get('b:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2406 | ▶ | if (defined $budget && $budget =~ /\A[0-9]+\z/ && $budget < $node->{max_children}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
defined $budget and $budget =~ /\A[0-9]+\z/ and $budget < $node->{"max_children"}
defined $budget and $budget =~ /\A[0-9]+\z/
MC/DC66%2/3
defined $budget and $budget =~ /\A[0-9]+\z/ and $budget < $node->{"max_children"}
defined $budget
$budget =~ /\A[0-9]+\z/
$budget < $node->{"max_children"}
Truth table75%3/4
A and B and C
A= defined $budgetB= $budget =~ /\A[0-9]+\z/C= $budget < $node->{"max_children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # A replayed manifest may ask for more; it gets the stored budget instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | Carp::croak("Data::Shared: composite '$self->{name}' storage was created" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | . " for max_children=$budget and cannot serve" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | . " $node->{max_children}; the index is sized when it is created," | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | . " so raising the budget needs unmount(unlink => 1) first") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | unless $o{replaying}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | $self->{_budget} = $budget; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ▶ | elsif (!defined $budget && !$self->{readonly} && !$self->{_cleanup} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
defined $budget || $self->{'readonly'} || $self->{'_cleanup'} || $self->_index_frozen
defined $budget or $self->{"readonly"} or $self->{"_cleanup"}
defined $budget or $self->{"readonly"}
MC/DC25%1/4
defined $budget || $self->{'readonly'} || $self->{'_cleanup'} || $self->_index_frozen
defined $budget
$self->{"readonly"}
$self->{"_cleanup"}
$self->_index_frozen
Truth table40%2/5
A or B or C || D
A= defined $budgetB= $self->{"readonly"}C= $self->{"_cleanup"}D= $self->_index_frozen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | && !$self->_index_frozen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2289 | $self->_index_put('b:', $node->{max_children}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2408 | ▶ | }, undef, $o{opening} ? 1 : 0); # reopening tolerates an unwritable lock; creating does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2405 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2662 | ▶ | sub _index_file { my ($self) = @_; return "$self->{dir}/index.shm" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # Best-effort: a missing or unreadable lock file must not block a shipped store. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 164 | ▶ | sub _with_shared_lock { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_with_shared_lock: called CC=8 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 164 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 164 | ▶ | my $lockfile = defined $self->{dir} ? "$self->{dir}/.lock" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 164 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 164 | ▶ | if (defined $lockfile && -e $lockfile && CORE::open($fh, '<', $lockfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $lockfile and -e $lockfile and open $fh, "<", $lockfile
defined $lockfile and -e $lockfile
MC/DC0%0/3
defined $lockfile and -e $lockfile and open $fh, "<", $lockfile
defined $lockfile
-e $lockfile
open $fh, "<", $lockfile
Truth table25%1/4
A and B and C
A= defined $lockfileB= -e $lockfileC= open $fh, "<", $lockfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 164 | ▶ | until (flock $fh, LOCK_SH) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | last unless $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # Recheck identity after waiting; teardown may have replaced the instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 164 | ▶ | $self->_assert_live_instance if $self->{index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 163 | local $self->{_locked} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 163 | return $code->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # Index identity distinguishes incarnations even when frozen mappings cannot record deletion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # Teardown may meet its own absent index, but must never remove a replacement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 39 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 39 | _INDEX_SAME => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | _INDEX_ABSENT => 1, # our own teardown, finished or interrupted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | _INDEX_REPLACED => 2, # a different incarnation of the store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 39 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 6627 | ▶ | sub _index_replaced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_replaced: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 6627 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 6627 | ▶ | return _INDEX_SAME unless defined $self->{dir} && defined $self->{_index_ino}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"dir"} and defined $self->{"_index_ino"}
MC/DC50%1/2
defined $self->{"dir"} and defined $self->{"_index_ino"}
defined $self->{"dir"}
defined $self->{"_index_ino"}
Truth table66%2/3
A and B
A= defined $self->{"dir"}B= defined $self->{"_index_ino"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2345 | my ($dev, $ino) = (stat _index_file($self))[0, 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2345 | ▶ | return _INDEX_ABSENT unless defined $ino; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | return ($dev == $self->{_index_dev} && $ino == $self->{_index_ino}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 2344 | ▶ | ? _INDEX_SAME : _INDEX_REPLACED; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dev == $self->{"_index_dev"} and $ino == $self->{"_index_ino"}
MC/DC50%1/2
$dev == $self->{"_index_dev"} and $ino == $self->{"_index_ino"}
$dev == $self->{"_index_dev"}
$ino == $self->{"_index_ino"}
Truth table66%2/3
A and B
A= $dev == $self->{"_index_dev"}B= $ino == $self->{"_index_ino"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6627 | ▶ | sub _assert_live_instance { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_live_instance: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 6627 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6627 | my $state = $self->_index_replaced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6627 | ▶ | Carp::croak('Data::Shared: composite storage belongs to a newer instance') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | if $state == _INDEX_REPLACED; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6622 | ▶ | return if $self->{_cleanup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | Carp::croak('Data::Shared: composite instance was deleted') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 6582 | ▶ | if $self->{index}->get('x:') || $state == _INDEX_ABSENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"index"}->get("x:") or $state == 1
MC/DC50%1/2
$self->{"index"}->get("x:") or $state == 1
$self->{"index"}->get("x:")
$state == 1
Truth table66%2/3
A or B
A= $self->{"index"}->get("x:")B= $state == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 6581 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2407 | ▶ | sub _chain_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chain_signature: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2407 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2407 | my @levels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 2407 | ▶ | for (my $level = $node; $level; $level = $level->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 4831 | ▶ | push @levels, $level->{resolved}{class} . '->' . ($level->{resolved}{ctor} || 'new'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$level->{'resolved'}{'ctor'} || 'new'
MC/DC0%0/1
$level->{'resolved'}{'ctor'} || 'new'
$level->{'resolved'}{'ctor'}
Truth table50%1/2
A
A= $level->{'resolved'}{'ctor'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2407 | return join ' ', @levels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 5676 | ▶ | sub _root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_root: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 5676 | my ($self, $root) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 5676 | ▶ | return $root if $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $r = $self->{root_weak}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | Carp::croak("Data::Shared: root has gone away") unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # The resolved spec is fixed for this instance's lifetime. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 11607 | ▶ | sub _key_is_int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_is_int: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 11607 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 11607 | ▶ | return $self->{_key_is_int} //= _key_is_int_for($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_key_is_int"} //= _key_is_int_for($self)
MC/DC0%0/2
$self->{"_key_is_int"} //= _key_is_int_for($self)
$self->{"_key_is_int"}
_key_is_int_for($self)
Truth table66%2/3
A //= B
A= $self->{"_key_is_int"}B= _key_is_int_for($self)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 198 | ▶ | sub _key_int_bits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_int_bits: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 198 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 198 | ▶ | return $self->{_key_int_bits} //= _key_int_bits_for($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_key_int_bits"} //= _key_int_bits_for($self)
MC/DC0%0/2
$self->{"_key_int_bits"} //= _key_int_bits_for($self)
$self->{"_key_int_bits"}
_key_int_bits_for($self)
Truth table66%2/3
A //= B
A= $self->{"_key_int_bits"}B= _key_int_bits_for($self)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2377 | ▶ | sub _key_probe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_probe: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2377 | my ($resolved) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2377 | ▶ | return lc $resolved->{variant} if defined $resolved->{variant}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | ▶ | return $resolved->{class} =~ /::(\w+)\z/ ? lc $1 : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 2380 | ▶ | sub _key_is_int_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_is_int_for: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2380 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 2380 | my $resolved = $self->{node}{resolved}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # kdtree and graph address children by integer id without an int variant. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 2380 | ▶ | return 1 if $self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2372 | ▶ | return 0 if $resolved->{class} eq 'Data::SortedSet::Shared::Strings'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2367 | ▶ | return 1 if $resolved->{entry} && ($resolved->{entry}{key} || '') eq 'sortedset'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$resolved->{"entry"} and ($resolved->{"entry"}{"key"} || "") eq "sortedset"
$resolved->{'entry'}{'key'} || ''
MC/DC0%0/2
$resolved->{"entry"} and ($resolved->{"entry"}{"key"} || "") eq "sortedset"
$resolved->{"entry"}
$resolved->{'entry'}{'key'}
Truth table33%1/3
A and B
A= $resolved->{"entry"}B= $resolved->{'entry'}{'key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2362 | ▶ | return _key_probe($resolved) =~ /\A(?:i16|i32|ii|is)/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 11404 | ▶ | sub _valid_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_address: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 11404 | my ($self, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 11404 | ▶ | return 0 unless defined $addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 11404 | ▶ | return 1 unless $self->_key_is_int; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # One canonical spelling per key, and \z not $: the index keys on the string and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # parent on its numeric value, so "7\n" would register a second child over one slot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 217 | my ($neg, $mag) = $addr =~ /\A(-?)(0|[1-9][0-9]*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 217 | ▶ | return 0 if !defined $mag || ($neg && $mag eq '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not defined $mag or $neg and $mag eq 0
$neg and $mag eq 0
MC/DC100%3/3
not defined $mag or $neg and $mag eq 0
not defined $mag
$neg
$mag eq 0
Truth table100%4/4
not(A) or B and C
A= not defined $magB= $negC= $mag eq 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # Overflow is refused for composite parents only; plain leaves keep backend wrapping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 198 | ▶ | if (my $bits = $self->_key_int_bits) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 128 | ▶ | my $limit = $bits == 64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ? ($neg ? '9223372036854775808' : '9223372036854775807') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | : (1 << ($bits - 1)) - ($neg ? 0 : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Compare decimal strings to avoid rounding 64-bit bounds through a double. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 128 | ▶ | return 0 if length($mag) > length($limit) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
length $mag > length $limit or length $mag == length $limit and $mag gt $limit
length $mag == length $limit and $mag gt $limit
MC/DC100%3/3
length $mag > length $limit or length $mag == length $limit and $mag gt $limit
length $mag > length $limit
length $mag == length $limit
$mag gt $limit
Truth table100%4/4
A or B and C
A= length $mag > length $limitB= length $mag == length $limitC= $mag gt $limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | || (length($mag) == length($limit) && $mag gt $limit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 184 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 23 | ▶ | sub _key_int_bits_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_int_bits_for: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # Id parents have no mirror slot whose fixed-width key could collide. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 23 | ▶ | return 0 if $self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 15 | my $probe = _key_probe($self->{node}{resolved}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 15 | ▶ | return 16 if $probe =~ /\Ai16/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 13 | ▶ | return 32 if $probe =~ /\Ai32/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Other integer-keyed parents wrap at IV width. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 11 | ▶ | return $self->_key_is_int ? 64 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5736 | ▶ | sub _with_lock { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_with_lock: called CC=24 SCAR=32.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 5736 | my ($self, $code, $mutating, $read_only) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Check identity before every shortcut, including re-entry and read-only access. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 5736 | ▶ | $self->_assert_live_instance if $self->{index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5731 | ▶ | return $code->() if $self->{_locked}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Hold a shared lock through child opens so teardown cannot replace their storage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 5707 | ▶ | return $self->_with_shared_lock($code) if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 5543 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 5543 | ▶ | if (defined $self->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1312 | my $lockfile = "$self->{dir}/.lock"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1312 | ▶ | Carp::croak("Data::Shared: missing composite directory '$self->{dir}'") unless -d $self->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # $read_only, not !$mutating: freeze and destroy are destructive yet pass no $mutating. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1312 | ▶ | unless (sysopen $fh, $lockfile, O_RDWR | O_APPEND | O_CREAT, 0600) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | my $err = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | ▶ | unless ($read_only && -e $lockfile && CORE::open $fh, '<', $lockfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$read_only and -e $lockfile and open $fh, "<", $lockfile
$read_only and -e $lockfile
MC/DC0%0/3
$read_only and -e $lockfile and open $fh, "<", $lockfile
$read_only
-e $lockfile
open $fh, "<", $lockfile
Truth table25%1/4
A and B and C
A= $read_onlyB= -e $lockfileC= open $fh, "<", $lockfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $! = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | Carp::croak("Data::Shared: cannot open composite lock '$lockfile': $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1312 | ▶ | until (flock $fh, LOCK_EX) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | Carp::croak("Data::Shared: cannot lock composite: $!") unless $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 4231 | ▶ | unless ($self->{lock_handle}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # RWLock recovers a lock whose owner died. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2090 | Data::Shared::_require_class('Data::Sync::Shared::RWLock', 'Data-Sync-Shared'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2090 | $self->{lock_handle} = Data::Sync::Shared::RWLock->new(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 4231 | $self->{lock_handle}->wrlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 5543 | local $self->{_locked} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5543 | my $want = wantarray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 5543 | my (@ret, $ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 5543 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 5543 | ▶ | if ($self->{index}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 3219 | $self->_assert_live_instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # A sealed index cannot be repaired. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3219 | ▶ | if ($self->{index}->get('p:') && !$self->_index_frozen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"index"}->get("p:") and not $self->_index_frozen
MC/DC100%2/2
$self->{"index"}->get("p:") and not $self->_index_frozen
$self->{"index"}->get("p:")
not $self->_index_frozen
Truth table100%3/3
A and not(B)
A= $self->{"index"}->get("p:")B= not $self->_index_frozen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | $self->_index_put('s:', $self->_count_addresses); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | $self->_index_remove('p:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 3219 | ▶ | $self->_index_put('p:', 1) if $mutating; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 5543 | ▶ | if ($want) { @ret = $code->() } elsif (defined $want) { $ret = $code->() } else { $code->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5525 | ▶ | $self->_index_remove('p:') if $mutating && $self->{index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$mutating and $self->{"index"}
MC/DC50%1/2
$mutating and $self->{"index"}
$mutating
$self->{"index"}
Truth table66%2/3
A and B
A= $mutatingB= $self->{"index"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 5525 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5543 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 5543 | ▶ | if ($fh) { close $fh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 4231 | else { $self->{lock_handle}->wrunlock } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5543 | ▶ | die $err unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 5525 | ▶ | return $want ? @ret : $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # Each index key needs next_pow2(2 + address length) bytes: the backend's 128-byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # default covers 126-byte addresses, 272 covers 254. The mapping is sparse. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 39 | my $INDEX_ARENA_PER_ENTRY = 272; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 39 | my $INDEX_ARENA_MAX = 0xFFFFFFFF; # the backend's 32-bit size limit | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # No freeze: sealing a composite index would prevent retiring it (freeze_all seals subtrees). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 39 | my %LIFECYCLE_METHOD = map { $_ => 1 } qw(stats sync unlink destroy frozen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # Backends may reject a second freeze. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 344 | ▶ | sub _freeze_once { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_freeze_once: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 344 | my ($handle) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 344 | ▶ | return 0 unless $handle && $handle->can('freeze'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$handle and $handle->can("freeze")
MC/DC0%0/2
$handle and $handle->can("freeze")
$handle
$handle->can("freeze")
Truth table33%1/3
A and B
A= $handleB= $handle->can("freeze")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 344 | ▶ | return 0 if $handle->can('frozen') && $handle->frozen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$handle->can("frozen") and $handle->frozen
MC/DC50%1/2
$handle->can("frozen") and $handle->frozen
$handle->can("frozen")
$handle->frozen
Truth table66%2/3
A and B
A= $handle->can("frozen")B= $handle->frozen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 342 | $handle->freeze; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 342 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # Shared by every composite: nothing may write to it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 39 | my $INDEX_SPEC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2642 | ▶ | sub _index_spec { return $INDEX_SPEC ||= Data::Shared::Registry::resolve_spec('hashmap:ss') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_spec: called CC=2 SCAR=7.2
Condition66%2/3
$INDEX_SPEC ||= Data::Shared::Registry::resolve_spec("hashmap:ss")
MC/DC0%0/2
$INDEX_SPEC ||= Data::Shared::Registry::resolve_spec("hashmap:ss")
$INDEX_SPEC
Data::Shared::Registry::resolve_spec("hashmap:ss")
Truth table66%2/3
A ||= B
A= $INDEX_SPECB= Data::Shared::Registry::resolve_spec("hashmap:ss")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2636 | ▶ | sub _index_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_args: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2636 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2636 | my $entries = 2 * $node->{max_children} + 16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2636 | my $arena = $entries * $INDEX_ARENA_PER_ENTRY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2636 | ▶ | $arena = $INDEX_ARENA_MAX if $arena > $INDEX_ARENA_MAX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2636 | return [undef, $entries, 0, 0, 0, $arena]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 20709 | ▶ | sub _index_put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_put: called CC=7 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 20709 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 20709 | ▶ | return 1 if $self->{index}->put($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | ▶ | my $s = ($self->{index}->can('stats') ? $self->{index}->stats : undef) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
($self->{'index'}->can('stats') ? $self->{'index'}->stats : undef) || {}
MC/DC0%0/1
($self->{'index'}->can('stats') ? $self->{'index'}->stats : undef) || {}
($self->{'index'}->can('stats') ? $self->{'index'}->stats : undef)
Truth table50%1/2
A
A= ($self->{'index'}->can('stats') ? $self->{'index'}->stats : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # HashMap put exhausts capacity, not the smaller max_entries load-factor limit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 1 | ▶ | my $shown = length($key) > 72 ? substr($key, 0, 69) . '...' : $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | Carp::croak(sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | "Data::Shared: composite registry is full, cannot write '%s'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | . " (entries %s/%s, string arena %s/%s bytes, max_children=%s)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 5 | ▶ | $shown, map { defined $_ ? $_ : '?' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$s->{"capacity"} // $s->{"max_entries"}
MC/DC0%0/2
$s->{"capacity"} // $s->{"max_entries"}
$s->{"capacity"}
$s->{"max_entries"}
Truth table33%1/3
A // B
A= $s->{"capacity"}B= $s->{"max_entries"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | $s->{size}, $s->{capacity} // $s->{max_entries}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | $s->{arena_used}, $s->{arena_cap}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | $self->{node}{max_children}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 5150 | ▶ | sub _index_remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_remove: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 5150 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 5150 | $self->{index}->remove($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 5150 | ▶ | Carp::croak("Data::Shared: cannot remove composite registry '$key'") if $self->{index}->exists($key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 11710 | ▶ | sub _reg_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reg_id: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 11710 | my ($self, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 11710 | return $self->{index}->get('a:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3344 | ▶ | sub _reg_constructed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reg_constructed: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3344 | my ($self, $addr, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3344 | my $value = $self->{index}->get('c:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 3344 | ▶ | return 0 unless defined $value && length $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and length $value
MC/DC50%1/2
defined $value and length $value
defined $value
length $value
Truth table66%2/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # Legacy marker spelling, still read; t/17 covers it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 3332 | ▶ | return 1 if $value eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 3330 | ▶ | $id = $self->_reg_id($addr) unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3330 | ▶ | return defined $id && $value eq "id:$id" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $id and $value eq "id:$id"
MC/DC50%1/2
defined $id and $value eq "id:$id"
defined $id
$value eq "id:$id"
Truth table66%2/3
A and B
A= defined $idB= $value eq "id:$id"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 2297 | ▶ | sub _count_addresses { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_count_addresses: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2297 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 2297 | my @keys = $self->{index}->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 2297 | return scalar grep { substr($_, 0, 2) eq 'a:' } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 5574 | ▶ | sub _child_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_child_count: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 5574 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 5574 | ▶ | if (!$self->{_locked} && $self->{index}->get('p:')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->{"_locked"} and $self->{"index"}->get("p:")
MC/DC100%2/2
not $self->{"_locked"} and $self->{"index"}->get("p:")
not $self->{"_locked"}
$self->{"index"}->get("p:")
Truth table100%3/3
not(A) and B
A= not $self->{"_locked"}B= $self->{"index"}->get("p:")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 5 | ▶ | return $self->_count_addresses if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 5 | ▶ | return $self->_with_lock(sub { $self->{index}->get('s:') }, undef, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 5569 | my $count = $self->{index}->get('s:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 5569 | ▶ | return defined $count ? $count : $self->_count_addresses; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2757 | ▶ | sub _allocate_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_allocate_id: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2757 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 2757 | ▶ | my $limit = $self->{_budget} // $self->{node}{max_children}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_budget"} // $self->{"node"}{"max_children"}
MC/DC0%0/2
$self->{"_budget"} // $self->{"node"}{"max_children"}
$self->{"_budget"}
$self->{"node"}{"max_children"}
Truth table66%2/3
A // B
A= $self->{"_budget"}B= $self->{"node"}{"max_children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 2757 | ▶ | Carp::croak("Data::Shared: composite child limit exceeded (max_children=$limit) at $self->{name}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | if $self->_child_count >= $limit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2751 | ▶ | my $id = $self->{index}->get('n:') // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"index"}->get("n:") // 0
MC/DC100%1/1
$self->{"index"}->get("n:") // 0
$self->{"index"}->get("n:")
Truth table100%2/2
A
A= $self->{"index"}->get("n:")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2751 | ▶ | Carp::croak('Data::Shared: invalid composite child sequence') unless $id =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2751 | $self->_index_put('n:', $id + 1); # Child ids are never rolled back or reused. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2751 | return $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 10815 | ▶ | sub _is_index_parent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_index_parent: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 10815 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 10815 | ▶ | my $key = $self->{node}{resolved}{entry}{key} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
MC/DC0%0/1
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
$self->{'node'}{'resolved'}{'entry'}{'key'}
Truth table50%1/2
A
A= $self->{'node'}{'resolved'}{'entry'}{'key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 10815 | ▶ | return ($key eq 'kdtree' || $key eq 'graph') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "kdtree" or $key eq "graph"
MC/DC100%2/2
$key eq "kdtree" or $key eq "graph"
$key eq "kdtree"
$key eq "graph"
Truth table100%3/3
A or B
A= $key eq "kdtree"B= $key eq "graph"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 5612 | ▶ | sub _parent_exists { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent_exists: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 5612 | my ($self, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 5612 | ▶ | return defined $self->_reg_id($addr) ? 1 : 0 if $self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 5590 | my $r = Data::Shared::_dispatch_record('exists', $self->{parent_record}, [$addr]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 5590 | ▶ | return $r ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2753 | ▶ | sub _parent_register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent_register: called CC=15 SCAR=31.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2753 | my ($self, $addr, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 2753 | ▶ | return if $self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 2731 | ▶ | my $key = $self->{node}{resolved}{entry}{key} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
MC/DC0%0/1
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
$self->{'node'}{'resolved'}{'entry'}{'key'}
Truth table50%1/2
A
A= $self->{'node'}{'resolved'}{'entry'}{'key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2731 | ▶ | if ($key eq 'sortedset') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 22 | ▶ | if (!$self->_parent_exists($addr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 18 | Data::Shared::_dispatch_record('set', $self->{parent_record}, [$addr], 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 2709 | Data::Shared::_dispatch_record('set', $self->{parent_record}, [$addr], $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 2731 | ▶ | return if $self->_parent_exists($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | ▶ | my $s = ($self->{parent_handle}->can('stats') ? $self->{parent_handle}->stats : undef) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
($self->{'parent_handle'}->can('stats') ? $self->{'parent_handle'}->stats : undef) || {}
MC/DC0%0/1
($self->{'parent_handle'}->can('stats') ? $self->{'parent_handle'}->stats : undef) || {}
($self->{'parent_handle'}->can('stats') ? $self->{'parent_handle'}->stats : undef)
Truth table50%1/2
A
A= ($self->{'parent_handle'}->can('stats') ? $self->{'parent_handle'}->stats : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # SortedSet::Strings reports member capacity under "set". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | ▶ | $s = $s->{set} if ref $s->{set} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 1 | ▶ | my $size = $s->{size} // $s->{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$s->{"size"} // $s->{"count"}
MC/DC0%0/2
$s->{"size"} // $s->{"count"}
$s->{"size"}
$s->{"count"}
Truth table33%1/3
A // B
A= $s->{"size"}B= $s->{"count"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | ▶ | my $cap = $s->{capacity} // $s->{max_entries} // $s->{max}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($s->{"capacity"} // $s->{"max_entries"}) // $s->{"max"}
$s->{"capacity"} // $s->{"max_entries"}
MC/DC0%0/3
($s->{"capacity"} // $s->{"max_entries"}) // $s->{"max"}
$s->{"capacity"}
$s->{"max_entries"}
$s->{"max"}
Truth table25%1/4
A // B // C
A= $s->{"capacity"}B= $s->{"max_entries"}C= $s->{"max"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | Carp::croak(sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | "Data::Shared: cannot register child '%s' in the %s parent of '%s'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | . " (parent holds %s of %s; every child is an entry in it, so its own" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | . " capacity bounds max_children=%s)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | $addr, $key || ref $self->{parent_handle}, $self->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 3 | ▶ | map { defined $_ ? $_ : '?' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_budget"} // $self->{"node"}{"max_children"}
MC/DC0%0/2
$self->{"_budget"} // $self->{"node"}{"max_children"}
$self->{"_budget"}
$self->{"node"}{"max_children"}
Truth table33%1/3
A // B
A= $self->{"_budget"}B= $self->{"node"}{"max_children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | ▶ | $size, $cap, $self->{_budget} // $self->{node}{max_children}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key || ref $self->{'parent_handle'}
MC/DC0%0/2
$key || ref $self->{'parent_handle'}
$key
ref $self->{'parent_handle'}
Truth table33%1/3
A || B
A= $keyB= ref $self->{'parent_handle'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 21 | ▶ | sub _parent_unregister { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent_unregister: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 21 | my ($self, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 21 | ▶ | return if $self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 21 | ▶ | if ($self->_parent_exists($addr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 18 | Data::Shared::_dispatch_record('delete', $self->{parent_record}, [$addr]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 18 | ▶ | Carp::croak('Data::Shared: cannot unregister child in parent backend') if $self->_parent_exists($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1533 | ▶ | sub _untouch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_untouch: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1533 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1533 | ▶ | return unless exists $self->{lru_prev}{$id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 512 | my $prev = delete $self->{lru_prev}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 512 | my $next = delete $self->{lru_next}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 512 | ▶ | if (defined $prev) { $self->{lru_next}{$prev} = $next } else { $self->{lru_head} = $next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 512 | ▶ | if (defined $next) { $self->{lru_prev}{$next} = $prev } else { $self->{lru_tail} = $prev } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 5435 | ▶ | sub _touch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_touch: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 5435 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 5435 | ▶ | return unless defined $self->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1059 | ▶ | return if defined $self->{lru_tail} && $self->{lru_tail} == $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"lru_tail"} and $self->{"lru_tail"} == $id
MC/DC100%2/2
defined $self->{"lru_tail"} and $self->{"lru_tail"} == $id
defined $self->{"lru_tail"}
$self->{"lru_tail"} == $id
Truth table100%3/3
A and B
A= defined $self->{"lru_tail"}B= $self->{"lru_tail"} == $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1000 | $self->_untouch($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1000 | my $tail = $self->{lru_tail}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1000 | $self->{lru_prev}{$id} = $tail; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1000 | $self->{lru_next}{$id} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1000 | ▶ | if (defined $tail) { $self->{lru_next}{$tail} = $id } else { $self->{lru_head} = $id } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 1000 | $self->{lru_tail} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 533 | ▶ | sub _forget { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_forget: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 533 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 533 | $self->_untouch($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 533 | return delete $self->{cache}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 3112 | ▶ | sub _evict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_evict: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 3112 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 3112 | ▶ | return unless defined $self->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 995 | ▶ | while (keys(%{ $self->{cache} }) > $self->{node}{cache_size}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 496 | $self->_forget($self->{lru_head}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 3163 | ▶ | sub _open_child { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_open_child: called CC=19 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 3163 | my ($self, $root, $addr, $id, $opening, $pending, $cleanup) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 3163 | ▶ | if (my $rt = $self->{cache}{$id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | $self->_touch($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | return $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 3161 | my $node = $self->{node}{child}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 3161 | ▶ | my $dir = defined $self->{dir} ? "$self->{dir}/child-$id" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 3161 | ▶ | Carp::croak("Data::Shared: child '" . join('/', '', @{ $self->{path} }, $addr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opening and not defined $dir
MC/DC100%2/2
$opening and not defined $dir
$opening
not defined $dir
Truth table100%3/3
A and not(B)
A= $openingB= not defined $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | . "' exists in the shared index but belongs to another process; an anonymous" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | . " root has no backing file to reopen it (mount a file-backed root)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | if $opening && !defined $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 3160 | ▶ | if (defined $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 1043 | ▶ | Carp::croak("Data::Shared: missing composite child directory '$dir'") if $opening && !-d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opening and not -d $dir
MC/DC100%2/2
$opening and not -d $dir
$opening
not -d $dir
Truth table100%3/3
A and not(B)
A= $openingB= not -d $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1042 | ▶ | Carp::croak("Data::Shared: unpublished child storage exists at '$dir'; inspect it before retrying") if !$opening && -e $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $opening and -e $dir
MC/DC100%2/2
not $opening and -e $dir
not $opening
-e $dir
Truth table100%3/3
not(A) and B
A= not $openingB= -e $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 1041 | ▶ | if (!$opening) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 631 | ▶ | push @$pending, $dir if $pending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 631 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 631 | File::Path::make_path($dir, { mode => 0700 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # Existing children may be sealed even on a writable root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | my %mode = (opening => $opening, strict_readonly => $self->{strict_readonly}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | pending_paths => $pending, cleanup => $cleanup, frozen_ok => $self->{_frozen_ok}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 3158 | ▶ | replaying => $opening ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | sealed_ok => $opening ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 3158 | my $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 3158 | ▶ | if ($node->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | my $comp = Data::Shared::Composite->new(root => $root, name => $addr, node => $node, dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 24 | path => [ @{ $self->{path} }, $addr ], readonly => $self->{readonly}, %mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 24 | $rt = { kind => 'composite', comp => $comp, addr => $addr }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | my ($handle) = construct_node($dir, $self->{readonly}, $node->{resolved}, 'child', $node->{args}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 3134 | ▶ | { %mode, frozen_ok => $mode{frozen_ok} || $mode{sealed_ok} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$mode{'frozen_ok'} || $mode{'sealed_ok'}
MC/DC100%2/2
$mode{'frozen_ok'} || $mode{'sealed_ok'}
$mode{'frozen_ok'}
$mode{'sealed_ok'}
Truth table100%3/3
A || B
A= $mode{'frozen_ok'}B= $mode{'sealed_ok'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | my $record = { name => $addr, handle => $handle, entry => $node->{resolved}{entry} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 3131 | ▶ | || { key => $node->{resolved}{class}, dist => 'unknown', path_class => 'map' }, dt => {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->{'resolved'}{'entry'} || {'key', $node->{'resolved'}{'class'}, 'dist', 'unknown', 'path_class', 'map'}
MC/DC0%0/1
$node->{'resolved'}{'entry'} || {'key', $node->{'resolved'}{'class'}, 'dist', 'unknown', 'path_class', 'map'}
$node->{'resolved'}{'entry'}
Truth table50%1/2
A
A= $node->{'resolved'}{'entry'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 3131 | $rt = { kind => 'leaf', record => $record, handle => $handle, addr => $addr }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # Walks and removal opens must not evict the caller's cached handles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 3155 | ▶ | return $rt if $cleanup || $self->{_walking}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cleanup or $self->{"_walking"}
MC/DC100%2/2
$cleanup or $self->{"_walking"}
$cleanup
$self->{"_walking"}
Truth table100%3/3
A or B
A= $cleanupB= $self->{"_walking"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 3112 | $self->{cache}{$id} = $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 3112 | $self->_touch($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 3112 | $self->_evict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 3112 | return $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 8452 | ▶ | sub _existing_child { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_existing_child: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 8452 | my ($self, $root, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 8452 | ▶ | return undef unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 8450 | my $id = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 8450 | ▶ | return undef unless defined $id && $self->_reg_constructed($addr, $id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $id and $self->_reg_constructed($addr, $id)
MC/DC100%2/2
defined $id and $self->_reg_constructed($addr, $id)
defined $id
$self->_reg_constructed($addr, $id)
Truth table100%3/3
A and B
A= defined $idB= $self->_reg_constructed($addr, $id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2915 | ▶ | if (my $rt = $self->{cache}{$id}) { $self->_touch($id) unless $self->{_walking}; return $rt } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 409 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 409 | my $current = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 409 | ▶ | return undef unless defined $current && $self->_reg_constructed($addr, $current); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $current and $self->_reg_constructed($addr, $current)
MC/DC0%0/2
defined $current and $self->_reg_constructed($addr, $current)
defined $current
$self->_reg_constructed($addr, $current)
Truth table33%1/3
A and B
A= defined $currentB= $self->_reg_constructed($addr, $current)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 409 | return $self->_open_child($root, $addr, $current, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 415 | }, undef, 1); # opens an existing child, writes nothing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2875 | ▶ | sub _ensure_child { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure_child: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2875 | my ($self, $root, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2875 | ▶ | Carp::croak('Data::Shared: composite is read-only, cannot create a child') if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 2875 | ▶ | Carp::croak("Data::Shared: invalid composite address '" . (defined $addr ? $addr : 'undef') . "' for $self->{node}{spec}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2846 | my $existing = $self->_existing_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 2845 | ▶ | return $existing if $existing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 2755 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=27.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 2755 | my $current = $self->_existing_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 2755 | ▶ | return $current if $current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2755 | my $old_id = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 2755 | my $old_marker = $self->{index}->get('c:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 2755 | my $was_parent = $self->_parent_exists($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | my $old_value = $was_parent && !$self->_is_index_parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2755 | ▶ | ? Data::Shared::_dispatch_record('get', $self->{parent_record}, [$addr]) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$was_parent and not $self->_is_index_parent
MC/DC50%1/2
$was_parent and not $self->_is_index_parent
$was_parent
not $self->_is_index_parent
Truth table66%2/3
A and not(B)
A= $was_parentB= not $self->_is_index_parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 2755 | my $count = $self->_child_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 2755 | ▶ | my $id = defined $old_id ? $old_id : $self->_allocate_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 2749 | my @pending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | my $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 2749 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 2749 | $rt = $self->_open_child($root, $addr, $id, 0, \@pending); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 2746 | $self->_index_put('c:' . $addr, "id:$id"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 2745 | $self->_parent_register($addr, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 2744 | ▶ | $self->_index_put('s:', $count + 1) unless defined $old_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 2744 | ▶ | $self->_index_put('a:' . $addr, $id) unless defined $old_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 2744 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 2749 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 2749 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 5 | $self->_forget($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 5 | undef $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 5 | my $clean = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 5 | ▶ | defined $old_marker ? $self->_index_put('c:' . $addr, $old_marker) : $self->_index_remove('c:' . $addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 5 | ▶ | $self->_index_remove('a:' . $addr) unless defined $old_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 5 | ▶ | $self->_parent_unregister($addr) unless $was_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 5 | ▶ | Data::Shared::_dispatch_record('set', $self->{parent_record}, [$addr], $old_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$was_parent and not $self->_is_index_parent
MC/DC50%1/2
$was_parent and not $self->_is_index_parent
$was_parent
not $self->_is_index_parent
Truth table66%2/3
A and not(B)
A= $was_parentB= not $self->_is_index_parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | if $was_parent && !$self->_is_index_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 5 | $self->_index_put('s:', $count); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 5 | ▶ | my $rollback = $clean ? '' : $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 5 | my $files = Data::Shared::_cleanup_paths(\@pending); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 5 | ▶ | _rethrow($err, length($rollback . $files) ? "$rollback $files" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2744 | return $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2755 | }, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 5537 | ▶ | sub dispatch_verb { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_verb: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 5537 | my ($self, $root, $verb, $rest, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 5537 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 5537 | ▶ | if (!@$rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 11 | ▶ | return Data::Shared::Node->new($root, [ @{ $self->{path} } ]) if $verb eq 'get'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 7 | ▶ | return 1 if $verb eq 'exists'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 4 | Carp::croak("Data::Shared: cannot $verb a composite mount itself; address a child"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 5526 | my ($addr, @child_rest) = @$rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 5526 | ▶ | if (!@child_rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 75 | return $self->_verb_at_child($root, $verb, $addr, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 5451 | my $rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 5451 | ▶ | if ($verb eq 'exists' || $verb eq 'get' || $verb eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$verb eq "exists" or $verb eq "get" or $verb eq "delete"
$verb eq "exists" or $verb eq "get"
MC/DC100%3/3
$verb eq "exists" or $verb eq "get" or $verb eq "delete"
$verb eq "exists"
$verb eq "get"
$verb eq "delete"
Truth table100%4/4
A or B or C
A= $verb eq "exists"B= $verb eq "get"C= $verb eq "delete"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2604 | $rt = $self->_existing_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2596 | ▶ | return $verb eq 'exists' ? 0 : undef unless $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2847 | $rt = $self->_ensure_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 5386 | ▶ | if ($rt->{kind} eq 'composite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 38 | return $rt->{comp}->dispatch_verb($root, $verb, \@child_rest, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 5348 | return Data::Shared::_dispatch_record($verb, $rt->{record}, \@child_rest, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 75 | ▶ | sub _verb_at_child { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verb_at_child: called CC=22 SCAR=34.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 75 | my ($self, $root, $verb, $addr, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 75 | ▶ | my $key = $self->{node}{resolved}{entry}{key} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
MC/DC0%0/1
$self->{'node'}{'resolved'}{'entry'}{'key'} || ''
$self->{'node'}{'resolved'}{'entry'}{'key'}
Truth table50%1/2
A
A= $self->{'node'}{'resolved'}{'entry'}{'key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 75 | ▶ | if ($verb eq 'exists') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 17 | ▶ | return 0 unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 15 | ▶ | return (defined $self->_reg_id($addr) || $self->_parent_exists($addr)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->_reg_id($addr) or $self->_parent_exists($addr)
MC/DC50%1/2
defined $self->_reg_id($addr) or $self->_parent_exists($addr)
defined $self->_reg_id($addr)
$self->_parent_exists($addr)
Truth table66%2/3
A or B
A= defined $self->_reg_id($addr)B= $self->_parent_exists($addr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 58 | ▶ | if ($verb eq 'get') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 22 | ▶ | if ($key eq 'sortedset' && $self->{parent_handle}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq "sortedset" and $self->{"parent_handle"}
MC/DC50%1/2
$key eq "sortedset" and $self->{"parent_handle"}
$key eq "sortedset"
$self->{"parent_handle"}
Truth table66%2/3
A and B
A= $key eq "sortedset"B= $self->{"parent_handle"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 18 | ▶ | return undef unless $self->_valid_address($addr) && $self->_parent_exists($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_valid_address($addr) and $self->_parent_exists($addr)
MC/DC50%1/2
$self->_valid_address($addr) and $self->_parent_exists($addr)
$self->_valid_address($addr)
$self->_parent_exists($addr)
Truth table66%2/3
A and B
A= $self->_valid_address($addr)B= $self->_parent_exists($addr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 16 | return Data::Shared::_dispatch_record('get', $self->{parent_record}, [$addr]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 4 | ▶ | return undef unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 4 | ▶ | return undef unless defined $self->_reg_id($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 2 | return Data::Shared::Node->new($root, [ @{ $self->{path} }, $addr ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 36 | ▶ | if ($verb eq 'set' || $verb eq 'incr') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$verb eq "set" or $verb eq "incr"
MC/DC50%1/2
$verb eq "set" or $verb eq "incr"
$verb eq "set"
$verb eq "incr"
Truth table66%2/3
A or B
A= $verb eq "set"B= $verb eq "incr"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 18 | ▶ | Carp::croak("Data::Shared: cannot $verb a composite child of $self->{node}{spec}; $verb a path inside it") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | unless $key eq 'sortedset'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # Validate before setting the interrupted-mutation marker. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 16 | ▶ | Carp::croak("Data::Shared: sortedset $verb needs a " . ($verb eq 'set' ? 'score' : 'delta')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 15 | ▶ | Carp::croak('Data::Shared: composite is read-only') if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 15 | ▶ | Carp::croak("Data::Shared: invalid composite address '" . (defined $addr ? $addr : 'undef') . "' for $self->{node}{spec}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 15 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 15 | my $old_id = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 15 | my $was_parent = $self->_parent_exists($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 15 | ▶ | my $score = $was_parent ? Data::Shared::_dispatch_record('get', $self->{parent_record}, [$addr]) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 15 | my $count = $self->_child_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 15 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 15 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 15 | ▶ | unless (defined $old_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 8 | my $id = $self->_allocate_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 8 | $self->_parent_register($addr, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 8 | $self->_index_put('s:', $count + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 8 | $self->_index_put('a:' . $addr, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 15 | $result = Data::Shared::_dispatch_record($verb, $self->{parent_record}, [$addr], @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 15 | ▶ | Carp::croak('Data::Shared: parent score operation failed') unless defined $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 15 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 15 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | my $clean = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | $self->_index_remove('a:' . $addr) unless defined $old_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $self->_index_put('s:', $count); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if ($was_parent) { Data::Shared::_dispatch_record('set', $self->{parent_record}, [$addr], $score) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | else { $self->_parent_unregister($addr) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | _rethrow($err, $clean ? '' : $@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | # Registration pre-inserts score 0; report whether the address existed before this call. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 15 | ▶ | return 1 if $verb eq 'set' && !$was_parent && !$result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$verb eq "set" and not $was_parent and not $result
$verb eq "set" and not $was_parent
MC/DC33%1/3
$verb eq "set" and not $was_parent and not $result
$verb eq "set"
not $was_parent
not $result
Truth table50%2/4
A and not(B) and not(C)
A= $verb eq "set"B= not $was_parentC= not $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 7 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 15 | }, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 18 | ▶ | if ($verb eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 18 | return $self->delete_subtree($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | Carp::croak("Data::Shared: operation '$verb' is not supported at a composite child of $self->{node}{spec}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 18 | ▶ | sub dispatch_pushpop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_pushpop: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 18 | my ($self, $root, $which, $rest, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 18 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 18 | ▶ | Carp::croak("Data::Shared: cannot $which a composite mount itself; address a child") unless @$rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 16 | my ($addr, @child_rest) = @$rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # A missing child is an empty one to pop, not one to create. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 16 | ▶ | my $rt = $which eq 'pop' ? $self->_existing_child($root, $addr) : $self->_ensure_child($root, $addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 16 | ▶ | return undef unless $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 11 | ▶ | if ($rt->{kind} eq 'composite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | return $rt->{comp}->dispatch_pushpop($root, $which, \@child_rest, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 11 | return Data::Shared::_dispatch_record_pushpop($which, $rt->{record}, \@child_rest, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 86 | ▶ | sub dispatch_call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_call: called CC=20 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 86 | my ($self, $root, $rest, $method, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 86 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 86 | ▶ | if (!@$rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | return $self->$method(@args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 51 | ▶ | if $LIFECYCLE_METHOD{$method} && $self->can($method); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$LIFECYCLE_METHOD{$method} and $self->can($method)
MC/DC50%1/2
$LIFECYCLE_METHOD{$method} and $self->can($method)
$LIFECYCLE_METHOD{$method}
$self->can($method)
Truth table66%2/3
A and B
A= $LIFECYCLE_METHOD{$method}B= $self->can($method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 47 | ▶ | Carp::croak("Data::Shared: cannot freeze composite mount '$self->{name}' through call();" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | . " sealing the subtree would seal its child index too. Use \$root->freeze_all") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | if $method eq 'freeze'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 46 | ▶ | if ($self->{parent_handle} && $self->{parent_handle}->can($method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"parent_handle"} and $self->{"parent_handle"}->can($method)
MC/DC50%1/2
$self->{"parent_handle"} and $self->{"parent_handle"}->can($method)
$self->{"parent_handle"}
$self->{"parent_handle"}->can($method)
Truth table66%2/3
A and B
A= $self->{"parent_handle"}B= $self->{"parent_handle"}->can($method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 30 | return $self->{parent_handle}->$method(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 16 | ▶ | if ($method eq 'children') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 2 | my @c = $self->children_at($root, []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 2 | ▶ | return wantarray ? @c : \@c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 14 | ▶ | if ($method eq 'child_count') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 14 | return $self->_child_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | Carp::croak("Data::Shared: composite mount '" . $self->{name} . "' has no method '$method'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 35 | my ($addr, @child_rest) = @$rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # Retiring must not construct a missing child. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 35 | ▶ | my $retire = $method eq 'unlink' || $method eq 'destroy'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$method eq 'unlink' || $method eq 'destroy'
MC/DC100%2/2
$method eq 'unlink' || $method eq 'destroy'
$method eq 'unlink'
$method eq 'destroy'
Truth table100%3/3
A || B
A= $method eq 'unlink'B= $method eq 'destroy'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 35 | ▶ | return $self->delete_subtree($root, $addr) if $retire && !@child_rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$retire and not @child_rest
MC/DC100%2/2
$retire and not @child_rest
$retire
not @child_rest
Truth table100%3/3
A and not(B)
A= $retireB= not @child_rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 30 | ▶ | my $rt = $self->{readonly} || $retire | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"readonly"} or $retire
MC/DC100%2/2
$self->{"readonly"} or $retire
$self->{"readonly"}
$retire
Truth table100%3/3
A or B
A= $self->{"readonly"}B= $retire
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | ? $self->_existing_child($root, $addr) : $self->_ensure_child($root, $addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 30 | ▶ | return undef if $retire && !$rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$retire and not $rt
MC/DC100%2/2
$retire and not $rt
$retire
not $rt
Truth table100%3/3
A and not(B)
A= $retireB= not $rt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 26 | ▶ | Carp::croak('Data::Shared: read-only composite has no constructed child at this path') unless $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 24 | ▶ | if ($rt->{kind} eq 'composite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 4 | return $rt->{comp}->dispatch_call($root, \@child_rest, $method, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # Native leaf unlink/destroy ignore record suffixes and remove the whole file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 20 | ▶ | Carp::croak("Data::Shared: '$method' retires a composite child, not the record" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | . " at '$addr/" . join('/', @child_rest) . "' below it;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | . " use shared_delete to remove a record") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | if $retire; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 18 | return Data::Shared::_dispatch_record_call($rt->{record}, \@child_rest, $method, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 194 | ▶ | sub children_at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children_at: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 194 | my ($self, $root, $rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | # Must not require a live root: teardown lists children after its root may be gone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 194 | ▶ | if (!@$rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 192 | my @addrs = map { substr($_, 2) } grep { substr($_, 0, 2) eq 'a:' } $self->{index}->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 192 | ▶ | my @sorted = $self->_key_is_int ? (sort { $a <=> $b } @addrs) : (sort @addrs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 192 | return @sorted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 2 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | my ($addr, @more) = @$rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 2 | my $rt = $self->_existing_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | Carp::croak("Data::Shared: no composite child at '" . join('/', @{ $self->{path} }, $addr) . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | unless $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 2 | ▶ | Carp::croak("Data::Shared: child '$addr' is not composite") unless $rt->{kind} eq 'composite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 2 | return $rt->{comp}->children_at($root, \@more); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 10 | ▶ | sub handle_at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_at: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 10 | my ($self, $root, $rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 10 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 10 | ▶ | if (!@$rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 2 | return Data::Shared::Node->new($root, [ @{ $self->{path} } ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 8 | my ($addr, @more) = @$rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 8 | my $rt = $self->_existing_child($root, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | Carp::croak("Data::Shared: no child at '" . join('/', @{ $self->{path} }, $addr) . "'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | unless $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 8 | ▶ | if ($rt->{kind} eq 'composite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | return $rt->{comp}->handle_at($root, \@more); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 8 | ▶ | Carp::croak("Data::Shared: handle() path must name a leaf exactly (got extra components)") if @more; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 8 | return $rt->{handle}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | # The caller owns registry, cache, and directory cleanup. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 28 | ▶ | sub _remove_child_storage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_child_storage: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 28 | my ($rt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 28 | ▶ | if ($rt->{kind} eq 'composite') { $rt->{comp}->destroy } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 21 | elsif ($rt->{handle}->can('unlink')) { $rt->{handle}->unlink } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 28 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 23 | ▶ | sub delete_subtree { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_subtree: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 23 | my ($self, $root, $addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 23 | $root = $self->_root($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 23 | ▶ | Carp::croak('Data::Shared: composite is read-only, cannot delete') if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 23 | ▶ | return undef unless $self->_valid_address($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 23 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=22 SCAR=38.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 23 | my $id = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 23 | my $was_parent = $self->_parent_exists($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 23 | ▶ | return undef unless defined $id || $was_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $id or $was_parent
MC/DC50%1/2
defined $id or $was_parent
defined $id
$was_parent
Truth table66%2/3
A or B
A= defined $idB= $was_parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 18 | my $cleanup_rt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 18 | ▶ | if (defined $id && $self->{node}{child}{child} && $self->_reg_constructed($addr, $id)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $id and $self->{"node"}{"child"}{"child"} and $self->_reg_constructed($addr, $id)
defined $id and $self->{"node"}{"child"}{"child"}
MC/DC66%2/3
defined $id and $self->{"node"}{"child"}{"child"} and $self->_reg_constructed($addr, $id)
defined $id
$self->{"node"}{"child"}{"child"}
$self->_reg_constructed($addr, $id)
Truth table75%3/4
A and B and C
A= defined $idB= $self->{"node"}{"child"}{"child"}C= $self->_reg_constructed($addr, $id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 4 | $cleanup_rt = $self->_open_child($root, $addr, $id, 1, undef, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 18 | my $marker = $self->{index}->get('c:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 18 | my $count = $self->_child_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | my $score = $was_parent && !$self->_is_index_parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 18 | ▶ | ? Data::Shared::_dispatch_record('get', $self->{parent_record}, [$addr]) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$was_parent and not $self->_is_index_parent
MC/DC0%0/2
$was_parent and not $self->_is_index_parent
$was_parent
not $self->_is_index_parent
Truth table33%1/3
A and not(B)
A= $was_parentB= not $self->_is_index_parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 18 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 18 | ▶ | if (defined $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | # Remove readiness before registration; interruption then leaves a recoverable score-only child. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 18 | $self->_index_remove('c:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 18 | $self->_index_remove('a:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 18 | $self->_index_put('s:', $count - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 18 | $self->_parent_unregister($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 18 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 18 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | my $clean = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | $self->_index_put('c:' . $addr, $marker) if defined $marker; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | $self->_index_put('a:' . $addr, $id) if defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $self->_index_put('s:', $count); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | # Restoring an untouched record would fail on a frozen parent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | Data::Shared::_dispatch_record('set', $self->{parent_record}, [$addr], $score) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$was_parent and not $self->_is_index_parent and not $self->_parent_exists($addr)
$was_parent and not $self->_is_index_parent
MC/DC0%0/3
$was_parent and not $self->_is_index_parent and not $self->_parent_exists($addr)
$was_parent
not $self->_is_index_parent
not $self->_parent_exists($addr)
Truth table0%0/4
A and not(B) and not(C)
A= $was_parentB= not $self->_is_index_parentC= not $self->_parent_exists($addr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | if $was_parent && !$self->_is_index_parent && !$self->_parent_exists($addr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | _rethrow($err, $clean ? '' : $@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 18 | ▶ | if (defined $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 18 | ▶ | my $rt = $self->_forget($id) || $cleanup_rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->_forget($id) || $cleanup_rt
MC/DC100%2/2
$self->_forget($id) || $cleanup_rt
$self->_forget($id)
$cleanup_rt
Truth table100%3/3
A || B
A= $self->_forget($id)B= $cleanup_rt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 18 | ▶ | if ($rt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 15 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 15 | _remove_child_storage($rt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 15 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my $why = Data::Shared::_strip_location($@); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | Carp::croak("Data::Shared: subtree detached but retiring its storage" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | . " failed: $why"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 18 | ▶ | if (defined $self->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 9 | my $cleanup = Data::Shared::_cleanup_paths(["$self->{dir}/child-$id"]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 9 | ▶ | Carp::croak("Data::Shared: subtree detached but cleanup failed: $cleanup") if length $cleanup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 18 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 23 | }, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 20 | ▶ | sub destroy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 20 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 20 | ▶ | Carp::croak('Data::Shared: composite is read-only, cannot destroy') if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 20 | ▶ | return 0 if defined $self->{dir} && !-d $self->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"dir"} and not -d $self->{"dir"}
MC/DC0%0/2
defined $self->{"dir"} and not -d $self->{"dir"}
defined $self->{"dir"}
not -d $self->{"dir"}
Truth table66%2/3
A and not(B)
A= defined $self->{"dir"}B= not -d $self->{"dir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | # Teardown may retry after removing its own index. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 20 | local $self->{_cleanup} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 20 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=16 SCAR=27.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 20 | my $frozen = $self->_index_frozen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 20 | ▶ | if (!$frozen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # Set 'x:' first: waiters keep the old mapped index and could rebuild the subtree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 12 | $self->_index_put('x:', 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 12 | for my $addr ($self->children_at(undef, [])) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 14 | my $id = $self->_reg_id($addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 14 | my $rt = $self->{cache}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 14 | ▶ | if (!$rt && $self->{node}{child}{child} && $self->_reg_constructed($addr, $id)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $rt and $self->{"node"}{"child"}{"child"} and $self->_reg_constructed($addr, $id)
not $rt and $self->{"node"}{"child"}{"child"}
MC/DC100%3/3
not $rt and $self->{"node"}{"child"}{"child"} and $self->_reg_constructed($addr, $id)
not $rt
$self->{"node"}{"child"}{"child"}
$self->_reg_constructed($addr, $id)
Truth table100%4/4
not(A) and B and C
A= not $rtB= $self->{"node"}{"child"}{"child"}C= $self->_reg_constructed($addr, $id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 1 | $rt = $self->_open_child($self->{root_weak}, $addr, $id, 1, undef, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 14 | $self->_index_remove('a:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 14 | $self->_index_remove('c:' . $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 14 | $self->_forget($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 14 | ▶ | _remove_child_storage($rt) if $rt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 12 | $self->_index_put('s:', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # Frozen indexes already reject the mutation marker before any creation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 8 | for my $rt (values %{ $self->{cache} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 5 | _remove_child_storage($rt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 20 | ▶ | $self->{parent_handle}->unlink if $self->{parent_handle} && $self->{parent_handle}->can('unlink'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"parent_handle"} and $self->{"parent_handle"}->can("unlink")
MC/DC0%0/2
$self->{"parent_handle"} and $self->{"parent_handle"}->can("unlink")
$self->{"parent_handle"}
$self->{"parent_handle"}->can("unlink")
Truth table33%1/3
A and B
A= $self->{"parent_handle"}B= $self->{"parent_handle"}->can("unlink")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 20 | ▶ | $self->{index}->unlink if $self->{index} && $self->{index}->can('unlink'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"index"} and $self->{"index"}->can("unlink")
MC/DC0%0/2
$self->{"index"} and $self->{"index"}->can("unlink")
$self->{"index"}
$self->{"index"}->can("unlink")
Truth table33%1/3
A and B
A= $self->{"index"}B= $self->{"index"}->can("unlink")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 20 | $self->{cache} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 20 | $self->{lru_prev} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 20 | $self->{lru_next} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 20 | delete @{$self}{qw(lru_head lru_tail)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 20 | ▶ | if (defined $self->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # Lock only the nested dirs: flock via a second descriptor of our held lock would block. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 18 | my @under; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 18 | ▶ | if (opendir my $dh, $self->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 45 | @under = map { "$self->{dir}/$_" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 18 | ▶ | grep { $_ ne '.' && $_ ne '..' } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_ ne '.' && $_ ne '..'
MC/DC100%2/2
$_ ne '.' && $_ ne '..'
$_ ne '.'
$_ ne '..'
Truth table100%3/3
A && B
A= $_ ne '.'B= $_ ne '..'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 18 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 18 | my $held = Data::Shared::_lock_composite_dirs(\@under); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 18 | my $cleanup = Data::Shared::_cleanup_paths([$self->{dir}]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 18 | undef $held; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 18 | ▶ | Carp::croak("Data::Shared: cannot remove retired composite: $cleanup") if length $cleanup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 19 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 20 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 5 | ▶ | sub _rethrow { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rethrow: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 5 | my ($err, $rollback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 5 | ▶ | die $err if ref $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # Croak here, not in a shared helper, so Carp blames the composite's caller. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 5 | ▶ | Carp::croak(Data::Shared::_strip_location($err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rollback and length $rollback
MC/DC0%0/2
defined $rollback and length $rollback
defined $rollback
length $rollback
Truth table33%1/3
A and B
A= defined $rollbackB= length $rollback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | . (defined $rollback && length $rollback ? " (rollback: $rollback)" : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 64 | ▶ | sub _sync_once { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sync_once: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 64 | my ($rt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 64 | ▶ | return $rt->{comp}->sync if $rt->{kind} eq 'composite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 62 | ▶ | return 0 unless $rt->{handle}->can('sync'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 62 | $rt->{handle}->sync; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 62 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 12 | ▶ | sub sync { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 12 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 12 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | # Sealed children need no _frozen_ok: _existing_child opens with opening=1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # which already permits them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 12 | local $self->{_walking} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 12 | my $root = $self->{root_weak}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 12 | ▶ | if (defined $self->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # One child open at a time, or a large composite runs out of descriptors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 11 | for my $addr ($self->children_at(undef, [])) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 63 | ▶ | my $rt = $self->_existing_child($root, $addr) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 63 | $n += _sync_once($rt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # Anonymous roots can flush only children mapped in this process. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 1 | $n += _sync_once($_) for values %{ $self->{cache} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # Native sync returns nothing; count the call regardless of its result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 12 | for my $h ($self->{parent_handle}, $self->{index}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 24 | ▶ | next unless $h && $h->can('sync'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$h and $h->can("sync")
MC/DC0%0/2
$h and $h->can("sync")
$h
$h->can("sync")
Truth table33%1/3
A and B
A= $hB= $h->can("sync")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 24 | $h->sync; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 24 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 12 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 7029 | ▶ | sub _index_frozen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_frozen: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 7029 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 7029 | ▶ | return $self->{index} && $self->{index}->can('frozen') && $self->{index}->frozen ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->{"index"} and $self->{"index"}->can("frozen") and $self->{"index"}->frozen
$self->{"index"} and $self->{"index"}->can("frozen")
MC/DC33%1/3
$self->{"index"} and $self->{"index"}->can("frozen") and $self->{"index"}->frozen
$self->{"index"}
$self->{"index"}->can("frozen")
$self->{"index"}->frozen
Truth table50%2/4
A and B and C
A= $self->{"index"}B= $self->{"index"}->can("frozen")C= $self->{"index"}->frozen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | # The class of the first level that cannot reopen read-only, or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 107 | ▶ | sub _unsealable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unsealable: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 107 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 107 | ▶ | for (my $node = $self->{node}; $node; $node = $node->{child}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 217 | ▶ | return $node->{resolved}{class} unless Data::Shared::Storage::readonly_capable($node->{resolved}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 105 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # The index is frozen last, so a frozen index means the subtree is sealed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 103 | ▶ | sub frozen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
frozen: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 103 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 103 | ▶ | return $self->_index_frozen && !defined $self->_unsealable ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_index_frozen and not defined $self->_unsealable
MC/DC100%2/2
$self->_index_frozen and not defined $self->_unsealable
$self->_index_frozen
not defined $self->_unsealable
Truth table100%3/3
A and not(B)
A= $self->_index_frozenB= not defined $self->_unsealable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 95 | ▶ | sub freeze { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeze: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 95 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 95 | ▶ | Carp::croak("Data::Shared: cannot freeze a read-only composite") if $self->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 95 | ▶ | return $self->_with_lock(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 95 | my $root = $self->{root_weak}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 95 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | # Earlier freezes may have sealed uncached children; see sync. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 95 | local $self->{_walking} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 95 | for my $addr ($self->children_at(undef, [])) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 156 | ▶ | my $rt = $self->_existing_child($root, $addr) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 156 | ▶ | if ($rt->{kind} eq 'composite') { $n += $rt->{comp}->freeze } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 154 | else { $n += _freeze_once($rt->{handle}) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 95 | $n += _freeze_once($self->{parent_handle}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 95 | $n += _freeze_once($self->{index}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 95 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 95 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 13 | ▶ | sub unlink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlink: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 13 | return $self->destroy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 15 | ▶ | sub stats { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stats: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 15 | my %children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 15 | for my $id (sort { $a <=> $b } keys %{ $self->{cache} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 47 | my $rt = $self->{cache}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | $children{ $rt->{addr} } = $rt->{kind} eq 'composite' ? $rt->{comp}->stats | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 47 | ▶ | : ($rt->{handle}->can('stats') ? $rt->{handle}->stats : { class => ref $rt->{handle} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | class => 'Data::Shared::Composite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | spec => $self->{node}{spec}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | children => $self->_child_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 15 | open => scalar keys %{ $self->{cache} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | child_stats => \%children, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||