| 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(@$_) || ()
MC/DC0%0/2
&$mk_hash(@$_) || ()
&$mk_hash(@$_)
()
Truth table0%0/3
A || B
A= &$mk_hash(@$_)B= ()
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | : $mk_hash->( @{$_[1]->{$_}} ) | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | ) } ($_[1] ? keys %{$_[1]} : ()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | ($_[2] || keys %$hash) ? $hash : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[2] or keys %$hash
MC/DC0%0/2
$_[2] or keys %$hash
$_[2]
keys %$hash
Truth table0%0/3
A or B
A= $_[2]B= keys %$hash
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||