| 1 | #!/usr/bin/perl | ||||||||||||
| 2 | |||||||||||||
| 3 | package KiokuDB::Stream::Objects; | ||||||||||||
| 4 | 12 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 12 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 12 | has directory => ( | |||||||||||
| 9 | isa => "KiokuDB", | ||||||||||||
| 10 | is => "ro", | ||||||||||||
| 11 | required => 1, | ||||||||||||
| 12 | ); | ||||||||||||
| 13 | |||||||||||||
| 14 | 12 | has entry_stream => ( | |||||||||||
| 15 | does => "Data::Stream::Bulk", | ||||||||||||
| 16 | is => "ro", | ||||||||||||
| 17 | required => 1, | ||||||||||||
| 18 | handles => [qw(is_done loaded)], | ||||||||||||
| 19 | ); | ||||||||||||
| 20 | |||||||||||||
| 21 | 12 | has linker => ( | |||||||||||
| 22 | isa => "KiokuDB::Linker", | ||||||||||||
| 23 | is => "ro", | ||||||||||||
| 24 | lazy_build => 1, | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | |||||||||||||
| 27 | sub _build_linker { | ||||||||||||
| 28 | 340 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
_build_linker: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | |||||||||||||
| 30 | 340 | $self->directory->linker; | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 12 | has live_objects => ( | |||||||||||
| 34 | isa => "KiokuDB::LiveObjects", | ||||||||||||
| 35 | is => "ro", | ||||||||||||
| 36 | lazy_build => 1, | ||||||||||||
| 37 | ); | ||||||||||||
| 38 | |||||||||||||
| 39 | sub _build_live_objects { | ||||||||||||
| 40 | 340 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
_build_live_objects: called CC=1 SCAR=0.0
| |||||||||||||
| 41 | |||||||||||||
| 42 | 340 | $self->directory->live_objects; | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 12 | has _scope => ( | |||||||||||
| 46 | isa => "KiokuDB::LiveObjects::Scope", | ||||||||||||
| 47 | writer => "_scope", | ||||||||||||
| 48 | clearer => "_clear_scope", | ||||||||||||
| 49 | ); | ||||||||||||
| 50 | |||||||||||||
| 51 | 12 | has _no_scope => ( | |||||||||||
| 52 | isa => "Bool", | ||||||||||||
| 53 | is => "rw", | ||||||||||||
| 54 | ); | ||||||||||||
| 55 | |||||||||||||
| 56 | 12 | with qw(Data::Stream::Bulk) => { excludes => 'loaded' }; | |||||||||||
| 57 | |||||||||||||
| 58 | sub next { | ||||||||||||
| 59 | 858 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
next: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||
| 60 | |||||||||||||
| 61 | 858 | $self->_clear_scope; | |||||||||||
| 62 | |||||||||||||
| 63 | 858 | ▶ | my $entries = $self->entry_stream->next || return;; | ||||||||||
|
Condition100%2/2
$self->entry_stream->next || (return)
MC/DC100%1/1
$self->entry_stream->next || (return)
$self->entry_stream->next
Truth table100%2/2
A
A= $self->entry_stream->next
| |||||||||||||
| 64 | |||||||||||||
| 65 | 386 | ▶ | if ( @$entries ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | 385 | ▶ | $self->_scope( $self->directory->new_scope ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | unless $self->_no_scope; | ||||||||||||
| 68 | |||||||||||||
| 69 | 385 | $self->live_objects->register_entry( $_->id => $_, in_storage => 1 ) for @$entries; | |||||||||||
| 70 | |||||||||||||
| 71 | 385 | return [ $self->linker->register_and_expand_entries(@$entries) ]; | |||||||||||
| 72 | } else { | ||||||||||||
| 73 | 1 | return []; | |||||||||||
| 74 | } | ||||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 468 | ▶ | before all => sub { shift->_no_scope(1) }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 78 | |||||||||||||
| 79 | 12 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 80 | |||||||||||||
| 81 | 12 | __PACKAGE__ | |||||||||||
| 82 | |||||||||||||
| 83 | __END__ | ||||||||||||
| 84 | |||||||||||||
| 85 | =pod | ||||||||||||
| 86 | |||||||||||||
| 87 | =head1 NAME | ||||||||||||
| 88 | |||||||||||||
| 89 | KiokuDB::Stream::Objects - L<Data::Stream::Bulk> with live object management. | ||||||||||||
| 90 | |||||||||||||
| 91 | =head1 DESCRIPTION | ||||||||||||
| 92 | |||||||||||||
| 93 | This class is for object streams coming out of L<KiokuDB>. | ||||||||||||
| 94 | |||||||||||||
| 95 | C<new_scope> is called once for each block, and then cleared. | ||||||||||||
| 96 | |||||||||||||
| 97 | =cut | ||||||||||||
| 98 | |||||||||||||
| 99 | |||||||||||||