line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Filter::LZW; |
2
|
|
|
|
|
|
|
$POE::Filter::LZW::VERSION = '1.74'; |
3
|
|
|
|
|
|
|
#ABSTRACT: A POE filter wrapped around Compress::LZW |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
14301
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
68
|
|
8
|
1
|
|
|
1
|
|
397
|
use Compress::LZW qw(compress decompress); |
|
1
|
|
|
|
|
93031
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
8
|
use base qw(POE::Filter); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
472
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
348
|
my $type = shift; |
13
|
2
|
50
|
|
|
|
8
|
croak "$type requires an even number of parameters" if @_ % 2; |
14
|
2
|
|
|
|
|
3
|
my $buffer = { @_ }; |
15
|
2
|
|
|
|
|
3
|
$buffer->{ lc $_ } = delete $buffer->{ $_ } for keys %{ $buffer }; |
|
2
|
|
|
|
|
6
|
|
16
|
2
|
|
|
|
|
5
|
$buffer->{BUFFER} = []; |
17
|
2
|
|
|
|
|
12
|
return bless $buffer, $type; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub level { |
21
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
22
|
0
|
|
|
|
|
0
|
my $level = shift; |
23
|
0
|
0
|
|
|
|
0
|
$self->{level} = $level if defined $level; |
24
|
0
|
|
|
|
|
0
|
return $self->{level}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get { |
28
|
2
|
|
|
2
|
1
|
10
|
my ($self, $raw_lines) = @_; |
29
|
2
|
|
|
|
|
2
|
my $events = []; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
3
|
foreach my $raw_line (@$raw_lines) { |
32
|
2
|
50
|
|
|
|
5
|
if ( my $line = decompress( $raw_line ) ) { |
33
|
2
|
|
|
|
|
2073
|
push @$events, $line; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
0
|
warn "Couldn\'t decompress input\n"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
5
|
return $events; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_one_start { |
43
|
1
|
|
|
1
|
1
|
19
|
my ($self, $raw_lines) = @_; |
44
|
1
|
|
|
|
|
1
|
push @{ $self->{BUFFER} }, $_ for @{ $raw_lines }; |
|
1
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
6
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_one { |
48
|
4
|
|
|
4
|
1
|
163
|
my $self = shift; |
49
|
4
|
|
|
|
|
4
|
my $events = []; |
50
|
|
|
|
|
|
|
|
51
|
4
|
100
|
|
|
|
4
|
if ( my $raw_line = shift @{ $self->{BUFFER} } ) { |
|
4
|
|
|
|
|
11
|
|
52
|
3
|
50
|
|
|
|
6
|
if ( my $line = decompress( $raw_line ) ) { |
53
|
3
|
|
|
|
|
2481
|
push @$events, $line; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
warn "Couldn\'t decompress input\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
4
|
|
|
|
|
118
|
return $events; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub put { |
63
|
3
|
|
|
3
|
1
|
2074
|
my ($self, $events) = @_; |
64
|
3
|
|
|
|
|
5
|
my $raw_lines = []; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
6
|
foreach my $event (@$events) { |
67
|
5
|
50
|
|
|
|
18
|
if ( my $line = compress( $event, $self->{level} ) ) { |
68
|
5
|
|
|
|
|
5160
|
push @$raw_lines, $line; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
warn "Couldn\'t compress output\n"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
3
|
|
|
|
|
6
|
return $raw_lines; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub clone { |
78
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
79
|
1
|
|
|
|
|
2
|
my $nself = { }; |
80
|
1
|
|
|
|
|
1
|
$nself->{$_} = $self->{$_} for keys %{ $self }; |
|
1
|
|
|
|
|
8
|
|
81
|
1
|
|
|
|
|
2
|
$nself->{BUFFER} = [ ]; |
82
|
1
|
|
|
|
|
3
|
return bless $nself, ref $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
qq[Cmprss me]; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |