| 1 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package Data::Conveyor::Ticket::Provider; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $Data::Conveyor::Ticket::Provider::VERSION = '1.103130'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use parent 'Class::Scaffold::Storable'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | __PACKAGE__->mk_scalar_accessors( | |||||||||||||||||||||||||||||||||||||||||
| 13 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 14 | handle prefetch supported timestamp lagmax clause | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 16 | )->mk_array_accessors(qw(accepted_stages stack)); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use constant INFO => qw/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | ticket_no | ||||||||||||||||||||||||||||||||||||||||||
| 19 | stage | ||||||||||||||||||||||||||||||||||||||||||
| 20 | rc | ||||||||||||||||||||||||||||||||||||||||||
| 21 | status | ||||||||||||||||||||||||||||||||||||||||||
| 22 | nice | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | /; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use constant PREFETCH_MAX => 12; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use constant DEFAULTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | prefetch => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | lagmax => 8 | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use constant NULLCLAUSE => '0=0'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $self->storage_type('core_storage'); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $self->clause($self->delegate->ticket_provider_clause || NULLCLAUSE); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->delegate->ticket_provider_clause || '0=0'
MC/DC0%0/1
$self->delegate->ticket_provider_clause || '0=0'
$self->delegate->ticket_provider_clause
Truth table0%0/2
A
A= $self->delegate->ticket_provider_clause
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | die sprintf "prefetch value too large: %d", $self->prefetch | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | if $self->prefetch > PREFETCH_MAX; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub get_next_ticket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_next_ticket: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $supported = join ",", map { "'starten_$_'" } @{ shift(@_) }; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $succeeded = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $self->stack_clear if $succeeded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $info = $self->_next_unit($supported); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return unless $info; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | my $ticket = | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->delegate->make_obj('ticket', map { $_ => $info->{$_} } INFO); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $ticket; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub _next_unit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next_unit: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ($self, $supported) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $self->handle( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | $self->storage->prepare(' | ||||||||||||||||||||||||||||||||||||||||||
| 56 | begin | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ticket_pck.next_ticketblock_select ( | ||||||||||||||||||||||||||||||||||||||||||
| 58 | :supported | ||||||||||||||||||||||||||||||||||||||||||
| 59 | , :prefetch | ||||||||||||||||||||||||||||||||||||||||||
| 60 | , :clause | ||||||||||||||||||||||||||||||||||||||||||
| 61 | , :nextblock | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | end; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ') | ||||||||||||||||||||||||||||||||||||||||||
| 65 | ) unless $self->handle; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $self->stack_count | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->stack_count and $self->fresh and $supported eq $self->supported
$self->stack_count and $self->fresh
MC/DC0%0/3
$self->stack_count and $self->fresh and $supported eq $self->supported
$self->stack_count
$self->fresh
$supported eq $self->supported
Truth table0%0/4
A and B and C
A= $self->stack_countB= $self->freshC= $supported eq $self->supported
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | && $self->fresh | ||||||||||||||||||||||||||||||||||||||||||
| 68 | && $supported eq $self->supported) { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return $self->stack_shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->supported($supported); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $nextblock; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->handle->bind_param(':supported', $supported); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->handle->bind_param(':prefetch', $self->prefetch); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->handle->bind_param(':clause', $self->clause); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->handle->bind_param_inout(':nextblock', \$nextblock, 4096); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $self->handle->execute; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->stack_clear; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->timestamp(time()); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return unless $nextblock; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | for my $token (split /#/, $nextblock) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my (%entry, @info); | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | @info = split / /, $token; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | die sprintf "severe provider error" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | unless @info == 5; | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | @entry{ (INFO) } = @info; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->stack_push(\%entry); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return $self->_next_unit($supported); | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub fresh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fresh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return (time() - $self->timestamp <= $self->lagmax); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | defined $self->handle | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | && $self->handle->finish; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | __END__ | ||||||||||||||||||||||||||||||||||||||||||