From: Alexandre Mestiashvili Date: Thu, 6 Mar 2014 16:39:57 +0000 (+0100) Subject: Imported Upstream version 2.04 X-Git-Tag: archive/raspbian/4.017+ds-1+rpi1~1^2~3^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3153c22c12a6b78b743ddcafaf864c303469f168;p=libsereal-encoder-perl.git Imported Upstream version 2.04 --- diff --git a/Changes b/Changes index 23f012b..929482d 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,9 @@ Revision history for Perl extension Sereal-Encoder * of the decoder before upgrading to version 2 of the * encoder! +2.04 Wed Mar 5 18:15 2014 (AMS time) + - Fix rt.cpan.org #93484 - fencepost error in Encoder.xs (Zefram) + 2.03 Tue Jan 7 20:00 2014 (AMS time) - (Hopefully) final fixes to FREEZE/THAW functionality: => Add safe assertion to make sure that we don't segfault on invalid diff --git a/Encoder.xs b/Encoder.xs index a366199..bb3b32f 100644 --- a/Encoder.xs +++ b/Encoder.xs @@ -42,7 +42,7 @@ encode(enc, src, ...) SV *hdr_user_data_src = NULL; PPCODE: assert(enc != NULL); - if (items >= 2 && SvOK(ST(2))) + if (items > 2 && SvOK(ST(2))) hdr_user_data_src = ST(2); srl_dump_data_structure(aTHX_ enc, src, hdr_user_data_src); assert(enc->buf.pos > enc->buf.start); diff --git a/MANIFEST b/MANIFEST index 7f6d2d3..52a221d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -36,8 +36,6 @@ t/003_ptable.t t/010_desperate.t t/020_sort_keys.t t/021_sort_keys_option.t -t/100_roundtrip.t -t/101_roundtrip_v1.t t/110_nobless.t t/120_hdr_data.t t/130_freezethaw.t @@ -45,10 +43,11 @@ t/160_recursion.t t/200_bulk.t t/300_fail.t t/400_evil.t +t/700_roundtrip.t +t/701_roundtrip_v1.t t/800_threads.t t/data/corpus t/lib/Sereal/BulkTest.pm t/lib/Sereal/TestSet.pm typemap -META.yml Module YAML meta-data (added by MakeMaker) -META.json Module JSON meta-data (added by MakeMaker) +META.yml Module meta-data (added by MakeMaker) diff --git a/META.json b/META.json deleted file mode 100644 index b5e53f9..0000000 --- a/META.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "abstract" : "Fast, compact, powerful binary serialization", - "author" : [ - "Steffen Mueller , Yves Orton " - ], - "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", - "license" : [ - "perl_5" - ], - "meta-spec" : { - "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : "2" - }, - "name" : "Sereal-Encoder", - "no_index" : { - "directory" : [ - "t", - "inc" - ] - }, - "prereqs" : { - "build" : { - "requires" : { - "Data::Dumper" : "0", - "ExtUtils::ParseXS" : "2.21", - "File::Find" : "0", - "File::Path" : "0", - "File::Spec" : "0", - "Scalar::Util" : "0", - "Sereal::Decoder" : "2.03", - "Test::LongString" : "0", - "Test::More" : "0.88", - "Test::Warn" : "0" - } - }, - "configure" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - } - }, - "runtime" : { - "requires" : { - "XSLoader" : "0", - "perl" : "5.008" - } - } - }, - "release_status" : "stable", - "resources" : { - "bugtracker" : { - "web" : "https://github.com/Sereal/Sereal/issues" - }, - "repository" : { - "url" : "git://github.com/Sereal/Sereal.git" - } - }, - "version" : "2.03" -} diff --git a/META.yml b/META.yml index 917c859..e6386ea 100644 --- a/META.yml +++ b/META.yml @@ -1,35 +1,35 @@ ---- -abstract: 'Fast, compact, powerful binary serialization' +--- #YAML:1.0 +name: Sereal-Encoder +version: 2.04 +abstract: Fast, compact, powerful binary serialization author: - - 'Steffen Mueller , Yves Orton ' -build_requires: - Data::Dumper: 0 - ExtUtils::ParseXS: 2.21 - File::Find: 0 - File::Path: 0 - File::Spec: 0 - Scalar::Util: 0 - Sereal::Decoder: 2.03 - Test::LongString: 0 - Test::More: 0.88 - Test::Warn: 0 + - Steffen Mueller , Yves Orton +license: perl +distribution_type: module configure_requires: - ExtUtils::MakeMaker: 0 -dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' -license: perl -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 -name: Sereal-Encoder -no_index: - directory: - - t - - inc + ExtUtils::MakeMaker: 0 +build_requires: + Data::Dumper: 0 + ExtUtils::ParseXS: 2.21 + File::Find: 0 + File::Path: 0 + File::Spec: 0 + Scalar::Util: 0 + Sereal::Decoder: 2.03 + Test::LongString: 0 + Test::More: 0.88 + Test::Warn: 0 requires: - XSLoader: 0 - perl: 5.008 + perl: 5.008 + XSLoader: 0 resources: - bugtracker: https://github.com/Sereal/Sereal/issues - repository: git://github.com/Sereal/Sereal.git -version: 2.03 + bugtracker: https://github.com/Sereal/Sereal/issues + repository: git://github.com/Sereal/Sereal.git +no_index: + directory: + - t + - inc +generated_by: ExtUtils::MakeMaker version 6.57_05 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 diff --git a/author_tools/hobodecoder.pl b/author_tools/hobodecoder.pl index 0c0f935..143051c 100644 --- a/author_tools/hobodecoder.pl +++ b/author_tools/hobodecoder.pl @@ -239,7 +239,7 @@ sub parse_hv { while ($len--) { my $t = substr($data, 0, 1); my $o = ord($t); - print( " ", $ind, ($flipflop++ % 2 == 1 ? "VALUE" : "KEY"), ":\n" ); + printf "$fmt2%s:\n",("") x $lead_items, $ind, ($flipflop++ %2 == 1 ? "VALUE" : "KEY"); parse_sv($ind." "); } } diff --git a/lib/Sereal/Encoder.pm b/lib/Sereal/Encoder.pm index a636541..906007a 100644 --- a/lib/Sereal/Encoder.pm +++ b/lib/Sereal/Encoder.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use XSLoader; -our $VERSION = '2.03'; # Don't forget to update the TestCompat set for testing against installed decoders! +our $VERSION = '2.04'; # Don't forget to update the TestCompat set for testing against installed decoders! # not for public consumption, just for testing. (my $num_version = $VERSION) =~ s/_//; @@ -58,6 +58,8 @@ there is a discussion of the design objectives in L, and the output of our benchmarks can be seen at L. +For more information on getting the best performance out of Sereal, have a look +at the L section below. =head1 CLASS METHODS @@ -205,7 +207,7 @@ various caveats involved. =head3 no_shared_hashkeys -When the C option is set ot a true value, then +When the C option is set to a true value, then the encoder will disable the detection and elimination of repeated hash keys. This only has an effect for serializing structures containing hashes. By skipping the detection of repeated hash keys, performance goes up a bit, @@ -217,7 +219,7 @@ Do not disable this unless you have a reason to. If this is option is enabled/true then Sereal will use a hash to encode duplicates of strings during serialization efficiently using (internal) backreferences. This -has a peformance and memory penalty during encoding so it defaults to off. +has a performance and memory penalty during encoding so it defaults to off. On the other hand, data structures with many duplicated strings will see a significant reduction in the size of the encoded form. Currently only strings longer than 3 characters will be deduped, however this may change in the future. @@ -245,7 +247,7 @@ This option enables a mode of operation that is similar to I and if both options are set, I takes precedence. The behaviour of I differs from I -in that the duplicate occurrances of strings are emitted as Perl language +in that the duplicate occurrences of strings are emitted as Perl language level B instead of as Sereal-internal backreferences. This means that using this option actually produces a different output data structure when decoding. The upshot is that with this option, the application @@ -277,13 +279,24 @@ The functional interface that is equivalent to using C and C. Expects a data structure to serialize as first argument, optionally followed by a hash reference of options (see documentation for C). -The functional interface is marginally slower than the OO interface since +The functional interface is quite a bit slower than the OO interface since it cannot reuse the encoder object. =head1 PERFORMANCE +If you care about performance at all, then use the object-oriented interface +instead of the functional interface. It's a significant difference in performance +if you are serializing small data structures. + The exact performance in time and space depends heavily on the data structure -to be serialized. For ready-made comparison scripts, see the +to be serialized. Often there is a trade-off between space and time. If in doubt, +do your own testing and most importantly ALWAYS TEST WITH REAL DATA. If you +care purely about speed at the expense of output size, you can use the +C option for a small speed-up. If you need smaller output at +the cost of higher CPU load and more memory used during encoding/decoding, +try the C option and enable Snappy compression. + +For ready-made comparison scripts, see the F and F programs that are part of this distribution. Suffice to say that this library is easily competitive in both time and space efficiency with the best alternatives. @@ -304,7 +317,7 @@ by including the original object). But C can't return a list as with CBO This should not be any practical limitation whatsoever. Just return an array reference instead of a list. -Here is a contrived example of a class implementing the C / C mechansim. +Here is a contrived example of a class implementing the C / C mechanism. package File; @@ -413,10 +426,10 @@ applies to HASH vs. HASHREF. Similar to how Sereal can represent arrays and hashes in a full and a compact form. For small integers (between -16 and +15 inclusive), Sereal emits only one byte including the encoding of the type of data. For larger integers, -it can use either varints (positive only) or zigzag encoding, which can also +it can use either variants (positive only) or zigzag encoding, which can also represent negative numbers. For a canonical mode, the space optimizations would have to be turned off and it would have to be explicitly specified -whether varint or zigzag encoding is to be used for encoding positive +whether variant or zigzag encoding is to be used for encoding positive integers. Perl may choose to retain multiple representations of a scalar. Specifically, @@ -462,7 +475,7 @@ L Sereal development list: L -=head1 AUTHORS +=head1 AUTHORS AND CONTRIBUTORS Yves Orton Edemerphq@gmail.comE @@ -478,6 +491,8 @@ Tim Bunce Daniel Dragan Ebulkdd@cpan.orgE (Windows support and bugfixes) +Zefram + Some inspiration and code was taken from Marc Lehmann's excellent L module due to obvious overlap in problem domain. Thank you! diff --git a/t/100_roundtrip.t b/t/100_roundtrip.t deleted file mode 100644 index 2889ce9..0000000 --- a/t/100_roundtrip.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl -use strict; -use warnings; -use Sereal::Encoder; -use Data::Dumper; -use File::Spec; - -# These tests use an installed Decoder (or respectively Encoder) to do -# round-trip testing. There are two strategies, both with drawbacks: -# - Test::More's is_deeply is waaaay too lenient to catch all the -# subtleties that Sereal is supposed to encode. -# - Serialize - Deserialize - Serialize, then do a string compare. -# This won't catch if the first serialization has bogus output -# but the subsequent de- & serialization work for the already -# bogus output. -# These tests can't replace carefully crafted manual tests, I fear. - -use lib File::Spec->catdir(qw(t lib)); -BEGIN { - lib->import('lib') - if !-d 't'; -} - -use Sereal::TestSet qw(:all); -use Test::More; - -my $ok = have_encoder_and_decoder(); -if (not $ok) { - plan skip_all => 'Did not find right version of decoder'; -} -else { - run_roundtrip_tests(2); # 2 is "run for proto version 2 only" -} - - -pass(); -done_testing(); - diff --git a/t/101_roundtrip_v1.t b/t/101_roundtrip_v1.t deleted file mode 100644 index 3c065f1..0000000 --- a/t/101_roundtrip_v1.t +++ /dev/null @@ -1,38 +0,0 @@ -#!perl -use strict; -use warnings; -use Sereal::Encoder; -use Data::Dumper; -use File::Spec; - -# These tests use an installed Decoder (or respectively Encoder) to do -# round-trip testing. There are two strategies, both with drawbacks: -# - Test::More's is_deeply is waaaay too lenient to catch all the -# subtleties that Sereal is supposed to encode. -# - Serialize - Deserialize - Serialize, then do a string compare. -# This won't catch if the first serialization has bogus output -# but the subsequent de- & serialization work for the already -# bogus output. -# These tests can't replace carefully crafted manual tests, I fear. - -use lib File::Spec->catdir(qw(t lib)); -BEGIN { - lib->import('lib') - if !-d 't'; -} - -use Sereal::TestSet qw(:all); -use Test::More; - -my $ok = have_encoder_and_decoder(); -if (not $ok) { - plan skip_all => 'Did not find right version of decoder'; -} -else { - run_roundtrip_tests(1); # 1 is "run for proto-version 1 only" -} - - -pass(); -done_testing(); - diff --git a/t/700_roundtrip.t b/t/700_roundtrip.t new file mode 100644 index 0000000..2889ce9 --- /dev/null +++ b/t/700_roundtrip.t @@ -0,0 +1,38 @@ +#!perl +use strict; +use warnings; +use Sereal::Encoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of decoder'; +} +else { + run_roundtrip_tests(2); # 2 is "run for proto version 2 only" +} + + +pass(); +done_testing(); + diff --git a/t/701_roundtrip_v1.t b/t/701_roundtrip_v1.t new file mode 100644 index 0000000..3c065f1 --- /dev/null +++ b/t/701_roundtrip_v1.t @@ -0,0 +1,38 @@ +#!perl +use strict; +use warnings; +use Sereal::Encoder; +use Data::Dumper; +use File::Spec; + +# These tests use an installed Decoder (or respectively Encoder) to do +# round-trip testing. There are two strategies, both with drawbacks: +# - Test::More's is_deeply is waaaay too lenient to catch all the +# subtleties that Sereal is supposed to encode. +# - Serialize - Deserialize - Serialize, then do a string compare. +# This won't catch if the first serialization has bogus output +# but the subsequent de- & serialization work for the already +# bogus output. +# These tests can't replace carefully crafted manual tests, I fear. + +use lib File::Spec->catdir(qw(t lib)); +BEGIN { + lib->import('lib') + if !-d 't'; +} + +use Sereal::TestSet qw(:all); +use Test::More; + +my $ok = have_encoder_and_decoder(); +if (not $ok) { + plan skip_all => 'Did not find right version of decoder'; +} +else { + run_roundtrip_tests(1); # 1 is "run for proto-version 1 only" +} + + +pass(); +done_testing(); +