ivankosenko / open-vcdiff

Automatically exported from code.google.com/p/open-vcdiff
Apache License 2.0
0 stars 0 forks source link

Encoder should buffer writes until flushed #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The current encoder interface VCDiffStreamingEncoder::EncodeChunk() accepts
a contiguous block of memory and creates a single VCDIFF delta window
(including a window header) each time it is called.  The intended use is
for the caller to gather all available input data into a buffer before
calling EncodeChunk(), so that the encoded delta window can be sent to
streaming output such as a TCP connection or output file.

However, there may be cases in which the currently available input data is
split up into more than one contiguous memory block.  Imagine that, instead
of a single block "ABCDEF", two blocks "ABC" and "DEF" are available for
encoding.  EncodeChunk("ABC",...) will be called, then
EncodeChunk("DEF",...), and each of the two blocks will get its own delta
window header (about a dozen bytes.)  To avoid wasting that space, the
caller has to copy the multiple blocks into a single contiguous memory
buffer before calling EncodeChunk().

Proposed enhancement: add a new interface (probably a new encoder class in
addition to VCDiffStreamingEncoder) that will queue up calls to
EncodeChunk() and not output a delta window until a function FinishWindow()
is called.  The caller will use FinishWindow() to indicate that no more
input data is available at the moment, and that the encoder should generate
as much output data as it can.  Calling FinishEncoding() will implicitly
finish the current window.

Original issue reported on code.google.com by openvcd...@gmail.com on 12 Sep 2008 at 4:46