Closed nhz2 closed 6 days ago
I wonder if it would be appropriate to call this sizehint!
.
I chose the name to match the style of the other functions in the transcoding protocol. This is also slightly stronger than a hint since with Zstd setting the wrong size will cause an error.
I guess the convention here is not to use !
?
Could we make it clearer the order in which these functions will be called?
Also do we have a mechanism to pledge the size even in streaming mode?
I added some more details to the order of the function calls. The transcoding protocol can be used outside of the transcode
function since it is part of the stable API, though care has to be taken because these functions are potentially memory-unsafe.
@mkitti I added some examples of how pledgeinsize
could work in one of the test codecs.
The
pledgeinsize(codec::C, insize::Int64, error::Error)::Symbol
method is used whentranscode
is called to tell thecodec
the total input size. This is called afterstartproc
and beforeprocess
. Some compressors can add this total input size to a header, makingexpectedsize
accurate during later decompression. By default this just returns:ok
. If there is an error, the return code must be:error
and theerror
argument must be set to an exception object. Setting an inaccurateinsize
may cause the codec to error later on while processing data. A negativeinsize
means unknown content size.Ref: https://github.com/JuliaIO/CodecZstd.jl/pull/58
I think this is a nicer alternative to #215