The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

NAME

Data::AnyXfer::Elastic::Import::File::Simple - An object representing a collection of data in storage

SYNOPSIS

# initialise any type of storage...
use constant STORAGE =>
Data::AnyXfer::Elastic::Import::Storage::Directory->new(
dir => '/mnt/webdata/some/path' );
# 1. CREATE AN ENTRY...
my $file =
Data::AnyXfer::Elastic::Import::File::Simple->new(
name => 'My-Data',
storage => STORAGE, );
# store some data in the "file" entry
$file->add($$);
$file->add(%ENV);
# depending on the storage type, you may need to call save...
$storage->save;
# 2. AND THEN...AT SOME OTHER TIME...
my $file =
Data::AnyXfer::Elastic::Import::File::Simple->new(
name => 'My-Data',
storage => STORAGE, );
# get the pid back
print "PID: %s\n", $file->get;
# get the env back
my @env_data;
push @env_data, $data while ( my $data = $file->get );
print Data::Dumper::Dumper( { @env_data } );

DESCRIPTION

This is a low-level module representing a Data::AnyXfer::Elastic collection of data. The interface allows the storage and interaction with the data collection. Details of actual storage and persistence are handled by the Data::AnyXfer::Elastic::Import::Storage backend. See the "storage" attribute.

Not all perl data structures may be supported. Serialisation is handled by Data::AnyXfer::Elastic::Import::File::Format. See the "format" attribute.

This module implements: Data::AnyXfer::Elastic::Import::File

ATTRIBUTES

storage

Optional. The storage backend to retrieve and manipulate data from. If not supplied, will default to an instance of Data::AnyXfer::Elastic::Import::Storage::TempDirectory.

name

Optional. The name of the data collection. This will be need to match to retrieve the same data.

format

Optional. An implementation of Data::AnyXfer::Elastic::Import::File::Format. This controls serialisation and supported data types.

If not supplied, defaults to an instance of Data::AnyXfer::Elastic::Import::File::Format::JSON,

DATA INTERFACE

Please see Data::AnyXfer::Elastic::Import::File for the interface definition and information.

ADDITIONAL METHODS

reset_item_pos

Does the same as the "reset" method but more descriptive. Can be used by subclasses to provide clarity when multiple types of 'resets' are available.

See "reset" in Data::AnyXfer::Elastic::Import::File for the interface definition.

content

# get all of the content
my @data = @{ $file->content };
# or set it...
$file->content([1..10]);

Fetch or overwrite the entire contents of the data collection. All at once.

This method should NOT be favoured over the standard iteration interface provided by "get" in Data::AnyXfer::Elastic::Import::File and "add" in Data::AnyXfer::Elastic::Import::File.

Knowledge of the entry structure and underlying implementation is required, or there may be unknown side-effects.

This is mostly intended for use within specialised subclasses such as Data::AnyXfer::Elastic::Import::File::MultiPart.

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.