| 1 | package POE::Filter::LZW::Progressive; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use Compress::LZW::Progressive; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use base qw(POE::Filter); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.1'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=13.0
Pod
documented
| |||||||||||||||||||||
| 12 | 1 | my ($class, %args) = @_; | |||||||||||||||||||
| 13 | # Filter passthru args to just those that are pertinent | ||||||||||||||||||||
| 14 | 0 | my %passthru_args = map { $_ => $args{$_} } grep { /^(bits)$/ } keys %args; | |||||||||||||||||||
| 15 | 1 | ▶ | $args{codec} ||= Compress::LZW::Progressive->new(%passthru_args); | ||||||||||||||||||
|
Condition33%1/3
$args{"codec"} ||= "Compress::LZW::Progressive"->new(%passthru_args)
MC/DC0%0/2
$args{"codec"} ||= "Compress::LZW::Progressive"->new(%passthru_args)
$args{"codec"}
"Compress::LZW::Progressive"->new(%passthru_args)
Truth table33%1/3
A ||= B
A= $args{"codec"}B= "Compress::LZW::Progressive"->new(%passthru_args)
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | $args{buffer} = ''; | |||||||||||||||||||
| 18 | 1 | ▶ | return bless \%args, ref $class ? ref $class : $class; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub reset { | ||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||
| 23 | 0 | $self->{codec}->reset(); | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub clone { | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||
| 28 | 0 | return $self->new(); | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | ## | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 1 | ▶ | sub get { | ||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||
| 34 | 1 | my ($self, $raw_lines) = @_; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | my @records; | |||||||||||||||||||
| 37 | 1 | foreach my $line (@$raw_lines) { | |||||||||||||||||||
| 38 | 1 | my $decompressed = $self->{codec}->decompress($line); | |||||||||||||||||||
| 39 | 1 | push @records, $decompressed; | |||||||||||||||||||
| 40 | printf STDERR "POE::Filter::LZW::Progressive get(): decompressed %d B to %d B\n", | ||||||||||||||||||||
| 41 | 1 | ▶ | length($line), length($decompressed) if $self->{debug}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 1 | ▶ | printf STDERR "POE::Filter::LZW::Progressive get(): returning %d records\n", int(@records) if $self->{debug}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 1 | return \@records; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub get_one_start { | ||||||||||||||||||
|
Subroutine
get_one_start: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 48 | 0 | my ($self, $raw_lines) = @_; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | $self->{buffer} .= join '', @$raw_lines; | |||||||||||||||||||
| 51 | 0 | ▶ | printf STDERR "POE::Filter::LZW::Progressive get_one_start(): buffer now %d\n", length($self->{buffer}) if $self->{debug} > 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub get_one { | ||||||||||||||||||
|
Subroutine
get_one: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||
| 56 | 0 | ▶ | return [] unless length $self->{buffer}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | my $return = [ $self->{codec}->decompress( $self->{buffer} ) ]; | |||||||||||||||||||
| 59 | printf STDERR "POE::Filter::LZW::Progressive get_one(): decompressed %d B to %d B (%s)\n", | ||||||||||||||||||||
| 60 | 0 | ▶ | length($self->{buffer}), length($return->[0]), $self->{codec}->stats('decompress') if $self->{debug}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | $self->{buffer} = ''; | |||||||||||||||||||
| 63 | 0 | return $return; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # Same as get_one() but doesn't clear the buffer | ||||||||||||||||||||
| 67 | 0 | ▶ | sub get_pending { | ||||||||||||||||||
|
Subroutine
get_pending: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||||||||||
| 69 | 0 | ▶ | printf STDERR "POE::Filter::LZW::Progressive get_pending()\n" if $self->{debug} > 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 0 | ▶ | return undef unless length $self->{buffer}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 0 | return [ $self->{codec}->decompress( $self->{buffer} ) ]; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 1 | ▶ | sub put { | ||||||||||||||||||
|
Subroutine
put: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 75 | 1 | my ($self, $records) = @_; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 1 | my @raw_lines; | |||||||||||||||||||
| 78 | 1 | foreach my $record (@$records) { | |||||||||||||||||||
| 79 | 1 | my $compressed = $self->{codec}->compress($record); | |||||||||||||||||||
| 80 | 1 | push @raw_lines, $compressed; | |||||||||||||||||||
| 81 | 1 | ▶ | print STDERR "POE::Filter::LZW::Progressive put(): ".$self->{codec}->stats('compress')."\n" if $self->{debug}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | 1 | return \@raw_lines; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||||