blib/lib/DBIO/ResultClass/HashRefInflator.pm

filter: Statementstmt 52.6% 10 / 19 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 2 / 4 Podpod 100% 1 / 1 totaltotal 28.2% 13 / 46 CC 9 SCAR 42.2
CC
9
Cov
27%
__ANON__
90.0
inflate_result
2.0
BEGIN
1.0
CRAP 67.8
« blib/lib/DBIO/Storage/DBI/Cursor.pm ↑ Summary blib/lib/DBIO/ResultSource/RowParser.pm »
1 package DBIO::ResultClass::HashRefInflator;
2 # ABSTRACT: Get raw hashrefs from a resultset
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our $VERSION = '0.900007';
8  
9  
10 ##############
11 # NOTE
12 #
13 # Generally people use this to gain as much speed as possible. If a new &mk_hash is
14 # implemented, it should be benchmarked using the maint/benchmark_hashrefinflator.pl
15 # script (in addition to passing all tests of course :)
16  
17 # This coderef is a simple recursive function
18 # Arguments: ($me, $prefetch, $is_root) from inflate_result() below
19 9 my $mk_hash;
20 0 ▶$mk_hash = sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
21  
22 my $hash = {
23  
24 # the main hash could be an undef if we are processing a skipped-over join
25 0 $_[0] ? %{$_[0]} : (),
26  
27 # the second arg is a hash of arrays for each prefetched relation
28 map { $_ => (
29  
30 # null-branch or not
31 ref $_[1]->{$_} eq $DBIO::ResultSource::RowParser::Util::null_branch_class
32  
33 ? ref $_[1]->{$_}[0] eq 'ARRAY' ? [] : undef
34  
35 : ref $_[1]->{$_}[0] eq 'ARRAY'
36 0 ▶ ? [ map { $mk_hash->( @$_ ) || () } @{$_[1]->{$_}} ]
Condition0%0/3
&$mk_hash(@$_) || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
&$mk_hash(@$_) || ()
&$mk_hash(@$_) ()
Truth table0%0/3
A || B
A= &$mk_hash(@$_)B= ()
ABresult
1X1
011
000
37 0 ▶ : $mk_hash->( @{$_[1]->{$_}} )
Branch: 4 branches
BranchTrueFalseTotal
ref $_[1]{$_} eq $DBIO::ResultSource::RowParser::Util::null_branch_class ? : 0 0 0
ref $_[1]{$_}[0] eq 'ARRAY' ? : 0 0 0
ref $_[1]{$_}[0] eq 'ARRAY' ? : 0 0 0
$_[1] ? : 0 0 0
38  
39 0 ▶ ) } ($_[1] ? keys %{$_[1]} : ())
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
40 };
41  
42 0 ▶ ($_[2] || keys %$hash) ? $hash : undef;
Branch: 1 branch
BranchTrueFalseTotal
$_[2] || keys %$hash ? : 0 0 0
Condition0%0/3
$_[2] or keys %$hash
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[2] or keys %$hash
$_[2] keys %$hash
Truth table0%0/3
A or B
A= $_[2]B= keys %$hash
ABresult
1X1
011
000
43 9 };
44  
45  
46 ##################################################################################
47 # inflate_result is invoked as:
48 # HRI->inflate_result ($resultsource_instance, $main_data_hashref, $prefetch_data_hashref)
49 0 ▶sub inflate_result {
Subroutine inflate_result: not called CC=1 SCAR=6.9
Pod documented
50 0 return $mk_hash->($_[2], $_[3], 'is_root');
51 }
52  
53 9 1;
54  
55 __END__
« blib/lib/DBIO/Storage/DBI/Cursor.pm ↑ Summary blib/lib/DBIO/ResultSource/RowParser.pm »