line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sereal; |
2
|
4
|
|
|
4
|
|
350287
|
use 5.008; |
|
4
|
|
|
|
|
38
|
|
3
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
71
|
|
4
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
251
|
|
5
|
|
|
|
|
|
|
our $VERSION= '5.001'; |
6
|
|
|
|
|
|
|
our $XS_VERSION= $VERSION; $VERSION= eval $VERSION; |
7
|
4
|
|
|
|
|
382
|
use Sereal::Encoder 5.001 qw( |
8
|
|
|
|
|
|
|
encode_sereal |
9
|
|
|
|
|
|
|
sereal_encode_with_object |
10
|
|
|
|
|
|
|
SRL_UNCOMPRESSED |
11
|
|
|
|
|
|
|
SRL_SNAPPY |
12
|
|
|
|
|
|
|
SRL_ZLIB |
13
|
|
|
|
|
|
|
SRL_ZSTD |
14
|
4
|
|
|
4
|
|
22
|
); |
|
4
|
|
|
|
|
60
|
|
15
|
4
|
|
|
|
|
334
|
use Sereal::Decoder 5.001 qw( |
16
|
|
|
|
|
|
|
decode_sereal |
17
|
|
|
|
|
|
|
looks_like_sereal |
18
|
|
|
|
|
|
|
decode_sereal_with_header_data |
19
|
|
|
|
|
|
|
scalar_looks_like_sereal |
20
|
|
|
|
|
|
|
sereal_decode_with_object |
21
|
|
|
|
|
|
|
sereal_decode_with_header_with_object |
22
|
|
|
|
|
|
|
sereal_decode_only_header_with_object |
23
|
|
|
|
|
|
|
sereal_decode_only_header_with_offset_with_object |
24
|
|
|
|
|
|
|
sereal_decode_with_header_and_offset_with_object |
25
|
|
|
|
|
|
|
sereal_decode_with_offset_with_object |
26
|
4
|
|
|
4
|
|
23
|
); |
|
4
|
|
|
|
|
52
|
|
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
21
|
use Exporter 'import'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1560
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK= qw( |
30
|
|
|
|
|
|
|
get_sereal_decoder |
31
|
|
|
|
|
|
|
get_sereal_encoder |
32
|
|
|
|
|
|
|
clear_sereal_object_cache |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
encode_sereal |
35
|
|
|
|
|
|
|
decode_sereal |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
read_sereal |
38
|
|
|
|
|
|
|
read_sereal_file |
39
|
|
|
|
|
|
|
write_sereal |
40
|
|
|
|
|
|
|
write_sereal_file |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
looks_like_sereal |
43
|
|
|
|
|
|
|
scalar_looks_like_sereal |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sereal_encode_with_object |
46
|
|
|
|
|
|
|
sereal_decode_with_object |
47
|
|
|
|
|
|
|
decode_sereal_with_header_data |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sereal_decode_with_header_with_object |
50
|
|
|
|
|
|
|
sereal_decode_only_header_with_object |
51
|
|
|
|
|
|
|
sereal_decode_only_header_with_offset_with_object |
52
|
|
|
|
|
|
|
sereal_decode_with_header_and_offset_with_object |
53
|
|
|
|
|
|
|
sereal_decode_with_offset_with_object |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
SRL_UNCOMPRESSED |
56
|
|
|
|
|
|
|
SRL_SNAPPY |
57
|
|
|
|
|
|
|
SRL_ZLIB |
58
|
|
|
|
|
|
|
SRL_ZSTD |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
our %EXPORT_TAGS= ( all => \@EXPORT_OK ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# export by default if run from command line |
63
|
|
|
|
|
|
|
our @EXPORT= ( ( caller() )[1] eq '-e' ? @EXPORT_OK : () ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
our %ENCODERS; |
66
|
|
|
|
|
|
|
our %DECODERS; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _key { |
69
|
14
|
|
|
14
|
|
16
|
join "\t", map { $_ => $_[0]->{$_} } sort keys %{ $_[0] }; |
|
8
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
771
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub clear_sereal_object_cache { |
73
|
1
|
|
|
1
|
1
|
1292
|
my $count= keys(%DECODERS) + keys(%ENCODERS); |
74
|
1
|
|
|
|
|
3
|
%ENCODERS= (); |
75
|
1
|
|
|
|
|
2
|
%DECODERS= (); |
76
|
1
|
|
|
|
|
4
|
return $count; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub get_sereal_encoder { |
80
|
5
|
|
|
5
|
1
|
2701
|
my ($opts)= @_; |
81
|
5
|
|
66
|
|
|
11
|
return $ENCODERS{ _key($opts) } ||= Sereal::Encoder->new($opts); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_sereal_decoder { |
85
|
9
|
|
|
9
|
1
|
21
|
my ($opts)= @_; |
86
|
9
|
|
66
|
|
|
15
|
return $DECODERS{ _key($opts) } ||= Sereal::Decoder->new($opts); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub write_sereal_file { |
90
|
2
|
|
|
2
|
1
|
1054
|
my ( $file, $struct, $append, $opts )= @_; |
91
|
2
|
|
|
|
|
7
|
get_sereal_encoder($opts)->encode_to_file( $file, $_[1], $append ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub read_sereal_file { |
95
|
6
|
|
|
6
|
1
|
2577
|
my ( $file, $opts )= @_; |
96
|
6
|
100
|
|
|
|
14
|
get_sereal_decoder($opts)->decode_from_file( $file, @_ > 2 ? $_[2] : () ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
*read_sereal= *read_sereal= *read_sereal_file; |
100
|
|
|
|
|
|
|
*write_sereal= *write_sereal= *write_sereal_file; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |