| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Cmd::Command::Dump; | ||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use KiokuDB::Backend::Role::Scan (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | extends qw(KiokuDB::Cmd::Base); | |||||||||
| 11 | |||||||||||
| 12 | 1 | with qw( | |||||||||
| 13 | KiokuDB::Cmd::WithDSN::Read | ||||||||||
| 14 | KiokuDB::Cmd::DumpFormatter | ||||||||||
| 15 | KiokuDB::Cmd::SpecifiedEntries | ||||||||||
| 16 | KiokuDB::Cmd::OutputHandle | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 1 | has '+entries_in_args' => ( default => 1 ); | |||||||||
| 20 | |||||||||||
| 21 | 3 | ▶ | augment run => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 22 | 3 | my $self = shift; | |||||||||
| 23 | |||||||||||
| 24 | 3 | $self->v("dumping entries\n"); | |||||||||
| 25 | |||||||||||
| 26 | 3 | my $stream = $self->entries; | |||||||||
| 27 | |||||||||||
| 28 | 3 | my $out = $self->output_handle; | |||||||||
| 29 | 3 | my $ser = $self->serializer; | |||||||||
| 30 | |||||||||||
| 31 | 3 | my $i; | |||||||||
| 32 | |||||||||||
| 33 | 3 | ▶ | while ( $self->v("loading block #", ++$i, "..."), my $block = $stream->next ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 3 | $self->v(" dumping ", scalar(@$block), " entries..."); | |||||||||
| 35 | 3 | foreach my $entry ( @$block ) { | |||||||||
| 36 | 66 | $ser->serialize_to_stream($out, $entry); | |||||||||
| 37 | } | ||||||||||
| 38 | 3 | $self->v(" done.\n"); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 3 | $self->v("\r \r"); | |||||||||
| 42 | 3 | $self->v("no blocks remain.\n"); | |||||||||
| 43 | 1 | }; | |||||||||
| 44 | |||||||||||
| 45 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 46 | |||||||||||
| 47 | 1 | __PACKAGE__ | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||