NAME

KiokuDB::Cmd::Command::Load - Load database dumps

SYNOPSIS

# command line API
# dump whole database to foo.yml sequentially

% kiokuload --verbose --file foo.yml --format yaml --clear --dsn bdb-gin:dir=data/


# programmatic API

use KiokuDB::Cmd::Command::Load;

my $loader = KiokuDB::Cmd::Command::Load->new(
    backend => $backend,
    formatter => sub { ... },
    input_handle => $fh,
);

$dumper->run;

DESCRIPTION

This class loads dumps created by KiokuDB::Cmd::Command::Dump.

Entries will be read sequentially from input_handle, deserialized, and inserted into the database.

If the backend supports KiokuDB::Backend::Role::TXN then the load is performed in a single transaction.

COMMAND LINE API

This class uses MooseX::Getopt to provide a command line api.

The command line options map to the class attributes.

METHODS

new_with_options

Provided by MooseX::Getopt. Parses attributes init args from @ARGV.

run

Performs the actual load.

ATTRIBUTES

dsn
backend

The backend to be dumped.

dsn is a string and thus can be used on the command line. backend is defined in terms of dsn if it isn't provided.

format
formatter

format is one of yaml, storable or json, defaulting to yaml.

formatter is a code reference that is provided with a file handle and should return at least one entry object.

It is applied to the handle repeatedly until no more entries are returned.

clear

If set, KiokuDB::Backend::Role::Clear's interface will be used to wipe the database before loading.

file
input_handle

input_handle is where entries will be read from.

If it isn't provided and then file will be opened for reading.

If file isn't provided STDIN will be used.

verbose

If enabled causes progress information to be printed to STDERR.