Harmonize time zone spelling in InflateColumn::DateTime
[dbsrgits/DBIx-Class.git] / examples / Benchmarks / semicolon_vs_comma_rowparser / semicol.src
CommitLineData
05a5ca4b 1### BEGIN LITERAL STRING EVAL
2 my $rows_pos = 0;
3 my ($result_pos, @collapse_idx, $cur_row_data, %cur_row_ids );
4
5 # this loop is a bit arcane - the rationale is that the passed in
6 # $_[0] will either have only one row (->next) or will have all
7 # rows already pulled in (->all and/or unordered). Given that the
8 # result can be rather large - we reuse the same already allocated
9 # array, since the collapsed prefetch is smaller by definition.
10 # At the end we cut the leftovers away and move on.
11 while ($cur_row_data = (
12 (
13 $rows_pos >= 0
14 and
15 (
16 $_[0][$rows_pos++]
17 or
18 # It may be tempting to drop the -1 and undef $rows_pos instead
19 # thus saving the >= comparison above as well
20 # However NULL-handlers and underdefined root markers both use
21 # $rows_pos as a last-resort-uniqueness marker (it either is
22 # monotonically increasing while we parse ->all, or is set at
23 # a steady -1 when we are dealing with a single root node). For
24 # the time being the complication of changing all callsites seems
25 # overkill, for what is going to be a very modest saving of ops
26 ( ($rows_pos = -1), undef )
27 )
28 )
29 or
30 ( $_[1] and $_[1]->() )
31 ) ) {
32
33 # the undef checks may or may not be there
34 # depending on whether we prune or not
35 #
36 # due to left joins some of the ids may be NULL/undef, and
37 # won't play well when used as hash lookups
38 # we also need to differentiate NULLs on per-row/per-col basis
39 # (otherwise folding of optional 1:1s will be greatly confused
40@cur_row_ids{( 0, 1, 5, 6, 8, 10 )} = (
41@{$cur_row_data}[( 0, 1, 5, 6, 8, 10 )]
42 );
43
44 # in the case of an underdefined root - calculate the virtual id (otherwise no code at all)
45
46
47 # if we were supplied a coderef - we are collapsing lazily (the set
48 # is ordered properly)
49 # as long as we have a result already and the next result is new we
50 # return the pre-read data and bail
51$_[1] and $result_pos and ! $collapse_idx[0]{ $cur_row_ids{1} } and (unshift @{$_[2]}, $cur_row_data) and last;
52
53 # the rel assemblers
54$collapse_idx[0]{ $cur_row_ids{1} } //= $_[0][$result_pos++] = [ { "genreid" => $cur_row_data->[4], "latest_cd" => $cur_row_data->[7], "year" => $cur_row_data->[3] } ];
55$collapse_idx[0]{ $cur_row_ids{1} }[1]{"existing_single_track"} //= $collapse_idx[1]{ $cur_row_ids{1} } = [ ];
56$collapse_idx[1]{ $cur_row_ids{1} }[1]{"cd"} //= $collapse_idx[2]{ $cur_row_ids{1} } = [ ];
57$collapse_idx[2]{ $cur_row_ids{1} }[1]{"artist"} //= $collapse_idx[3]{ $cur_row_ids{1} } = [ { "artistid" => $cur_row_data->[1] } ];
58( ! defined $cur_row_data->[6] )
59 ? $collapse_idx[3]{ $cur_row_ids{1} }[1]{"cds"} = []
60 : do {
61(! $collapse_idx[4]{ $cur_row_ids{1} }{ $cur_row_ids{6} }) and push @{$collapse_idx[3]{ $cur_row_ids{1} }[1]{"cds"}}, $collapse_idx[4]{ $cur_row_ids{1} }{ $cur_row_ids{6} } = [ { "cdid" => $cur_row_data->[6], "genreid" => $cur_row_data->[9], "year" => $cur_row_data->[2] } ];
62( ! defined $cur_row_data->[8] )
63 ? $collapse_idx[4]{ $cur_row_ids{1} }{ $cur_row_ids{6} }[1]{"tracks"} = []
64 : do {
65(! $collapse_idx[5]{ $cur_row_ids{1} }{ $cur_row_ids{6} }{ $cur_row_ids{8} }) and push @{$collapse_idx[4]{ $cur_row_ids{1} }{ $cur_row_ids{6} }[1]{"tracks"}}, $collapse_idx[5]{ $cur_row_ids{1} }{ $cur_row_ids{6} }{ $cur_row_ids{8} } = [ { "title" => $cur_row_data->[8] } ];
66};
67};
68( ! defined $cur_row_data->[5] )
69 ? $collapse_idx[0]{ $cur_row_ids{1} }[1]{"tracks"} = []
70 : do {
71(! $collapse_idx[6]{ $cur_row_ids{1} }{ $cur_row_ids{5} }) and push @{$collapse_idx[0]{ $cur_row_ids{1} }[1]{"tracks"}}, $collapse_idx[6]{ $cur_row_ids{1} }{ $cur_row_ids{5} } = [ { "title" => $cur_row_data->[5] } ];
72( ! defined $cur_row_data->[10] )
73 ? $collapse_idx[6]{ $cur_row_ids{1} }{ $cur_row_ids{5} }[1]{"lyrics"} = []
74 : do {
75$collapse_idx[6]{ $cur_row_ids{1} }{ $cur_row_ids{5} }[1]{"lyrics"} //= $collapse_idx[7]{ $cur_row_ids{1} }{ $cur_row_ids{5} }{ $cur_row_ids{10} } = [ ];
76(! $collapse_idx[8]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{5} }{ $cur_row_ids{10} }) and push @{$collapse_idx[7]{ $cur_row_ids{1} }{ $cur_row_ids{5} }{ $cur_row_ids{10} }[1]{"existing_lyric_versions"}}, $collapse_idx[8]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{5} }{ $cur_row_ids{10} } = [ { "lyric_id" => $cur_row_data->[10], "text" => $cur_row_data->[0] } ];
77};
78};
79
80 }
81
82 $#{$_[0]} = $result_pos - 1; # truncate the passed in array to where we filled it with results
83### END LITERAL STRING EVAL