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