| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Cmd::Command::Load; | ||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use KiokuDB::Entry; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use KiokuDB::Reference; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | extends qw(KiokuDB::Cmd::Base); | |||||||||
| 12 | |||||||||||
| 13 | 1 | with qw( | |||||||||
| 14 | KiokuDB::Cmd::WithDSN::Create | ||||||||||
| 15 | KiokuDB::Cmd::DumpFormatter | ||||||||||
| 16 | KiokuDB::Cmd::InputHandle | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | augment run => sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.9
| |||||||||||
| 20 | 3 | my $self = shift; | |||||||||
| 21 | |||||||||||
| 22 | 3 | my $b = $self->backend; | |||||||||
| 23 | |||||||||||
| 24 | 3 | my $in = $self->input_handle; | |||||||||
| 25 | 3 | my $ser = $self->serializer; | |||||||||
| 26 | |||||||||||
| 27 | 3 | my $i = my $j = 0; | |||||||||
| 28 | |||||||||||
| 29 | 3 | ▶ | while ( my @entries = $ser->deserialize_from_stream($in) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 26 | ▶ | if ( $self->verbose ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $i += @entries; | |||||||||
| 32 | 0 | $j += @entries; | |||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | if ( $j > 13 ) { # luv primes | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | $j = 0; | |||||||||
| 36 | 0 | $self->v("\rloading... $i"); | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 26 | $b->insert(@entries); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 2 | $self->v("\rloaded $i entries \n"); | |||||||||
| 44 | |||||||||||
| 45 | 2 | $self->try_txn_commit($b); | |||||||||
| 46 | 1 | }; | |||||||||
| 47 | |||||||||||
| 48 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 49 | |||||||||||
| 50 | 1 | __PACKAGE__ | |||||||||
| 51 | |||||||||||
| 52 | __END__ | ||||||||||