Data-FastPack-JPacker
view release on metacpan or search on metacpan
lib/Data/FastPack/JPacker.pm view on Meta::CPAN
=head1 TITLE
Data::FastPack::JPacker - backend class for packing FastPack data files into web loadable JPack
=head1 SYNOPSIS
use Data::FastPack::JPacker;
my @pairs=("input/path", "output/location");
my %options=();
my $jpacker=Data::FastPack::JPaker->new(%options)
$jpacker->pack_files(@pairs);
=head1 DESCRIPTION
Backend to the fastpack-split program. Splits input files or standard input
(assumed FastPack messages/frames) in to output files encoded in JPack. A
sequence of files may be created representing a single input file. The
resulting jpack files are loadable via JPack in the browser
=head1 API
=cut
package Data::FastPack::JPacker;
our $VERSION="v0.1.0";
# Module for encoding Fastpack time series as JPACK files
# Also splits Fastpack files into smaller ones either on message count or byte limit
#
use strict;
use warnings;
use feature "say";
use Data::FastPack; # For parsing data files
use Data::JPack; # For packing/unpacking JPack
use File::Path qw<make_path>;
use File::Spec::Functions qw<rel2abs abs2rel>;
use File::Basename qw<basename dirname>;
use feature ":all";
#use constant KEY_OFFSET=>Data::JPack::Packer::KEY_OFFSET+Data::JPack::Packer::KEY_COUNT;
use constant::more ("byte_limit_="."0", qw<
byte_size_
message_limit_
message_count_
messages_
html_root_
html_container_
jpack_
jpack_options_
write_threshold_
read_size_
ifh_
out_fh_
in_buffer_
out_buffer_
input_done_flag_
file_count_
first_
>);
#use constant KEY_COUNT=first_-byte_limit_+1;
=head2 new
Create a new packer. No arguments
=cut
sub new{
my $package=shift//__PACKAGE__;
my $self=[];
$self->[messages_]=[];
bless $self, $package;
$self->init(@_);
}
=head2 init
$jpacker->init( OPTIONS )
Initializes a packer with the options (key value pairs) given
The options to this are
=over
=item html_container
The path to the root dir or 'index.html' file in the root of the html
directory. Data will be stored relative to the container
=item jpack_options
Options specific to the JPack encoding. Please refere to L<Data::JPack> for
more details
( run in 1.007 second using v1.01-cache-2.11-cpan-39bf76dae61 )