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